Docs
Tracking Methods
Segment

Segment

Segment is a CDP (Customer Data Platform) which lets you track event data and route it to various downstream destinations. Mixpanel integrates seamlessly with Segment -- if you use Segment, it takes just a few clicks to set up Mixpanel.

Startup Credit Program

Mixpanel offers $50K in credits to eligible startups (opens in a new tab). Because of our Segment partnership, we're also able to offer startups $50k in Segment credits. This gives startups the runway to use both tools for free.

Once you create your Segment and Mixpanel accounts, you can fill out this form (opens in a new tab) and Segment will get back to you within 48 hours to confirm your credits are applied.

Startup eligibility requirements:

  • Founded less than 2 years ago
  • Raised no more than $8MM USD in total funding

How the Integration Works

In the simplest form, the Segment libraries (“Sources”) generate messages about what’s happening in your site or app, and send them to the Segment servers. Segment then translates the content of those messages into different formats for use by other tools (which we call ‘Destinations’), and sends the translated messages to those tools. The Segment servers also archive a copy of the data, and can send data to your storage systems (such as databases, warehouses, or bulk-storage buckets).

For detailed instructions on how to install and initialize the Segment library please refer to the Segment Getting Started Guide (opens in a new tab).

1. Integrate with Segment

Once you've installed and initialized a Segment library in your application, get your data into Mixpanel by following the instructions for setting up the Mixpanel (Actions) Destination (opens in a new tab)

2. Identify Users

The next thing you need to do is identify your users, so that you can understand what your users are really doing. When you call Segment's identify API (opens in a new tab), Mixpanel will set the specified userId as the Mixpanel distinct_id along with any additional traits that you provide.

3. Track User Actions

Lastly, track your users' actions using Segment's track API call (opens in a new tab).

4. Check for Success

Open up Events View in Mixpanel (opens in a new tab) to view incoming events.

Implementing Group Analytics using Segment

There are 4 parts to implementing Group Analytics via Segment.

1. Define the Group Key in Mixpanel and Segment

Create the Group Key in Mixpanel Project Settings. 1groupkey_projectsettings

Create the Group Identifier Trait in Segment’s Mixpanel Destination Settings (opens in a new tab). 2segment_groupkey

Make sure the value placed in Segment’s “Group Identifier Trait” row matches Mixpanel’s “Group Key”.

2. Create Group Profiles

analytics.group() (opens in a new tab) will create Group Profile/Group Profile Properties in Mixpanel. Mixpanel uses the key specified in the second argument of the group method.

3groupcall (5)

Example Group Profile/Group Profile Properties created from the group method:

4groupprofile

3. Add Group Key as a User Profile Property

In order to use Group Profile Properties when analyzing User Profiles, the user profile must have the Group Key/Group ID Value as a profile property.

Declare the Group Key in the identify method as a profile property (trait): 5identify

4. Add Group Key as an Event Property to Events

In order to connect events to a Group, the event must have the Group Key/Group ID Value as an event property.

If you are using Segment Cloud Mode (opens in a new tab):

  • The Group Key must be explicitly declared as an event property on every event track call in order for the event to be compatible with Group Analytics.

6trackcall

If you are using Segment Device Mode (opens in a new tab) (legacy):

Debugging

For debugging purposes, it can be useful to see exactly what Segment is sending to Mixpanel. You can validate this data through the Segment Source Debugger (opens in a new tab). In the Segment Source Debugger, you can select the event you are looking to validate: yGK1yH7zGy_cv5hLBEHgdU9oMyALishD6S0kObRRJANGxbjIEL

Click the “Validate” button in the top right corner and choose “Mixpanel” as the destination. After the event has been sent, you can click to view the request from Segment to grab the data payload: pasted image 0 (1)

You can then copy the data payload and decode it in a base64 decoder (opens in a new tab) to see the JSON event that was sent to Mixpanel.

FAQ

Why are my Segment data not appearing in my project?

This could be due to several reasons:

  • Storing data in the EU: A common issue is that the data in Segment is enabled to be sent to an EU endpoint but the Mixpanel data is still being stored outside of the EU. Both endpoints for Segment and Mixpanel need to point to the EU as described here (opens in a new tab). If you have an existing Mixpanel project, you might need to have your data migrated to the EU. Please find further information here (opens in a new tab).

  • Cloud implementation vs. device implementation (opens in a new tab): Segment can be implemented via a cloud-based implementation or as an SDK on the device directly. Device implementation will send the data to Mixpanel directly while the cloud implementation will send it to Segment first. You can confirm your implementation by querying for the Mixpanel library property of the events in your project:

  • Cloud Mode will show as Mixpanel Library: Segment: analytics.js

  • Device Mode will show as Mixpanel Library: Segment: web

Why are there duplicated Segment events in my project?

Mixpanel SDKs assign an $insert_id (opens in a new tab) to each tracked event.

This allows Mixpanel to ensure no event is tracked more than once and events will be deduplicated based on the insert_id. Segment does not assign an insert_id to events. If the ingestion of an event is not confirmed by Mixpanel’s servers fast enough, Segment will retry to send the event.

This can lead to duplicate events in Mixpanel, they will likely have different insert_ids as Mixpanel assigns each event without an insert_id a unique new one. This behavior can be caused by sending huge batches of data at the same time and can be avoided by reducing the batch size and frequency of event sending from Segment to Mixpanel.

How do I register super properties using Segment?

Super properties can only be set when you are running in device mode. The super properties are automatically set with every property you pass into the analytics.identify() method. To have more control over the super properties you set, you can explicitly set super properties in your Segment settings (opens in a new tab).

How do I track page views using Segment?

Page calls are automatically tracked via Segment. These can be tracked from Segment to Mixpanel as Loaded a Page or Loaded a Screen. To turn them off, you need to configure this in your Segment settings (opens in a new tab).

Was this page useful?