You can track push notification open rates on iOS or Android with Mixpanel. A push notification is considered to be "opened" if a user clicks the push notification to open the app, or if a user views a push while in the application.
Enabling push tracking in iOS
Push open tracking in iOS is automatically captured in v3.1.9 of the Objective-C SDK, meaning any SDK below this will require an upgrade.
Push open tracking is automatically available in v2.1.9 in Swift.
To track push open rates from a notification that's opened while the app is suspended, you must pass launchOptions from your didFinishLaunchingWithOptions into your initialization of your Mixpanel instance:
[Mixpanel sharedInstanceWithToken:MIXPANEL_TOKEN launchOptions:launchOptions];
If you're using an older version of the Mixpanel SDKs, you can enable push open tracking following the details below.
If you wish to also track open rates while the app is suspended, you will need to pass your launch options to the initialization of the Mixpanel instance per the details above.
The "$campaign_received" (Message Received) event can be used to track pushes that are displayed when the app is already open.
To enable this event, add the following to the AppDelegate's didReceiveRemoteNotification:
[[Mixpanel sharedInstance] trackPushNotification:userInfo];
By changing the initialization options and adding the above tracking calls, you can track the “open rate” of all pushes in iOS.
Enabling push tracking in Android
Push open tracking in Android was first introduced in Mixpanel v4.9.5, meaning any SDK below this will require an upgrade. Tracking requires your app to use Ice Cream Sandwich or above (API 14+).
How Push Opens Are Tracked in a Project
If push tracking is enabled in your app, one of two events are captured when a push notification is opened:
- $app_open (App Open): An $app_open event with campaign and message id properties is triggered if the user opens the application from a push notification. This action allows Mixpanel to track the open rate of the app due to push notifications.
By default, the $app_open event does not automatically trigger on every app open, though you can certainly add custom code to ensure this behavior. For information about tracing app open events, see Mobile: Track App Open And App Close.
- $campaign_received (Message Received): This event is triggered when a user is in the app and the push notification is displayed.