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

It is very easy to capture the subscription status of a subscriber when you are trying to build an internal mapping to CRM or capturing the subscribers in your database.

There is a simple JavaScript call ‘User Subscription Status’.

This API call returns user subscription status in the form of object.

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

Response

{statuscode:1,status:"SUBSCRIBED",message:"User subscribed successfully",data:{subscriber_hash:"UserUniqueId"}}
{statuscode:2,status:"DENIED",message:"User denied push notification"}
{statuscode:3,status:"CLOSED",message:"User closed subscription Opt-in"}
{statuscode:20,message:"Your website url is not allowed, please configure in PushEngage correctly"}
{statuscode:21,message:"Your browser does not support PushEngage web push notification"}
{statuscode:22,message:"User not subscribed"}

Along with the status code, the subscriber hash (Subscriber identifier) is also added to the response code. This can be used saved from the javascript variable and later mapped in your database.

Subscriber hash is the unique identifier of web push notifications that can be used for deeper API integrations.

Still stuck? How can we help?
Last updated on February 22nd, 2021

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