Send your event data from RudderStack to Mixpanel.
Mixpanel is a powerful, self-serve product analytics solution for your web and mobile apps. By analyzing the actions your users perform, you can unlock valuable customer insights to drive retention, engagement, and conversion.
RudderStack supports Mixpanel as a destination where you can seamlessly send your event data.
Find the open source transformer code for this destination in the GitHub repository.
Getting started
RudderStack supports sending event data to Mixpanel via the following connection modes:
Connection Mode
Web
Mobile
Server
Device mode
Supported
-
-
Cloud mode
Supported
Supported
Supported
In a web device mode integration, that is, using JavaScript SDK as a source, the Mixpanel native SDK is loaded from https://cdn.mxpnl.com/ domain. Based on your website’s content security policy, you might need to allowlist this domain to load the Mixpanel SDK successfully.
Once you have confirmed that the source platform supports sending events to Mixpanel, follow these steps:
From your RudderStack dashboard, add a source. Then, from the list of destinations, select Mixpanel.
Assign a name to the destination and click Continue.
Connection settings
To successfully configure Mixpanel as a destination, you will need to configure the following settings:
API Token: Enter your Mixpanel API Token.
API Secret: Enter your Mixpanel API secret. For more information on obtaining the Mixpanel API Token and API Secret (also called Project Secret), refer to this Mixpanel Help Center page.
Mixpanel will deprecate the Project Secret authentication method soon. It is highly recommended to use Service Accounts for authenticating your Mixpanel project. For more information, refer to this Mixpanel API reference guide.
Service Account Username: Enter your Mixpanel service account username.
Service Account Secret: Enter the secret associated with your service account.
For more information on setting up your Mixpanel service account and getting the username and secret, refer to this Mixpanel Help Center page.
Project ID: Enter your Mixpanel project ID.
For more information on getting your Mixpanel project ID, refer to this Mixpanel Help Center page.
Data Residency: Select the relevant option among US and EU. RudderStack will send your event data to the Mixpanel server in that region.
The following settings are applicable if you are using this destination via web device mode:
Use Mixpanel People: This option sends all your identify calls to Mixpanel People. For more information, refer to the Mixpanel People section below.
Page Tracking Options: For device mode, RudderStack offers three options for the page calls. Refer to the Page web device mode settings section below for more information on these options.
Source Name: If specified, RudderStack sends this source name to Mixpanel for every event/page/screen call.
Cross Subdomain Cookie: If enabled, this option lets the Mixpanel cookie to persist between different pages of your application.
Persistence Type: This option lets you choose the persistence type for your Mixpanel cookies.
Secure Cookie: Enabling this option will mark the Mixpanel cookie as secure, i.e., it will only transmit over HTTPS.
Group Key Settings: RudderStack sends the group calls to Mixpanel only if one or more group keys are specified here. These group keys act as the group identifiers in Mixpanel. For more information, refer to the Group Key section below.
Client-side Events Filtering: Refer to the Client-side Event Filtering guide for more information on this feature.
The following event mapping setting is applicable only if you are sending events to Mixpanel via cloud mode:
Use New Mapping: This option is disabled by default and sends the first name and last name as:
$firstName : "John" $lastName : "Keener"
If this option is enabled, RudderStack maps these fields to Mixpanel in the following way :
$first_name : "John" $last_name : "Keener"
RudderStack lets you pass empty and null values for the properties sent to Mixpanel.
Identify
To identify a user in Mixpanel, you need to call RudderStack’s identify method.
Mixpanel needs an identifier to uniquely identify a user. If you pass userId and anonymousId along with the Mixpanel API Secret (in the dashboard settings), then RudderStack first makes an identify call to Mixpanel using the userId and the traits. RudderStack then passes the userId and anonymousId via Mixpanel’s Merge Identities feature, so that the two identifiers are glued to a single user profile.
When sending events via cloud mode, you can prevent the $last_seen attribute getting updated with incorrect times by setting active to false in the context object, as shown in the following snippet:
Setting active to false sets Mixpanel’s $ignore_time attribute to true. This way, you can bypass the “Last Seen” date property.
Reserved Mixpanel properties
Mixpanel has some reserved properties:
$first_name
$last_name
$name
$username
$created
$email
$phone
$avatar
$city
$country_code
$region
$unsubscribed
You should not create custom properties that begin with a $ sign.
Mixpanel People
RudderStack does not send data to Mixpanel People by default, as it usually requires you to upgrade your Mixpanel account. If you want to use this feature, you can enable the Use Mixpanel People option in the RudderStack dashboard.
You can identify the user traits without the userId if you wish to add the people properties in Mixpanel before knowing the userId. To do so, refer to the following snippet:
RudderStack passes all page properties that you provide via the page call to Mixpanel, along with the other default properties. RudderStack sets the event name as Page for a page call and Screen for a screen call.
A sample page call is shown below:
rudderanalytics.page();
Page web device mode settings
RudderStack will send 1 event to Mixpanel per page call.
For device mode, RudderStack offers the following three options for page calls:
Track All Pages with a Consolidated Event Name: This setting is enabled by default. RudderStack sends all page and screen calls with the name Loaded a Page with the corresponding properties of the call. This lets you leverage Mixpanel’s reporting capabilities for page/screen analytics in the best possible way.
Track Categorized Pages to Mixpanel: RudderStack tracks the categorized pages to Mixpanel. If you enable this setting in the dashboard, RudderStack sends a Viewed [<category>] Page event to Mixpanel. If the page name is also present in the event, then RudderStack sends a Viewed [<category> <page_name>] Page event.
Track Named Pages to Mixpanel: RudderStack also tracks the named pages to Mixpanel. If you enable this setting in the dashboard, RudderStack will send a Viewed [page_name] Page event. Note that this option has the least precedence and comes to effect only if the above two options are disabled in the RudderStack dashboard.
RudderStack gives the highest precedence to the Track All Pages with a Consolidated Event Name option even if Track Categorized Pages to Mixpanel and
Track Named Pages to Mixpanel are enabled in the dashboard.
RudderStack expects atleast one of the three options listed above to be enabled for sending the page events to Mixpanel using device mode.
Track
To track user events, use the track method with the event name and the associated properties.
Mixpanel lets you track revenue events. If you send revenue as a property in your track event, RudderStack tracks it as a revenue event.
Revenue tracking is done with a distinct_id (userId that you provide in your identify call; if userId is not present then it will be associated with an anonymousId.)
If Use Mixpanel People setting is enabled in your RudderStack dashboard and you include revenue as an event property, RudderStack will track a charge for the current user.
Alias
The alias call lets you associate multiple identities of a known user.
A sample alias call is as shown:
analytics.alias('userId',`previousId`);
Group
The group call lets you link an identified user with a group such as a company, organization, or an account, and record any traits associated with that group, for example, company name, number of employees, etc. For more information on how the group call works in Mixpanel, refer to Mixpanel’s Group Analytics documentation.
RudderStack lets you record the custom traits associated with a user group and send this information to Mixpanel.
You can create group keys in the Mixpanel project settings, which act as the group identifiers in Mixpanel. To successfully send a group call to Mixpanel, you must specify at least one group key in the Group Key RudderStack dashboard setting:
Note the following points:
If you map the groupId as a group key, RudderStack looks up its value in the following priority order:
In message.groupId
In message.traits.groupId
If you map any other field as a group key, RudderStack looks up its value in message.traits.groupKey.
You can specify multiple values for a group key and send them in an array in the group event payload.
Sending historic events
Mixpanel supports importing historical event data. However, note that the event timestamp should be within the last 5 years. Mixpanel rejects any data older than this duration. To send historic events, provide the timestamp in the timestamp field of the message. RudderStack will then send the event with the same timestamp to Mixpanel.
Mapping RudderStack properties to Mixpanel properties
RudderStack maps the following properties to the Mixpanel properties before sending them over Mixpanel’s HTTP API.
RudderStack maps these fields only in the identify requests.
RudderStack property
Mixpanel property
traits.createdAt
$created
traits.email
$email
traits.firstName
$firstName
traits.lastName
$lastName
traits.name
$name
traits.username
$username
traits.phone
$phone
traits.avatar
$avatar
context.ip
ip or $ip
context.campaign.name
campaign_id
context.page.url
$current_url
context.os.name
$os
context.page.referrer
$referrer
context.network.carrier
$carrier
address.city
$city
address.country
$country_code
address.region
$region
context.location.latitude
$latitude
context.location.longitude
$longitude
context.page.manufacturer
$manufacturer
context.device.model
$model
context.screen.width
$screen_width
context.screen.height
$screen_height
context.network.wifi
$wifi
context.location.geoSource
$geoSource
context.traits.unsubscribed
$unsubscribed
traits.unsubscribed
$unsubscribed
properties.unsubscribed
$unsubscribed
context.location.timezone
$timezone
Explicitly setting People Properties and Super Properties
You can set all of your traits as both Super Properties and People Properties (If you have Use Mixpanel People option enabled) by enabling the Automatically set all Traits as Super Properties and People Properties option in the RudderStack dashboard.
You can also choose to filter your reports by both People Properties and Super Properties. This gives you better control over what traits you can set as a Super Property or People Property. To do this, disable the Automatically set all Traits as Super Properties and People Properties option in the dashboard and add the traits that you want to send to Mixpanel as Super Properties or People Properties in the Properties to send as Super Properties and Traits to set as People Properties fields respectively, as shown below:
RudderStack will send all Mixpanel special traits as People Properties. Hence, you can only add the properties that are not in this list.
This feature is available in web device mode only.
Mixpanel special traits
The following table lists all properties that RudderStack sends to Mixpanel as special traits:
RudderStack Properties
Mixpanel Properties
created
$created
email
$email
firstName
$first_name
lastName
$last_name
lastSeen
$last_seen
name
$name
username
$username
phone
$phone
city/address.city
$city
region/address.state
$region
country/address.country
$country_code
Incrementing events in Mixpanel People
To increment event counts in Mixpanel People, you can add the events in the Events to increment in People field.
This feature is available in web device mode only.
For each event name added, RudderStack automatically calls Mixpanel and sets a user trait as Last + <event_name>. For example, if you add Logged In to the list of increment events, RudderStack will increment a user trait called Logged In and set a trait called Last Logged In with the current date and time.
Increment works for known users only. If you make a track call, you must identify your user first.
Incrementing properties in Mixpanel People
To increment properties in Mixpanel People, you can add them in the Properties to Increment in People field. RudderStack will call Mixpanel’s increment when you attach a number to the specified property. For example, 'items purchased': 5.
This feature is available in web device mode only.
Cross subdomain cookies
Cross Subdomain Cookie: This option will let you persist the Mixpanel cookie between different pages of your application.
Persistence Type: This option lets you choose the persistence type for your Mixpanel cookies.
Secure Cookie: Enabling this option will mark the Mixpanel cookie as secure, i.e., it will only transmit over HTTPs.
FAQ
Can I pass null and empty values for the properties?
Yes, RudderStack supports passing empty or null values for the properties sent to Mixpanel.
Why am I getting the ‘Request Header Fields Too Large’ error?
Mixpanel imposes certain limitations on its API requests such as:
Any GET request URL above 19K characters (around 19 KB+) is blocked.
The header size more than 15KB is not allowed.
The body of the request more than 20MB is not allowed.
Each event can have up to 255 event properties.
If your requests are larger than the above-mentioned limits, you will get a ‘Request Header Fields Too Large’ error.
This site uses cookies to improve your experience while you navigate through the website. Out of
these
cookies, the cookies that are categorized as necessary are stored on your browser as they are as
essential
for the working of basic functionalities of the website. We also use third-party cookies that
help
us
analyze and understand how you use this website. These cookies will be stored in your browser
only
with
your
consent. You also have the option to opt-out of these cookies. But opting out of some of these
cookies
may
have an effect on your browsing experience.
Necessary
Always Enabled
Necessary cookies are absolutely essential for the website to function properly. This
category only includes cookies that ensures basic functionalities and security
features of the website. These cookies do not store any personal information.
This site uses cookies to improve your experience. If you want to
learn more about cookies and why we use them, visit our cookie
policy. We'll assume you're ok with this, but you can opt-out if you wish Cookie Settings.