Track notification events
Sendbird Business Messaging offers comprehensive event tracking capabilities for all channels. The purpose of this feature is to provide insights into how users interact with notifications and messages. By tracking events such as viewed
, clicked
, and delivered
, you can analyze user behavior and optimize your messaging strategy.
Event tracking are essential for some of Business Messaging's features, such as:
- Sequence: Send a message through various channels based on the event.
- User insights: Monitor message's status through the events per user.
- Analytics: Analyze the channel like Click rates, opened rates, etc.
Events
You can track the following events for each channel:
-
sent
: When a message is sent to the channel. -
delivered
: When a message is delivered to the user. For a push notification, call theSendbirdPushHelper.markPushNotificationAsDelivered
method to track this event. For a WhatsApp channel, thedelivered
event is automatically handled by Sendbird. -
viewed
: When a user views the message in the channel. If a message is not rendered in the current screen, theviewed
event won't be called. For an in-app message, theviewed
event is automatically handled by the UIKit. -
clicked
: When a user clicks a button on the message. For an in-app message, theclicked
event is automatically handled by the UIKit. For a push notification, call theSendbirdPushHelper.markPushNotificationAsClicked
method to track this event.
Events
Channels | Sent | Delivered | Viewed | Clicked |
---|---|---|---|---|
In-app | N/A | N/A | ||
Push notification | N/A | N/A | ||
N/A | N/A | N/A | ||
Kakao Alim Talk | N/A | N/A |
Push notifications
For the Business Messaging to accurately track push notification events, push notifications must be correctly set up in your mobile application. Sendbird provides detailed guides for configuring push notifications on both Android and iOS.
Set up environment for Android
To integrate push notifications with Sendbird on Android, follow the guide for setting up push notifications for Firebase Cloud Messaging (FCM). This setup includes creating a Firebase project, configuring your app with Firebase, adding Firebase configuration files to your project, and integrating FCM with the Sendbird SDK.
For a step-by-step guide, visit the Sendbird documentation: Push notifications for UIKit.
This guide will walk you through the steps to ensure your Android application can receive and process push notifications, pivotal for tracking delivered and clicked events within your app.
Track delivered
If you've implemented SendbirdPushHelper
and registered message events in SendbirdPushHandler
during the push notification setup, a delivered
event is automatically tracked when a user receives a push notification.
Track clicked
Similar to in-app messages, tracking when a push notification is clicked provides insights into how users interact with notifications and which messages prompt action. Call the methods below when a push notification banner is clicked.
The following two code snippets demonstrate the implementation for event tracking.
-
Call the
markPushNotificationAsClicked
function in theonNewIntent
function of the activity with deduplication logic.
Ship the data to the pending intent of the notification
Call the markPushNotificationAsClicked method
You can call the markPushNotificationAsClicked
method in the onNewIntent
method of the activity with deduplication logic.
Set up environment for iOS
For iOS, setting up push notifications involves registering your app with the Apple Push Notification service (APNs), configuring your app's notification settings, and integrating these settings with the Sendbird SDK. This process ensures your iOS app is prepared to handle push notifications, allowing for effective tracking within the Business Messaging feature.
Detailed instructions can be found in the Sendbird documentation: Push notifications for UIKit.
This comprehensive guide provides the steps to configure your iOS application to receive push notifications from APNs and how to communicate these notifications to the Sendbird servers for tracking purposes.
Track delivered
To mark a push notification as delivered when received, follow the instructions below:
-
Be sure to set the app group in
AppDelegate
when initializing the SendbirdChat SDK. -
Implement the necessary method in the
NotificationServiceExtension
.
Note: Sendbird SDK marks a push notification as
delivered
when receiving it fromAppDelegate
regardless of whether the client app is in the foreground or background. This ensures that the notification is delivered even if a user does't see the push banner. If your client app can receive a push notification in the foreground but doesn't want to display it, add a condition calledmarkPushNotificationAsDelivered
method so that it does not deliver in the foreground.
Track clicked
Similar to in-app messages, tracking when a push notification is clicked provides insights into how users interact with notifications and which messages prompt action. Implement the userNotificationCenter (_:didReceive:withCompletionHandler:)
method in AppDelegate
. This is called when a user clicks on a push notification.