Iterable's web push offering allows you to push blast and triggered notifications to subscribers using the Chrome, Firefox, or Opera browsers. Google's Firebase Cloud Messaging (FCM) service is used to deliver these messages. You can find more information about Firebase on their website.
A web push notification will resemble the following:
Table of contents
- Getting started
-
Frequently asked questions
- Does Firebase have any associated costs?
- 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
In order to leverage the web push service, you will first need to register for Google Firebase and then follow the steps below:
Create a project within the Firebase Console.
Within the console, navigate to Project Settings > Cloud Messaging and take note of your Server key and Sender ID:
Integrating Firebase into your website
In order 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 and firebase-messaging-sw.js, and place them in the root directory of your website.
The
gcm_sender_id 103953800507
found in the manifest.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. This snippet should serve two purposes:
It should 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. (read Handling Anonymous Users for more info).
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 API key, which has 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:
Also take a look at the documentation for the POST /api/webPush/target
API.
When creating a web push template, specify the following options:
- Template Name - The name of the template
- Notification Title - The text that should display at the top of the notification.
- Notification Body - The text that should display in the body of the notification.
- Icon - The image to display with the notification.
- Click Action - The URL to which the notification should navigate the user on click.
NOTES
- Title or body contents are required in order to save the template. This acts as a safeguard against sending blank messages.
- Your project name will display under the title and body in the preview. In proofs and the live sends, however, this will display your website name (for example, "iterable.com").
Frequently asked questions
Does Firebase have any associated costs?
No, Firebase is free (as of September 2017).
Where can I find more information on Firebase?
See Google's Firebase support page here.
Which browsers does web push work on?
Currently, 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.