Capture Push Metrics

How it works

Customer.io supports device-side metrics that help you determine the efficacy of your push notifications: delivered when a push notification is received by the app and opened when a push notification is clicked.

Beginning in customerio-reactnative version 3.4.0, the SDK will automatically track opened and delivered events for push notifications originating from Customer.io after you configure your app to receive push notifications.

Follow the instructions below if you have a different use case and need to track push metrics manually.

Manually record push metrics using Javascript methods

 Avoid duplicate push metrics

If you manually track your own metrics, you should disable automatic push tracking to avoid duplicate push metrics.

 Known issue tracking opened push metrics in app killed state

When manually tracking push metrics using Javascript methods, opened push metrics are not tracked when the app is in killed or closed state. This is a known behavior and it’s recommended to instead use the automatic push tracking feature.

🎉Updated in version 3.1.0

To monitor the delivered push metrics of a received push notification, use the CustomerIO.pushMessaging().trackNotificationReceived(<CUSTOMER.IO_PAYLOAD>) method.

CustomerIO.pushMessaging().trackNotificationReceived(<CUSTOMER.IO_PAYLOAD>)

To track opened push metrics, use the CustomerIO.pushMessaging().trackNotificationResponseReceived(<CUSTOMER.IO_PAYLOAD>) method.

CustomerIO.pushMessaging().trackNotificationResponseReceived(<CUSTOMER.IO_PAYLOAD>)

The method that you use to retrieve the <CUSTOMER.IO_PAYLOAD> value depends on API of the SDK that you are using to receive push notifications from. Here is a code snippet as an example from expo-notifications:

   // Listener called when a push notification is received
   Notifications.addNotificationReceivedListener(notification => {
      ...
      // Fetch Customer.io payload from the push notification
      const payload = notification.request.trigger.payload
      CustomerIO.pushMessaging().trackNotificationReceived(payload)
      ...
    });

   // Receives response when user interacts with the push notification
   Notifications.addNotificationResponseReceivedListener(response => {
      ...
      // Fetch Customer.io payload from the push notification response
      const payload = response.notification.request.trigger.payload
      CustomerIO.pushMessaging().trackNotificationResponseReceived(payload)
      ...
   });

Disabling automatic push tracking

After you set up push notifications, update AppDelegate.mm to disable automatic push notification tracking:

  @objc(setupCustomerIOClickHandling)
  public func setupCustomerIOClickHandling() {    
    CustomerIO.initialize(siteId: siteId, apiKey: apiKey, region: Region.US) { config in
      config.autoTrackPushEvents = false 
    }
  }
Copied to clipboard!
  Contents
Current release
 3.5.1
Is this page helpful?