Installing Web Behavior Tracking

Contents

Creating your Web Behavior Tracking profile
Basic implementation
Manual page tracking implementation
Custom values implementation
User identification implementation

Summary

Web Behavior Tracking has a few variations of code that you can install on your site depending on the requirements you have, or your technical ability.

Most users install our basic implementation as this is the least time consuming and simplest to get going. If you're ever in doubt or don't fully understand the other options available then it's best to use the basic implementation.

Important

The implementation code given below must be wrapped within <script></script> tags, otherwise the code won't work.

Furthermore, you'll need to replace DM-SAMPLE-01 (in the very first line) with your own unique tracking ID.

Creating your Web Behavior Tracking profile

Once you've purchased Web Behavior Tracking as an add-on to your account, you'll be able to create your unique tracking profiles which can then be added to any website page where you'd like to gather browsing insights.

Follow these steps to create a profile:

1. Click on the person-and-cog icon in the bottom left-hand corner of the screen to produce the settings menu and select Access

settings_select_access.png

2. Click on the Web behavior profiles tab and then click New profile.

wbt_new_profile.png

3. Enter a name for your profile, for example 'Main website', as well as up to 15 unique website domains where this code might be placed. These website domains don't need to include 'http(s)://www.' 

Subdomains belonging to a specified parent domain are automatically tracked and don't need to be specified.

However, specific subdomains, such as shop.domain.com, can be listed without their parent domain.

Only website domains that are listed under this profile will be able to send data through to your account.

Click Create once you've finished.

wbt_profile_name_and_domains.png

4. You'll now be able to see your unique ID, which relates only to this Web Behavior Tracking profile. In order to start using it to send browsing session data to your account, you'll need to copy and paste everything from the 'Tracking code' field and insert it into the head of any website page on any of the website domains specified in this profile.

If you have a single page website, or load content via Ajax, you can also change the tracking code using the option provided. If you're not sure which method you need, please check with your website administrator.

Click Save once you've finished.

wbt_profile_unique_id_and_tracking_code.png

Basic implementation

The following code is the most basic and popular implementation of our Web Behavior Tracking code. The implementation is as simple as placing the following code on every page of your website that you wish Web Behavior Tracking to track a user's behaviour on. This process is identical to other similar tracking tools, e.g. Google Analytics.

This code can either be manually added to your site, or it is also compatible with various tag management tools such as Google Tag Manager. 

var dm_insight_id ='DM-SAMPLE-01';
(function(w,d,u,t,o,c){w['dmtrackingobjectname']=o;c=d.createElement(t);c.async=1;c.src=u;t=d.getElementsByTagName (t)[0];t.parentNode.insertBefore(c,t);w[o]=w[o]||function(){(w[o].q=w[o].q||[]).push(arguments);};w[o]('track'); })(window, document, '//static.trackedweb.net/js/_dmptv4.js', 'script', 'dmPt'); 

Manual page tracking implementation

If your site uses Ajax or is a single page website, but you would still like to notify Web Behavior Tracking that a particular page on the site has been viewed, this is also possible. Using the example code below you simply submit the 'track' value at the time you wish to notify Web Behavior Tracking of a page view.

var dm_insight_id ='DM-SAMPLE-01';
(function(w,d,u,t,o,c){w['dmtrackingobjectname']=o;c=d.createElement(t);c.async=1;c.src=u;t=d.getElementsByTagName
(t)[0];t.parentNode.insertBefore(c,t);w[o]=w[o]||function(){(w[o].q=w[o].q||[]).push(arguments);};
})(window, document, '//static.trackedweb.net/js/_dmptv4.js', 'script', 'dmPt');
// Adds to tracking queue whenever this is called, e.g. on start up, after ajax request etc window.dmPt('track');

Custom values implementation

As default, Web Behavior Tracking sends dotmailer the following values:

  • Session start time
  • IP address
  • Agent
  • Website
  • Number of pages viewed
  • Duration
  • Page title
  • Page URL
  • Date and time of visit

If you require more data than this to truly make your segmentation or automation more effective using Web Behavior Tracking, we provide the ability to submit custom page values with each page request. Using the below code as an example, you can provide Web Behavior Tracking with a series of key/value pairs along with the default 'track' request. 

var dm_insight_id ='DM-SAMPLE-01';
(function(w,d,u,t,o,c){w['dmtrackingobjectname']=o;c=d.createElement(t);c.async=1;c.src=u;t=d.getElementsByTagName
(t)[0];t.parentNode.insertBefore(c,t);w[o]=w[o]||function(){(w[o].q=w[o].q||[]).push(arguments);};
})(window, document, '//static.trackedweb.net/js/_dmptv4.js', 'script', 'dmPt');
// tracks with custom key values (object with name/value pairs, only primitive types!) window.dmPt('track', { customVar: 'Hello', anotherKey: 'World' });

User identification implementation

Web Behavior Tracking's most common method of identifying a user is when a recipient clicks from one of your dotmailer campaigns and goes through to you website. However, you may have ways that a user tells you their email address whilst visiting your site, e.g. a customer login form, checkout or newsletter subscribe box. Using the 'identify' method, you can submit the user's email address as they provide it to you.

var dm_insight_id ='DM-SAMPLE-01';
(function(w,d,u,t,o,c){w['dmtrackingobjectname']=o;c=d.createElement(t);c.async=1;c.src=u;t=d.getElementsByTagName
(t)[0];t.parentNode.insertBefore(c,t);w[o]=w[o]||function(){(w[o].q=w[o].q||[]).push(arguments);};
})(window, document, '//static.trackedweb.net/js/_dmptv4.js', 'script', 'dmPt');
// Track First (any time before, but must be done). window.dmPt('track'); // Simply specify email address window.dmPt('identify', 'test@user.com');

Please note

You must replace the example email address in the above code -'test@user.com' - with the actual user's email address dynamically, as they provide it to you.

Have more questions? Submit a request

Comments

  • Avatar

    Hi

    If a recipient of an email clicks through to abc.com and then as part of their user journey visits xyz.com (which also has Web Tracking setup) will the platform track all of these visits or just the initial landing onto abc.com?

    Thanks

    Jon

  • Avatar

    Hi Jon. Thanks for your question. Yes, provided the domains are added under 'Website domains' in the 'Web behavior tracking profile page' and the Web Behavior Tracking code is added to the pages in question, visits will be tracked. You can add up to 15 unique website domains.