Using segments for Web Push Notifications

Want to send Web Push Notifications only to some specific group of your website visitors? You can do that by using segments.  

To use this feature, you need to modify MaxTraffic tracking code. By default it looks like this:

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

If you want to add or remove segments, please use addTag or RemoveTag functions:

<script>
  mt('addTag', 'one_tag');                                                                             
  mt('addTag', 'second tag');                                                                                      
  mt('addTag', 'thirdtag');                                                                           
  mt('removeTag', 'oldtag');
</script>

Correct use of addTag, removeTag

addTag/removeTag can be called once or many times, only new unique tags will be added.

Tags are case insensitive, example: "Super User" is transformed to "super user"

Tag max length is 36 chars. If tag length exceeds 36 chars, chars after 36 will be ignored, whitespaces counts as char.
example: "very long tag with more than thirty six characters" will be transformed to "very long tag with more than thirty"

Tag can contain whitespaces, but surrounding whitespace will be ingored. Example: " tag with whitespaces " is transformed to "tag with whitespaces"

Example - creating segment for visitors, who have logged in

If you want to create segment of visitors who have logged in at least once, then:

For visitors who have not logged in execute this tracking code version:

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

For visitors who have logged in, use this code:

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

Note: remember to replace WEBSITE_ID with your own website ID. 

Sending notifications 

After tag integration is done, when sending a new Push Notification, you will be able to include or exclude specific tags in Targeting section: