Get Even More Visitors To Your Blog, Upgrade To A Business Listing >>

How To Integrate Web Push Notification on AMP

AMP – or Accelerated Mobile Pages – is a project backed by Google that aims to make the loading of mobile web pages much faster.

According to Google, 40% of people abandon a website that takes more than 3 seconds to load. This demonstrates that users expect websites to load almost instantaneously.

Essentially, AMP pages work by using a lighter version of HTML that allows websites to load much faster than regular HTML.

As google give AMP pages more importance in search engines, you will get hell out of traffic. So it will be better idea to implement Web Push Notifications on AMP pages and increase your subscribers.

How to implement Web Push Notification on AMP pages

There are 3 simple steps to implement Web Push Notifications:

1. Start with an empty html page with basic html structure. Add the script tag given below in your head section. This will load amp-web-push library provided by amp project.

2. Now create a widget to give user to subscribe to push notification. Make two buttons , one for subscribe and one for unsubscribe. You can remove unsubscribe button but it will recommended by google for better user experiences. Add this code in body part.


amp-web-push-widgetvisibility=unsubscribed layout=fixed width=250 height=80>

buttonon=“tap:amp-web-push.subscribe”>Subscribe to push Notificationsbutton>
amp-web-push-widget>

amp-web-push-widget visibility=subscribed layout=fixed width=250 height=80>
 button on=tap:amp-web-push.unsubscribe>Unsubscribe from push Notificationsbutton>
amp-web-push-widget>

Note : Visibility tag is required here. Visibility will take three value namely subscribe , unsubscribe or blocked . Widget will show and hide on the basis of user’s subscription state .For ex. first time user will see widget with visibility unsubscribe and if user subscribe the push, he will see widget with visibility subscribe .

3 . Now it’s time to install service worker and other configuration. For this you have to integrate three files in your root folder of our web site and your site must be on https. This three files are as following:

  1. helper-iframe-url
  2. permission-dialog-url
  3. service-worker-url

You can download these files by clicking on them.

Add this amp-web-push tag in html page which loads the all three files.

amp-web-push
 helper-iframe-url=“https://example.com/helper-iframe.html”
 permission-dialog-url=“https://example.com/permission-dialog.html”
 service-worker-url=“https://example.com/service-worker.js”
>amp-web-push>

Now question is for what purpose we are adding these three files

helper-iframe-url : This page works as a mediator between amp and service worker, to enable communication which subscribes and unsubscribes the user. Notification permission status is also determined by this page.

Permission-dialog-url : This page is for user interaction which open a page as a pop up and prompts for notification permissions.

Service-worker-url : As you know it will run in background which subscribe, unsubscribe the users or display notifications to them.

If you don’t know about Service Workers, you can use third party sites which provide complete solution for Web Push Notifications like NotifyVisitors

Important Points to note to activate Web Push Notification on your AMP pages.

  1. Your AMP page must pass in validation.
  2. Your site must be on https.
  3. All three files mentioned above must be placed in root folder

The post How To Integrate Web Push Notification on AMP appeared first on NotifyVisitors | Web Push Notifications.



This post first appeared on Boost Your Customer Engagement With Web Push Notifications, please read the originial post: here

Share the post

How To Integrate Web Push Notification on AMP

×

Subscribe to Boost Your Customer Engagement With Web Push Notifications

Get updates delivered right to your inbox!

Thank you for your subscription

×