Mixpanel Cohort Sync
Sync your Mixpanel cohorts to Purchasely Custom Audiences with a Mixpanel webhook.
Pre-requisitesThis integration requires the Custom Audiences feature on your Purchasely account. Without this feature, the webhook answers
403. To enable the feature, contact us.The Mixpanel SDK and the Purchasely SDK must identify users with the same user ID.
General overview
Mixpanel Cohort Sync sends the members of a Mixpanel cohort to a webhook. Purchasely receives these calls and keeps a Custom Audience in sync with the cohort.
Purchasely creates one Custom Audience for each synced cohort. You can then use this Custom Audience in Placements, Campaigns, Flows and A/B tests.
Integrating Mixpanel Cohort Sync with Purchasely
1 - Identifying users with the same user ID
Purchasely matches each cohort member with a Purchasely user through the user ID.
Send the same user ID to mixpanel.identify() and to Purchasely.userLogin().
let userId = "user_123"
Mixpanel.mainInstance().identify(distinctId: userId)
Purchasely.userLogin(with: userId)
Anonymous usersPurchasely does not sync anonymous users. A cohort member without a user ID does not go to the Custom Audience.
2 - Getting the webhook URL and the API key
The webhook URL of your app is:
https://api.purchasely.io/client/mobile_applications/<app_public_id>/custom_audiences/webhook/mixpanel
The Purchasely Console shows this URL in Settings > API keys.
The webhook uses Basic authentication:
| Field | Value |
|---|---|
| Username | Any value. Purchasely does not read it. |
| Password | A Client API key of the app. |
3 - Adding the webhook destination in Mixpanel
- In Mixpanel, go to Data > Destinations.
- Click Add Destination, select Webhook, then click Connect.
- Paste the webhook URL of step 2.
- Enable Basic authentication. Type any username, and use your Client API key as the password.
- Save the destination.
4 - Syncing a cohort
- Open the Webhook destination, then open the Syncs tab.
- Click Add Cohort Sync and select the cohort.
- Select a recurring sync.
Add one recurring sync for each cohort. Each cohort gives one Custom Audience in Purchasely.
Sync from LexiconYou can also start a sync from Lexicon > Cohorts. Open the menu of the cohort, then select Export to... > Webhook.
Data freshness
Mixpanel syncs a cohort every 30 minutes. Purchasely caches audience membership for 15 minutes.
A change in a cohort can therefore take about 45 minutes to reach your users in the worst case. Processing time in Purchasely adds to this delay.
Limits
| Limit | Value |
|---|---|
| Recurring syncs per Mixpanel project | 60, for all destinations |
| Users per cohort | 10 million |
| Group cohorts (Group Analytics) | Not supported |
| Anonymous users | Not synced |
These limits come from Mixpanel, except for anonymous users. For more information, see the Mixpanel Cohort Sync documentation.
Troubleshooting
The webhook answers 403
The Custom Audiences feature is not enabled on your account. Contact us to enable it.
The Custom Audience was archived
When you archive the Custom Audience of a cohort, the sync stops. To restore the sync:
- Create a Custom Audience again with the same
vendor_idas the archived audience. - In Mixpanel, disconnect the webhook sync of the cohort.
- Connect the webhook sync of the cohort again.
Mixpanel then sends the full cohort again.
Updated about 13 hours ago

