Adding the JavaScript snippet to your page
Standard setup
The snippet below allows you to:
Respect best practices regarding collect on Mozilla Firefox and Chromium based browsers,
Personalize custom alert message and buttons
To get a personalized tag, including your own setup information (as API keys or safari set-up object), click on the Get the code button (⚙️ Settings → Push settings → Website Push configuration).

Custom alert setup details
Using the snippet above, the custom alert will only be displayed on Mozilla Firefox and Safari on MacOS. The native opt-in request will be displayed on other browsers.

See more customization options here.
Where to implement the JavaScript snippet?
Optimize performance
The tag should be implemented at the end of the body, so it doesn't block any other script.
Note that browsers directly manage the download and installation of the service worker asynchronously so it doesn't affect performance.
Trigger the subscription request at the right moment
In most cases, the JavaScript tag should be implemented on every page of your website that belong to the same domain. It allows users to be exposed to the opt-in request regardless of the origin of the traffic (organic, newsletter...). Alternatively, you can also choose to scenarize the opt-in request, after users perform a specific action.
Domains and subdomains management
Usually, the JavaScript tag should only deployed on your main domain (no other domain or subdomain) to eliminate risks of duplicate notifications.
If you want to integrate Batch on several domains or subdomains, check the dedicated section of the documentation Domains and subdomains management.
Alternative integrations
Last updated
Was this helpful?