Purchasely
4
Search
K

Mixpanel

Why combine Mixpanel and Purchasely?

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.

Subscription events

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

The following events are the main ones that can be sent to Mixpanel by Purchasely. See the full list here.
Event
Description
SUBSCRIPTION_STARTED
Sent when the user purchased a product wether it is the start of a trial or a regular purchase of a consumable product.
SUBSCRIPTION_RENEWED
Sent when a subscription renews
SUBSCRIPTION_EXPIRED
Sent when the subscription actually ends
SUBSCRIPTION_REACTIVATED
Sent when an expired subscription is reactivated. This event is particularly useful for win-back & retargeting campaigns
SUBSCRIPTION_REFUNDED_REVOKED
Sent when the subscription actually ends
RENEWAL_DISABLED
Sent when the user deactivates the renewal of a subscription wether it is in trial period or not.
RENEWAL_ENABLED
Sent when the user reactivates
TRIAL_STARTED
Sent when a trial starts
TRIAL_CONVERTED
Sent when a user converts from a free trial to a normal paid-period
TRIAL_NOT_CONVERTED
Sent when a user finishes it's trial period without renewing to a paid-period
The names of events sent to Mixpanel can be overriden when setting up the integration.

Integrating Purchasely with Mixpanel

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

1. Associating users to events

See the Mixpanel Documentation for more information
Swift
Kotlin
Java
React Native
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)
}
MixpanelAPI mixpanel = MixpanelAPI.getInstance(getApplicationContext(), "MY_TOKEN");
if(mixpanel.getDistinctId() != null) {
Purchasely.setAttribute(Attribute.MIXPANEL_DISTINCT_ID, mixpanel.getDistinctId());
}
import { Mixpanel } from 'mixpanel-react-native';
const mixpanel = new Mixpanel("Your Project Token");
mixpanel.init();
Purchasely.setAttribute(Attributes.MIXPANEL_DISTINCT_ID, (await mixpanel.getDistinctId(););

2. Activating the Mixpanel integration

The activation requires 2 steps:
  1. 1.
    Setting up a new service account in the Mixpanel Dashboard
  2. 2.
    Retrieving your service account's project ID from the Mixpanel Dashboard
  3. 3.
    Enabling the Mixpanel integration in the Purchasely Console

a. Setting up a new service account in the Mixpanel Dashboard

  1. 2.
    Write down your service account
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.

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

c. Enabling the Mixpanel integration in the Purchasely Console

  1. 1.
    Go in the "External integrations" section, and open the edition form for Mixpanel:
2. Enable the integration
3. Set your Mixpanel service account Project ID
4. Set your Mixpanel service account Username
5. Set your Mixpanel service account Secret
6. Enable the events you want to be sent to Mixpanel
7. (Optional) Override the names of the events that will be sent to Mixpanel
8. Save

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/.
© Purchasely 2020-2023