With Iterable, you can send web push campaigns to Chrome, Firefox, and Opera web browers. Google's Firebase Cloud Messaging (FCM) delivers these messages.
In this article
- Getting started
-
Frequently asked questions
- Where can I find more information on Firebase?
- Which browsers does web push work on?
- Does a user's browser token change from session to session?
- If a user's browser window is closed, will they still receive the notification?
- Will messages be queued if they are unable to display initially?
- What metrics can I track with web push?
Getting started
This section describes how to set up web push notifications in Iterable.
Configuring Firebase
To use web push, register for Google Firebase and follow these steps:
From the Firebase Console, create a project.
In the console, navigate to Project Settings > Cloud Messaging and take note of your Server key and Sender ID:
d
Integrating Firebase into your website
To send messages from Firebase, you will need to first prompt users with a message asking for permission. If permission is given, you will retrieve the user's browser token and give it to Iterable to use for future sends.
To do this, follow these steps:
Add
<link rel="manifest" href="/manifest.json"/>
in the<head>
section of your webpage.-
Download
manifest.json
andfirebase-messaging-sw.js
, and place them in the root directory of your website.The
gcm_sender_id 103953800507
found in themanifest.json
file should be the same across all projects. Please do not edit or change this. -
Follow Google's Firebase documentation incorporate a JavaScript snippet into your webpage.
- Prompt the user with a pop-up asking for permission to send push notifications
- If permission is granted, it should fetch the user's browser token and then
pass it to Iterable using the
POST /api/users/registerBrowserToken
API endpoint. - A user profile field,
browserTokens
, will then reflect the browser token value for each user who accepts notifications. This is an array, which is capable of accepting multiple values over time. - If you're working in an email-based project
and the user's email address isn't available (for example, if the user
hasn't logged in), you can leverage our
placeholder.email
domain convention to pass Iterable a placeholder email address with the token. For more information, read Handling Anonymous Users.
NOTES
- Browser tokens are managed and sometimes disabled by Firebase using their own algorithm. If Firebase determines a token to be outdated, you may need to re-prompt users for web push permission. Users who have not enabled browser tokens on their profiles will be suppressed from web push send attempts.
- If you have collected users' browser tokens in the past, you can import them
into Iterable using the same
POST /api/users/registerBrowserToken
API endpoint. API endpoint as mentioned in step 3, above.
Configuring your website to capture click metrics
In order to capture web push clicks in Iterable, call Iterable's
POST /api/events/trackWebPushClick
API.
IMPORTANT
- To call this API, use a JavaScript or Web API Key, which have limited access to Iterable's API. If possible, we recommend using JWT authentication for additional security.
- Never embed server-side API keys in client-side code (whether JavaScript, a mobile application or otherwise), since they can be used to access all of your project's data.
Connecting Your Firebase Instance to Iterable
In order to send messages from Firebase via Iterable, follow these instructions:
In Iterable, navigate to the Settings > Web Push.
-
Click Create Push Integration to add a new integration.
NOTE
Iterable supports one web push integration per project.
Select FCM and enter your Firebase server key and sender ID (from step 2 of Configuring Firebase, above).
Creating Web Push Templates and Campaigns
To create a web push notification campaign, follow the same steps as for other campaign types: select the message format, send and suppression lists, and template. For more information, read Sending or Scheduling a Blast Campaign and Activating a Triggered Campaign.
Also take a look at the documentation for the POST /api/webPush/target
API.
When creating a web push template, specify:
- Message Type — The message type to associate with your campaign.
- Title - Title text for the notification.
- Body - Body text for the notification.
- Icon - The image to display with the notification.
- Click Location - Where a click on the notification should navigate the user.
Frequently asked questions
Where can I find more information on Firebase?
Check out https://firebase.google.com/support/.
Which browsers does web push work on?
Chrome, Firefox, and Opera.
Does a user's browser token change from session to session?
A Firebase algorithm decides when to invalidate a token, in which case the client side JavaScript needs to register the new token for the user in Iterable. Generally this is about once per month.
If a user's browser window is closed, will they still receive the notification?
Yes. Even if the user closes the browser window, the service worker running in the background will display the notification. However, if the user quits out of the browser completely (not just the window or tab), then all service workers will be killed and they will receive no notification.
Will messages be queued if they are unable to display initially?
No. Messages will not deliver if the browser process isn't running at send time.
What metrics can I track with web push?
We support both web push send and click events. In order to track web push click events, you must configure your website to capture click metrics. Please see above for more information on how to track web push click events.
Comments
0 comments
Please sign in to leave a comment.