Introduction

Webpushr lets you fetch the unique Subscriber ID associated with your site's subscribers. You can fetch this ID by calling fetch_id method inside _webpushrScriptReady function.

<script>
     webpushr('fetch_id',function (sid) { 
            });
</script>

Sample Fetch ID Code

Call fetch_id method inside our main JavaScript snippet, as shown below:

<script>
   **Our JS snippet goes here** 
   webpushr('fetch_id',function (sid) { 
        //save id to database
        console.log('webpushr subscriber id: ' + sid)
    });
}</script>

Alternatively, you can also add the following code anywhere on the page:

<script>
  function _webpushrScriptReady(){
    webpushr('fetch_id',function (sid) { 
        //save id to database
        console.log('webpushr subscriber id: ' + sid)
    });
}</script>

You can also call fetch_id method on a custom event such as a click of a button:

<script>
$(element).click(function(){
    webpushr('fetch_id',function (sid) { 
        //save id to database
        console.log('webpushr subscriber id: ' + sid)
    });
});
</script>

Why fetch Subsciber ID?

In order to send highly targeted website push notifications using our REST API

Limitations

Since subscription endpoints change over time, so will Webpushr's subscription IDs. What this means is that the ID will change for the same unique person over time. Please plan to update this periodically in your application.