AMP Web Push Integration Prerequisites
- Ensure that AMP analytics is integrated before integrating AMP Web Push.
- Ensure that AMP analytics is integrated before integrating AMP Web Push.
- MoEngage AMP Web Push Integration does not, by default, track the MoEngage default user attributes and events.
AMP Web Push
Web Push Notification does not work by using the MoEngage Web SDK and serviceworker.js.Google has recently published a separate plugin to support the integration that enables News Publishers, Bloggers, or anyone who uses AMP to deliver their webpages quickly by encouraging users to subscribe using Push Notification.
Only Android devices are supported.
Add AMP Web Push script
Add this line in the<head> section of your .amp file where you want to use Web Push.
Add Helper files
Download the files corresponding to the dashboard you are using and ensure the files are available in the root directory of your website. Right-click and click Save Link as… to save the files:| Dashboard host | Files |
|---|---|
| dashboard-01.moengage.com | 1. amp-helper-frame.html 2. amp-permission-dialog.html 3. serviceworker_amp.js |
| dashboard-02.moengage.com | 1. amp-helper-frame.html 2. amp-permission-dialog.html 3. serviceworker_amp.js |
| dashboard-03.moengage.com | 1. amp-helper-frame.html 2. amp-permission-dialog.html 3. serviceworker_amp.js |
| dashboard-04.moengage.com | 1. amp-helper-frame.html 2. amp-permission-dialog.html 3. serviceworker_amp.js |
Add Code
Add the following code inside<body> tag:
- DOMAIN.COM with your actual domain.
- WORKSPACE_ID with your Workspace ID available at MoEngage Dashboard > Settings > General.
Ensure all files are available at the same source path and suffixed with HTTPS.
Add the Subscribe or Unsubscribe Buttons
Subscribe / Unsubscribe buttons or Amp Web Push Widgets are needed to subscribe or unsubscribe the user from AMP Web Push Notifications. The following code adds the subscribe or unsubscribe buttons:<button> or <a> with on="tap:amp-web-push.subscribe" for the button to work. You can:
- Modify the exact call to action of the button.
- Use your own text or leave it as it is.