Tracking Push Notification Open Rates

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];

Legacy Users

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

The $app_open and $campaign_received events are being deprecated in favor of the more accurate and reliable $push_notification_received, $push_notification_tap, and $push_notification_dismissed events. The following events are captured when a push notification is opened for all current Android and iOS SDK versions

  • $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 events 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. The $campaign_received event is triggered on Android when a push notification is received and the app is in the foreground. The $campaign_received event is triggered on iOS when the user taps the notification and automatics events are enabled. 

The following events are captured when a push notification is opened for Android v5.7.0+, Obj-C v3.6.0+, and Swift v2.7.0+

  • $push_notification_received (Push Notification Received): This event is triggered when a user's device receives a push notification sent from Mixpanel. This event is triggered regardless of whether the app is in the foreground or background. 

Note

Note: Install the NotificationServiceExtension to track the $push_notification_received event in iOS for Swift and Objective-C.

  • $push_notification_tap (Push Notification Tapped): This event is triggered when a user taps on a push notification or action buttons within a push notification sent from Mixpanel.
  • $push_notification_dismissed (Push Notification Dismissed): This event is triggered when a user dismisses a push notification sent from Mixpanel.
Did this answer your question?

Comments

0 comments

Article is closed for comments.