How to check if visitor has subscribed to push notifications?

With MaxTraffic you can create special offers (daily bonus, promotions with additional discounts, etc.) for those users who have subscribed to Web Push Notifications. That gives an additional incentive for visitors to subscribe to your sites Push Notifications, and you will be able to reach much wider audience when sending them.

To get started, you need to modify MaxTraffic tracking script:

1. Passing userId to MaxTraffic

By default your tracking script will look like this (we use 999 as your website ID in this example):

<script>
    window.mt=window.mt||function(){(mt.q=mt.q||[]).push(arguments)};mt.l=+new Date;
    mt('create', 999);
</script>
<script async src='//cdn.mxapis.com/mt.js'></script>

If a visitor has not logged in your system, then you need to keep the same tracking code as above.

BUT - if a visitor has logged in your system, and you know his unique user ID, then you need to add additional line to tracking script, sending us info about his userId (in this example userId is 123456789):

<script>
    window.mt=window.mt||function(){(mt.q=mt.q||[]).push(arguments)};mt.l=+new Date;
    mt('create', 999);
    mt('set', 'userId', '123456789');
</script>
<script async src='//cdn.mxapis.com/mt.js'></script>

Note: make sure that instead of 999 you are using your own website ID in the tracking script.

2. Get your API key

To use API, you first need to get your API key in e.maxtraffic.com > Push Notifications > Settings > API.

3. Checking if user has subscribed to notifications

After you have done modifications to tracking script, you can send server-side requests to our REST API and get info about any user to see if he has subscribed to Web Push Notifications or not. 

To get this info, see documentation here: http://dev.maxtraffic.com/#operation/getVisitorById

4. Special offers

Now that you know who has subscribed, you can save this info in your own user database and depending on status - either offer user some special promotions or bonuses, or inform him - that he needs to subscribe to notifications to receive them.