Web push
This topic describes web push initialization in Optimizely Data Platform (ODP).
Web push availability
Only customers onboarded prior to July 15, 2022 have access to the Campaigns and Web push functionality. For more information, contact your customer success manager.
Advanced initialization
If you want to create your own web push subscribe experience, ODP supports custom initialization options.
To manually handle Web Push initialization (instead of automatically initializing) go to step 5 of Web Push wizard within ODP: Account Settings > Integrations > Web Push. For more information about setting up Web Push in the ODP application, see Create web push notifications and Enable web push notifications.
Note
Integration of web push will not be marked as "live" but should be configured.
Display subscription modal on a specific page
In JavaScript on your website, AFTER ODP is initialized, perform any JavaScript logic and call this when you are ready to show the subscription UI:
{
"codes": [{
"code": "zaius.dispatch('webPush', 'initialize', {websiteID: ''})",
"language": "javascript",
"name": "Show Subscribe"
}]
}
Important
websiteID
is the name given in the web push subscribe setup, NOT your tracker_id.
Custom Initialization
In JavaScript on website, AFTER ODP is initialized, perform any JavaScript logic and call this when you are ready to show the subscription UI:
zaius.dispatch('webPush', 'initialize',
{websiteID: '<ZAIUS_WEBSITE_ID>',
subscribeUI: {enabled: false}}
);
//Then, check the subscription status before showing your subscription UI:
zaius.dispatch('webPush', 'subscriptionStatus', function(status, token) {
if (status !== 'subscribed' && status !== 'denied') {
// show subscribe UI
}
});
//Finally, when you want the browser to ask the user to allow push notifications call:
zaius.dispatch('webPush', 'askToSubscribe');
Updated 12 months ago