The Mixpanel object must be exposed globally
When installing Mixpanel SDK via npm, the mixpanel object is not available globally by default. You have to expose it manually to the global window object.
The Mixpanel integration enables you to filter session data by Mixpanel events. To use this integration, the mixpanel object must be exposed globally as the integration makes use of Mixpanel events from the client side and not from the server side. Mixpanel event properties are also ignored and filtering is only available based on the Mixpanel event name.
- How to enable the Mixpanel integration
- How to filter session data by Mixpanel events
- How to trigger a survey based on a Mixpanel event
How to enable the Mixpanel integration
Visit your Integrations page and select the site that will receive the integration. Then click Connect for Mixpanel.
Turn on Automatically send events to Hotjar to enable the integration.
How to filter session data by Mixpanel events
Before filtering, the Mixpanel integration needs to be enabled. You will only see Mixpanel events appear in your filter dropdown after at least one session that contains the Mixpanel event has been captured.
Mixpanel events can then be used to filter session data. Tools that use session data include Heatmaps, Recordings, Funnels, Dashboards and Trends pages. It doesn't include Surveys.
Inside a tool that uses session data, click Add filter and select Event.
Start typing MP_ followed by the Mixpanel event name to find the relevant event.
All Mixpanel events will appear with the MP_ prefix.
We will only receive Mixpanel events when at least one session has been captured containing the event. If you aren't seeing the event appear, ensure that Session Capture is enabled and that any targeting settings will capture your Mixpanel events.
Select the Mixpanel event to filter by, then click Apply.
You'll now see only those sessions from users associated with the selected Mixpanel event.
How to trigger a survey based on a Mixpanel event
Visit the Targeting section in the set up of a survey.
If you're creating a new survey, see our How to Create a Survey guides for further help.
Within the Pages subsection, select Specific pages and choose Event in the dropdown menu.
Enter the Event value using the MP_ prefix.
You'll need to know the exact Mixpanel event name being targeted.
To target a survey using a Mixpanel event, you'll need to know the name of that specific event. This can be entered in the Event field in your survey setup, adding "MP_" as the prefix.
If an event name contain spaces, the spaces need to be replaced with dashes in the survey targeting. For example, the Mixpanel event name "My survey event" would become "MP_My-survey-event".
Click Save changes and ensure the status of your survey is Active.
Your survey will appear when the event you've specified is triggered on a page. When using events for surveys, your behavior rules will still be followed. For example, you can set a survey to open after 10 seconds and use an event for targeting. In this case, the survey will appear 10 seconds after the event has been triggered (not 10 seconds after the page loaded).