Prompt
How do I track push notification opens and clicks?
Latest observation
To track push notification opens and clicks, you usually need to record two things:
- Delivery / receipt — the notification was successfully sent to the device
- Engagement — the user opened or clicked/tapped the notification
The exact implementation depends on your platform, but the general approach is the same.
1) Track the click/open event in the app
When a user taps a push notification, your app gets launched or brought to the foreground with payload data from the notification. In your notification handling code, log an analytics event such as:
push_notification_openedpush_notification_clicked
Include useful metadata:
- notification ID
- campaign name
- title/body
- deeplink / destination
- user ID (if available)
- timestamp
- device/platform
2) Distinguish between “delivered,” “opened,” and “clicked”
Common definitions:
- Delivered: push was accepted by APNs/FCM
- Opened: app was opened because the notification was tapped
- Clicked: often the same as opened for push notifications, especially on mobile
- Dismissed: user swiped it away or ignored it
If your system supports action buttons, track each button click separately.
3) Use analytics or push platform events
Many push providers already support engagement tracking:
- Firebase Cloud Messaging + Google Analytics / BigQuery
- OneSignal
- Braze
- Mixpanel / Amplitude integrations
- CleverTap / Airship
These tools can automatically record opens/clicks if integrated properly.
4) Implement platform-specific handlers
iOS
Handle notification response in:
UNUserNotificationCenterDelegateuserNotificationCenter(_:didReceive:withCompletionHandler:)
Log the event there.
Android
Handle the intent when the notification is tapped:
PendingIntentonNewIntent()- notification click intent extras
Log the event in the activity or receiver that receives the tap.
5) Add campaign/deep-link identifiers
To measure opens/clicks accurately, attach a unique identifier to each notification:
notification_idcampaign_idmessage_id
Then send that ID to analytics when the user taps.
6) Avoid double-counting
Notification opens can be triggered more than once if:
- the app is resumed multiple times
- the intent is handled twice
- the user taps from notification history
Use deduplication logic with a notification ID and timestamp.
Example event flow
- Backend sends push with
notification_id=abc123 - User taps notification
- App receives tap event
- App logs:
push_notification_openednotification_id=abc123campaign_id=summer_sale
- Analytics dashboard shows open rate = opens / delivered
If you want, I can show you:
- iOS code
- Android code
- Firebase Cloud Messaging example
- OneSignal/Braze example
- or a general backend + analytics schema for tracking pushes