Segment Integration

 

Note: Mixpanel has a bi-directional integration with Segment. This document is about syncing cohorts from Mixpanel as user traits in Segment. To send events from Segment to Mixpanel, please refer to Segment's documentation.

 

Permissions

You must be a Mixpanel project admin to enable the Segment integration.

 

Setting Up the Integration

The connection requires a Segment Write Key. You can obtain this key via Segment's UI: 

  • Login into your Segment workspace and click Sources under Connections in the menu bar on the left.
  • Click Add Source button the right side above the sources table.
  • Select Go server and name your source Mixpanel CohortsScreen_Shot_2021-10-22_at_12.37.23_PM.png
  • Copy the Write Key displayed there.              Screen_Shot_2021-10-22_at_12.37.45_PM.png

 

In Mixpanel, select Integrations under the Data Management tab in the top navigation bar:

Integrations_-_Mixpanel___Product_Analytics.png

Then select Segment, click Connect, and paste the Write Key that you generated in Segment.

Screen_Shot_2021-10-22_at_12.26.20_PM.png

 

You've now successfully created the integration!

 

Export a Cohort

You can export a cohort to Segment from the Cohorts page.

Select the overflow menu on cohort that you want to export and click Export to... → Segment.

Screen_Shot_2021-10-22_at_12.44.21_PM.png

 

Sync Types

There are two types of sync: one-time and dynamic.

 

One-Time

In this sync, Mixpanel sends Segment the static set of users who currently qualify for the cohort. The cohort data will not be updated in Segment after a one-time export.

 

Dynamic

In dynamic sync, Mixpanel initiates sync between a cohort and Segment every 15 minutes. The exported cohort will be updated every 15 minutes to reflect the most recent list of users in a cohort.

 

When you generate a one-time export or dynamic sync, it overwrites the previous export with an updated export that reflects users who qualify for the cohort at the time of export.

 

Verifying in Segment 

Once the export completes, you can open the debugger on the source you created in Segment above 

you will see identify calls flowing in for each user that has been added or removed from the cohort.

 

Screen_Shot_2021-10-22_at_12.50.51_PM.png

 

Mixpanel sets a property on the user's profile in Segment indicating whether they are currently part of the cohort.

 

We send the following identify call to Segment when a user enters the cohort:

{
"type": "identify",
"traits": {
"Mixpanel - <Cohort Name in Mixpanel>": true,
}
"userId": "user@email.com" // we use the distinct_id property here
}

 

We send the following when a user exits the cohort:

{
"type": "identify",
"traits": {
"Mixpanel - <Cohort Name in Mixpanel>": false,
}
"userId": "user@email.com" // we use the distinct_id property here
}

 

 

 

Did this answer your question?

Comments

0 comments

Please sign in to leave a comment.