How do I track push notification open rate?

One issue of interest when sending push notification on iOS or Android is tracking the open rate of a push notification sent. A push notification is considered to be "opened" if a user clicks the push notification to open the app or (optionally) 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 also 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];

Legacy

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 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 are Push Opens tracked in my project?

If push tracking is enabled in your app, one of two events will be captured when a push notification is opened:

  • $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 allows us 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. Read more about tracking app open events.
  • $campaign_received: This event is triggered when a user is in the app and the push notification is displayed.