How to check the subscription status of a user and capture the identifier?

Web push does not capture any identifier. We know finding an identifier that can link to the CRM or Database is essential. So in this guide, we will explain how you can check if your website visitor is a web push subscriber. Then you can capture the identifier and map it to your Database or CRM.

Checking if Website Visitor is Push Subscriber

There is a simple JavaScript API – User Subscription Status, which tells whether or not a person is a web push subscriber.

window._peq.push(['subscriber-status',function(res){
    if(res.statuscode==1)
    {
      // Code to return response
      console.log(res);
    }
}]);

The subscriber hash (Subscriber identifier) and the status code are added to the response code. This can be saved from the javascript variable and later mapped in your database. A Subscriber hash is the unique identifier of web push notifications that can be used for deeper API integrations.

Note: However subscriber hash keeps refreshing periodically, so if you are using it for any integrations, make sure you have some monthly or quarterly checks to update the hash in your CRM.

Mapping a Profile ID

There is another alternative instead of mapping our subscriber hash and keeping a periodic check. You can map your Database ID or CRM ID as Profile ID in our system against the subscribers. This way, you can get a broader spectrum to use segments saved in your database or CRM to trigger push notifications.

The process remains the same to check the subscription status. However, you can use our Adding a Profile ID Javascript API within the same callback.

Here is how the sample code would look like –

window._peq.push(['subscriber-status',function(res){
    if(res.statuscode==1)
    {
      // Code to return response
      console.log(res);
      window._peq.push(["add-to-profile", "profileId"]);

    }
}]); 

Here the Profile ID would be the exact ID you want to pass as a dynamic parameter.

Sending Notifications through REST API

You need to get your API Key if you have not fetched it from Dashboard. If you want to send notifications through API.

Navigate to Site Settings » Site Details. Scroll to API Key Section and click on Copy.

You can use REST API to send push campaigns based on the events or segments in your system once you have a mapping in place.

You can use optional parameters from the mentioned API

subscriber_hash or profile_id

This one-time integration connects your push database and customer database.

If you run into any issues, please contact us by clicking here. Our support team will be able to help you.

Still stuck? How can we help?
Last updated on September 22nd, 2023

Engage and Retain Visitors AfterThey’ve Left Your Website

Increase the value of every web visit with Push Notifications that are hard to miss.

  • Forever Free Plan
  • Easy Setup
  • 5 Star Support