Capture Push Metrics
UpdatedThere's a new version available!
These pages cover version 2 of our SDK, but a newer version is available. In general, we suggest that you update to the latest version to take advantage of new features and fixes.
- Are you new to our SDKs? Check out the latest docs.
- Otherwise, learn about updating to the latest version
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.
Update to version 3 for Javascript functions
The React Native SDK version 3.0 introduced support for tracking push metrics using Javascript methods, eliminating the need for adding any native code. It’s recommended you update to the latest version to take advantage of this feature.
If you already configured push notifications and your app does not use other push notification modules such as expo-notifications
or react-native-push-notification
, the SDK automatically tracks opened
and delivered
events for push notifications originating from Customer.io.
Otherwise, use one of the following methods to manually track push metrics:
iOS: Record push metrics with native code
If you’re using Objective-C, the example in our push setup process already contains the code required to handle push metrics—substituting AppDelegate
for your push notification class. If you use Swift, add the following code to track push notifications in your app.
extension AppDelegate: UNUserNotificationCenterDelegate {
func userNotificationCenter(
_ center: UNUserNotificationCenter,
didReceive response: UNNotificationResponse,
withCompletionHandler completionHandler: @escaping () -> Void
) {
let handled = MessagingPush.shared.userNotificationCenter(center, didReceive: response,
withCompletionHandler: completionHandler)
// If the Customer.io SDK does not handle the push, you need to handle it and call the
// completion handler. If the SDK handles it, it calls the completion handler for you.
if !handled {
completionHandler()
}
}
}
If delivered
events are important to you, we recommend that you follow the setup instructions for rich push notifications, even if you do not plan on sending rich push notifications as rich push tracks delivered
events more reliably.
Disabling automatic push tracking
Automatic push metric recording is enabled by default when you install the SDK. You can disable this behavior by passing a configuration option when you initialize the SDK. You cannot disable automatic push tracking (or change other configuration settings) after you initialize the SDK.
const cioConfigOptions = new CustomerioConfig()
cioConfigOptions.autoTrackPushEvents = false
const env = new CustomerIOEnv()
env.siteId = Env.siteId
env.apiKey = Env.apiKey
CustomerIO.initialize(env, cioConfigOptions)