Pushpad
Articles › Analytics And Monitoring, Pushpad

How to find the pages that generate more subscriptions to web push notifications

Recently a customer has asked:

I would like to track which are the best pages of my site to get subscriptions.

Here's a simple solution using Pushpad Pro and the Javascript SDK:

pushpad('status', function (isSubscribed) {
  if(!isSubscribed) {
    // the user is not subscribed...
    pushpad('subscribe', function (isSubscribed) {
      if(isSubscribed) {
        // ... and then is subscribed:
        // this means that a new subscription has been created just now on this page
        // let's update the stats
        fetch('/your_stats', {
          method: 'POST',
          body: 'location=' + window.location.href
        });
      }
    });
  }
});

For the stats you can use your own system of stats (like in this example) or send an event to Google Analytics for example.