Start a free 14-day trial by December 1 on a wide range of WooCommerce Marketplace extensions and themes. Explore products

Track custom events with WooCommerce Mixpanel

Use the WooCommerce Mixpanel integration to record a browser event when a visitor opens a specific page.

Note:

This is a developer-level doc. If you are unfamiliar working with code and resolving potential conflicts, we recommend you work with a Woo Agency Partner for larger projects, or find a WooCommerce developer on Codeable for smaller customization work. We are unable to provide support for customization under our Support Policy.

Record a custom page event

↑ Back to top

On a test site with the extension active and connected to a test Mixpanel project, add the following to your site’s custom plugin. Replace shop-information with the page slug you want to track. Use an event name and function prefix unique to your site.

/**
 * Queue a Mixpanel event when a visitor opens a specific page.
 */
function my_store_mixpanel_shop_information_event() {
	if ( ! is_page( 'shop-information' ) || ! function_exists( 'wc_mixpanel' ) ) {
		return;
	}

	$integration = wc_mixpanel()->get_integration();

	if ( $integration && $integration->token ) {
		$integration->custom_event(
			'Viewed shop information',
			array( 'Section' => 'Store details' )
		);
	}
}
add_action( 'wp', 'my_store_mixpanel_shop_information_event' );

Set a custom profile property

↑ Back to top

The integration also provides custom_user_properties_api(). Pass an associative array of properties and the WordPress user ID for the profile you want to update. The extension resolves that ID according to its configured name tag preference. Use a test user and avoid sending personal information you do not need.

Verify the event

↑ Back to top

In a shopper session, open the target page and look for Viewed shop information in your test project. Check that its Section property is Store details. Open a different page and confirm it does not add another copy of the event. Remove the callback when you no longer want to queue the event.

For built-in events and setup, see the WooCommerce Mixpanel guide.

Questions and support

↑ Back to top

Something missing from this documentation? Still have questions and need assistance?

  • If you have a question about a specific extension or theme you’d like to purchase, contact us to get answers.
  • If you already purchased this product and need some assistance, get in touch with a Happiness Engineer via our support page and select this product’s name from the Product dropdown.

Related Products

WooCommerce Subscriptions is a WooCommerce extension that lets customers subscribe to your products or...

Offer add-ons like gift wrapping, special messages or other special options for your products.

Use of your personal data
We and our partners process your personal data (such as browsing data, IP Addresses, cookie information, and other unique identifiers) based on your consent and/or our legitimate interest to optimize our website, marketing activities, and your user experience.