Mixpanel

Purchasely can send all your transactional events to Mixpanel to enrich your users data.

🚧

Pre-requisites

The minimal version of the Purchasely SDK supporting this integration is v3.2.0. If the Purchasely SDK integrated in your app is under the minimal version, please update it.

The Mixpanel SDK also needs to be integrated inside the app.


General overview

Mixpanel is a leading product analytics software company, it is an event-based tracking solution gives product teams the ability to gain insights into how to best acquire, convert, and retain their users across web and mobile platforms.

This integration will allow you to get all the available Purchasely events to Mixpanel and get a better and deeper understanding of your subscription business and customer behavior.

Purchasely provides a unified dataset to track the subscription events for all stores. These events are generated by the Purchasely Backend and can be sent to Mixpanel.

Subscription events generated by Purchasely will be sent to Mixpanel using a server-to-server integration. As a result, you will be able to see all the subscription events in your Mixpanel Dashboard and map them with your acquisition campaigns.

Events

Below are the typical Server Events that can be leveraged to create no-code automations

EventDescription
SUBSCRIPTION_STARTEDCan be leveraged to trigger an automation to welcome new subscribers and make them discover the benefits of their premium membership or introduce them with specific premium features
RENEWAL_DISABLEDCan be leveraged to trigger an automation collecting feedback on the cancelation reasons or try to retain premium members before they effectively churn thanks to a retention offer
SUBSCRIPTION_TERMINATEDCan be leveraged to inform users that their premium membership has been effectively terminated
SUBSCRIPTION_RENEWEDCan be leveraged to create an automation thanking users for their loyalty
TRIAL_STARTED/ INTRO_OFFER_STARTEDCan be leveraged to trigger engagement and activation experiences and make premium members discover the benefits and advantages coming along with their subscription
TRIAL_CONVERTEDCan be leveraged to send a message to thank a premium member for their trust after they become a paying member
GRACE_PERIOD_STARTEDCan be leveraged to trigger an automation informing the end user of a billing issue with their premium membership and inviting them to update their credit card to avoid the suspension of their premium benefits

Integrating Purchasely with Mixpanel

The integration requires 2 steps:

  1. Associate the user to events by providing the Mixpanel Distinct ID to the Purchasely SDK
  2. Activate the Mixpanel integration in the Purchasely Console

1 - Associating users to events

See the Mixpanel Documentation for more information

Mixpanel.initialize(token: "MY_TOKEN")
Purchasely.setAttribute(.mixpanelDistinctId, value: Mixpanel.mainInstance().distinctId)
val mixpanel = MixpanelAPI.getInstance(applicationContext, "MY_TOKEN")
mixpanel.distinctId?.let {
  Purchasely.setAttribute(Attribute.MIXPANEL_DISTINCT_ID, it)
}
Purchasely.setAttribute(Attributes.MIXPANEL_DISTINCT_ID, (await mixpanel.getDistinctId(););
mixpanel.getDistinctId(function(distinctId) {
	Purchasely.setAttribute(Purchasely.Attribute.MIXPANEL_DISTINCT_ID, distinctId);
});

String? distinctId = await mixpanel?.getDistinctId();
Purchasely.setAttribute(PLYAttribute.mixpanel_distinct_id, distinctId);
private PurchaselyRuntime.Purchasely _purchasely;
...
_purchasely.SetAttribute(PLYAttribute.MIXPANEL_DISTINCT_ID, Mixpanel.DistinctId);

2 - Activating the Mixpanel integration

Setting up a new service account in the Mixpanel Dashboard

📘

Project Role

Because it relies on the Import Event endpoint of Mixpanel's Ingestion API , the Mixpanel integration requires a service account with the Owner or Admin Project Role to be able to forward subscription events to Mixpanel. We strongly recommend using Member Organization Role and the Admin Project role.

Retrieving your service account's project ID from the Mixpanel Dashboard

Enabling the Mixpanel integration in the Purchasely Console

  • Go in the "Integrations" section, and open the edition form for Mixpanel:

  • Enable the integration
  • Set your Mixpanel service account Project ID
  • Set your Mixpanel service account Username
  • Set your Mixpanel service account Secret


  • Enable the events you want to be sent to Mixpanel
  • (Optional) Override the names of the events that will be sent to Mixpanel


Testing your integration

To test your integration, you can perform a set of in-app purchases in a Sandbox environment (eg: TestFlight for the App Store) and verify your events are received in the Mixpanel dashboard https://mixpanel.com/login/