Skip to main content

Advanced Javascript Functions

Written by Tom Voitik

First you need to have already integrated PushMonetization in to your site.  To view that article click here https://help.pushmonetization.com/publisher-help/how-to-install-pushmonetization-on-your-website
​

Events

If you would like to hook into the events when a user subscribes or when a user denies a subscription you can use the following javascript code.

<script>
function pushMonetizationEvents(event){
    if(event == 'SUBSCRIBED'){
        //Do something when user subscribes
    }else if(event == 'DENIED'){
        //Do something when user denies
    }
}
</script>

Place this javascript code on every page where you have also place the PushMonetization integration code.
​

Is User Subscribed

If you would like to know if the current user on your website is subscribed or not please use this function.

<script>
isUserSubscribed().then(function(result){
    if(result){
        //user is subscribed
        console.log('User is subscribed');
    }else{
        //user is NOT subscribed
        console.log('User is NOT subscribed');
    }
);
</script>

Place this javascript code on every page where you have also place the PushMonetization integration code.

Did this answer your question?