I am battling to get the subscriberid into a PHP variable from the console.log(). Webpush have given the js code but unfortunately when asked to assist they said they couldn't. Below is what they share. Please can someone assist me.
The main javascript snippet (This works perfectly).
<!-- start webpushr tracking code -->
<script>(function(w,d, s, id) {if(typeof(w.webpushr)!=='undefined') return;w.webpushr=w.webpushr||function(){(w.webpushr.q=w.webpushr.q||[]).push(arguments)};var js, fjs = d.getElementsByTagName(s)[0];js = d.createElement(s); js.id = id;js.async=1;js.src = "https://cdn.webpushr.com/app.min.js";
fjs.parentNode.appendChild(js);}(window,document, 'script', 'webpushr-jssdk'));
webpushr('setup',{'key':'BImQVMHyUy7kk35aSYV0Hrl9He2x8aCIxKSUSGB7KO6YuhnfpXw5m--TgDKncy730vc3w2tZIf6ddFR19NODjkQ' });</script>
<!-- end webpushr tracking code -->
Then they say Call fetch_id method inside the main JavaScript snippet, as shown below (It is here that I have no idea where to put it in the above snippet, and how to get it into a PHP variable so I can add it to my MySQL database):
<script>
<!-- Our JS snippet goes here -->
webpushr('fetch_id',function (sid) {
//save id to database
console.log('webpushr subscriber id: ' + sid)
});
</script>
Please someone help.