Using your own data to create custom segments

Want to send Web Push Notifications to segments that are created based on your own data about your clients? You can do that by using Traits and Javascript API. 

Define user traits (custom fields) 

1. In e.maxtraffic.com go to Push Notifications > Traits

2. Click on "Define new trait" button to add new user trait (custom field)

3. Fill out details about each user trait (custom field) that you want to use:

IMPORTANT: make sure to use correct data type and name field - after you have saved trait, later it will not be possible to make changes to data type or name field. 

4. Click Save

Pass trait info (custom fields) to our tracking code 

For our platform to receive data from your system, you will 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 pass trait info (custom fields) to our platform and later use it in segments, then you need to add Javascript snippet for each trait you want to use. For example, if you want to pass email data to our platform, then you need to add following code:

<script>
  mt('setTraits', {
    'email': 'peter@initech.com'
  })
</script>

Note: replace peter@initech.com with actual email address of your client

So final code would look like this:

//MaxTraffic tracking code
<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>

//Set trait, pass data about client email
<script>
  mt('setTraits', {
    'email': 'peter@initech.com'
  })
</script>

Note: replace peter@initech.com with actual email address of your client

IMPORTANT: if you use Google Tag Manager or similar tool, make sure that both codes (tracking code and trait code) are loaded together as one tag OR set trait code is loaded only after tracking code is initialized.