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

Before configuring your source and destination on the RudderStack, verify if the source platform is supported by Mixpanel by referring to the table below:

Connection ModeWebMobileServer
Device modeSupported--
Cloud modeSupportedSupportedSupported
To know more about the difference between cloud mode and device mode in RudderStack, refer to the RudderStack Connection Modes guide.

Once you have confirmed that the source platform supports sending events to Mixpanel, follow these steps:

  1. From your RudderStack dashboard, add a source. Then, from the list of destinations, select Mixpanel.
  2. 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 the 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.
  • Automatically set all Traits as Super Properties and People properties: Refer to the Explicitly setting People Properties and Super Properties section below.
  • Events to increment in People: Refer to the Incrementing events in Mixpanel People section below for more information on this field.
  • Properties to increment in People: Refer to the Incrementing properties in Mixpanel People section below for more information on this field.
  • 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. For more information, refer to the Group 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 the 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.

A sample identify call is as shown:

rudderanalytics.identify("12345", {
firstname: "Alex",
city: "New Orleans",
country: "USA",
phone: "8005550100",
email: "alex@example.com"
})

When sending events via the 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:

rudderanalytics.identify("12345", {
firstname: "Alex",
city: "New Orleans",
country: "USA"
}, {
context: {
active: false
}
})
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:

rudderanalytics.identify({
email: 'alex@example.com',
name: 'Alex Keener'
})
Currently, RudderStack supports this feature only for the web device mode.

Deleting a user

You can delete a user in Mixpanel using the Suppression with Delete regulation of the RudderStack Data Regulation API.

To delete a user, you need to specify their userId in the event.

A sample regulation request body for deleting a user in Mixpanel is shown below:

{
"regulationType": "suppress_with_delete",
"destinationIds": [
"2FIKkByqn37FhzczP23eZmURciA"
],
"users": [{
"userId": "1hKOmRA4GRlm",
"phone": "+1-202-555-0146",
"email": "alex@example.com"
}]
}

Page

RudderStack passes all the 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 the 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.

A sample track call is as shown:

rudderanalytics.track("track event", {
test_prop1: 50,
test_prop2: "prop_value"
});

Tracking revenue

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.)

A sample revenue track call is as shown:

rudderanalytics.track("Purchase", {
revenue: 100,
currency: "USD"
});

Tracking charge

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. It also lets you record any custom traits associated with that group like the name of the company, the 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.

A sample group call is shown below:

rudderanalytics.group(
"sample_group_id", {
name: "Tech group",
industry: "Technology",
employees: 100,
}
);

RudderStack sends the group calls to Mixpanel only if one or more group keys are specified during the destination configuration in RudderStack, as shown:

Mixpanel group key settings

You must create the group key(s) of the same name in your Mixpanel project settings. To administer the group keys, navigate to your project settings and click on Add Group Key under Group Keys.

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 propertyMixpanel 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.ipip or $ip
context.campaign.namecampaign_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:

mixpanel super people

RudderStack will send all the Mixpanel special traits as People Properties. Hence, you can only add the properties that are not in this list.

This feature is available in the web device mode only.

Mixpanel special traits

The following table lists all the properties that RudderStack sends to Mixpanel as special traits:

RudderStack PropertiesMixpanel 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 the 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 the 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.

Refer to the Mixpanel Community FAQ for more information.

Contact us

For more information on the topics covered on this page, email us or start a conversation in our Slack community.