Mixpanel
This guide describes how to add and configure the Mixpanel integration.
Mixpanel is a powerful mobile analytics service. Send events to Mixpanel via Apphud, analyze your users' behavior and make necessary decisions.
How to Add Integration?
Important Note
Please make sure that Mixpanel Collection common mobile events are Disabled. See here for details.
Step 1
- Integrate Apphud SDK.
- Integrate Mixpanel SDK.
- Match User IDs between Mixpanel and Apphud.
- Enable Service credentials for importing historical events (optional).
Step 2
In order not to receive Mixpanel automatic In-App purchase events disable collection common mobile events. Otherwise, if a user, for example, starts a trial period Mixpanel will consider this as revenue. More details here.
Step 3
At Apphud go to "Integrations" section and add Mixpanel:
Step 4
Paste Mixpanel Token into the "Mixpanel production app token" field. The token is the same as you use in your app.
Step 5
You may have one more app created in Mixpanel used for testing purposes not to mix test and live data. If you have such an app you can paste its Mixpanel Token into "Mixpanel test app token" field.
Step 6
You can enter your custom event names or disable some:
Step 7
Enable integration:
Step 8
If you want to send Revenue information to Mixpanel, check "Send Revenue properties to Mixpanel". Click "Save":
Match User IDs
Here is an example of initialising both SDKs with User IDs matching.
Swift
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
Apphud.start(apiKey: "YOUR_API_KEY")
Apphud.setDelegate(self)
Mixpanel.initialize(token: mixpanel_token)
Mixpanel.mainInstance().identify(distinctId: Apphud.userID())
return true
}
func apphudDidChangeUserID(_ userID: String) {
// Match again
Mixpanel.mainInstance().identify(distinctId: Apphud.userID())
}
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
// Override point for customization after application launch.
[Apphud startWithApiKey:@"APPHUD_API_KEY" userID:nil];
[Apphud setDelegate:self];
[Mixpanel sharedInstanceWithToken:@"MIXPANEL_TOKEN"];
[Mixpanel.sharedInstance identify:Apphud.userID];
return YES;
}
- (void)apphudDidChangeUserID:(NSString *)userID {
[Mixpanel.sharedInstance identify:Apphud.userID];
}
Apphud.start(apiKey: "YOUR_API_KEY")
let mixpanel = MixpanelAPI.getInstance(context, MIXPANEL_TOKEN)
mixpanel.identify(Apphud.userID())
Apphud.start(apiKey: "YOUR_API_KEY");
MixpanelAPI mixpanel = MixpanelAPI.getInstance(context, MIXPANEL_TOKEN);
mixpanel.identify(Apphud.userID());
Future<void> _initMixpanel() async {
final userId = await Apphud.userID();
_mixpanel = await Mixpanel.init(
'insert_your_token_key_here',
trackAutomaticEvents: false,
);
await _mixpanel?.identify(userId);
}
// implement Apphud Listener methods
@override
Future<void> apphudDidChangeUserID(String userId) async {
printAsJson('ApphudListener.apphudDidChangeUserID', userId);
await _mixpanel?.identify(userId);
}
Importing Historical Events
You can specify service credentials for importing historical events (for example, renewals that occurred before Apphud SDK integration).
You will need to provide Project ID and Service Account credentials. See here for details.
Events Cheat Sheet
This is a list of all possible events and their parameters that are being sent to Mixpanel.
Note
You can read more about subscription events here and parameters here.
Trial
Trial period started
Default event name: [Apphud] trial_started
Parameters:
product_id
: Stringunit
: Stringunits_count
: Integer
Successful conversion from trial period to regular subscription
Default event name: [Apphud] trial_converted
Parameters:
product_id
: Stringlocal_price
: Floatcurrency
: Stringusd_price
: Float
Failed conversion from trial period to regular subscription
Default event name: [Apphud] trial_expired
Parameters:
product_id
: Stringreason
: String
Cancellations
Trial Canceled
Default event name: [Apphud] trial_canceled
Parameters:
product_id
: String
Subscription Canceled
Default event name: [Apphud] subscription_canceled
Parameters:
product_id
: String
Autorenew disabled (Deprecated)
Default event name: [Apphud] autorenew_disabled
Parameters:
product_id
: String
Autorenew enabled
Default event name: [Apphud] autorenew_enabled
Parameters:
product_id
: String
Introductory Offer
Introductory offer started
Default event name: [Apphud] intro_started
Parameters:
product_id
: Stringlocal_price
: Floatcurrency
: Stringusd_price
: Floatoffer_type
: Stringunit
: Stringunits_count
: Integer
Introductory offer renewed
Default event name: [Apphud] intro_renewed
Parameters:
product_id
: Stringlocal_price
: Floatcurrency
: Stringusd_price
: Floatoffer_type
: Stringunit
: Stringunits_count
: Integer
Successful conversion from introductory offer to a regular subscription
Default event name: [Apphud] intro_converted
Parameters:
product_id
: Stringlocal_price
: Floatcurrency
: Stringusd_price
: Floatoffer_type
: String
Failed conversion from introductory offer to regular subscription or failed to renew
Default event name: [Apphud] intro_expired
Parameters:
product_id
: Stringreason
: Stringoffer_type
: String
Refund during the introductory offer
Default event name: [Apphud] intro_refunded
Parameters:
product_id
: Stringlocal_price
: Floatcurrency
: Stringusd_price
: Floatreason
: Stringoffer_type
: String
Regular
Subscription started
Default event name: [Apphud] subscription_started
Parameters:
product_id
: Stringlocal_price
: Floatcurrency
: Stringusd_price
: Float
Subscription renewed
Default event name: [Apphud] subscription_renewed
Parameters:
product_id
: Stringlocal_price
: Floatcurrency
: Stringusd_price
: Float
Subscription expired
Default event name: [Apphud] subscription_expired
Parameters:
product_id
: Stringreason
: String
Subscription refunded
Default event name: [Apphud] subscription_refunded
Parameters:
product_id
: Stringlocal_price
: Floatcurrency
: Stringusd_price
: Floatreason
: String
Promo Offer
Promotional offer started
Default event name: [Apphud] promo_started
Parameters:
product_id
: Stringoffer_id
: Stringlocal_price
: Floatcurrency
: Stringusd_price
: Floatoffer_type
: Stringunit
: Stringunits_count
: Integer
Promotional offer renewed
Default event name: [Apphud] promo_renewed
Parameters:
product_id
: Stringoffer_id
: Stringlocal_price
: Floatcurrency
: Stringusd_price
: Floatoffer_type
: Stringunit
: Stringunits_count
: Integer
Successful conversion from promotional offer to a regular subscription
Default event name: [Apphud] promo_converted
Parameters:
product_id
: Stringoffer_id
: Stringlocal_price
: Floatcurrency
: Stringusd_price
: Floatoffer_type
: String
Failed conversion from promotional offer to regular subscription or failed to renew
Default event name: [Apphud] promo_expired
Parameters:
product_id
: Stringoffer_id
: Stringreason
: Stringoffer_type
: String
Refund during the promotional offer
Default event name: [Apphud] promo_refunded
Parameters:
product_id
: Stringoffer_id
: Stringlocal_price
: Floatcurrency
: Stringusd_price
: Floatreason
: Stringoffer_type
: String
Other Events
Non-renewing purchase
Default event name: [Apphud] non_renewing_purchase
Parameters:
product_id
: Stringlocal_price
: Floatcurrency
: Stringusd_price
: Float
Non-renewing purchase refunded
Default event name: [Apphud] non_renewing_refunded
Parameters:
product_id
: Stringlocal_price
: Floatcurrency
: Stringusd_price
: Floatreason
: String
Billing issue
Default event name: [Apphud] billing_issue
Parameters:
product_id
: String
Billing issue Resolved
Default event name: [Apphud] billing_issue_resolved
Parameters:
product_id
: String
These events:
[Apphud] trial_converted
,[Apphud] intro_started
,[Apphud] intro_renewed
,[Apphud] intro_converted
,[Apphud] intro_refunded
,[Apphud] subscription_started
[Apphud] subscription_renewed
,[Apphud] subscription_refunded
,[Apphud] promo_started
,[Apphud] promo_renewed
,[Apphud] promo_converted
,[Apphud] promo_refunded
,
can be optionally sent to Mixpanel with Mixpanel's build-in Revenue parameter converted to USD. This option is off by default, but you can enable this feature in integration settings:
You can also choose between sending revenue as sales or proceeds (without Apple's 15%-30% commission).
Note
You can read more about how Apple calculates commission here.
In the table below you can see the list of user properties that are sent to Mixpanel.
Note
More information about user properties can be found here.
Parameter | Type |
---|---|
[Apphud] status-group_name | String |
[Apphud] autorenew-group_name | Boolean |
[Apphud] total_spent | Float |
[Apphud] paying | Boolean |
[Apphud] payments_count | Integer |
You may send test event to Mixpanel to check if integration is set up correctly.
- Click "…" and then in dropdown click on "Send test event".
- You will see new user in "Live view" report:
Updated 3 months ago