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 topOn 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 topThe 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 topIn 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 topSomething 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.