Installing Web Behaviour Tracking

Contents

Basic implementation
Manual page tracking implementation
Custom values implementation
User identification implementation

Summary

Web Behaviour 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 a unique code that will be supplied to you.

Basic implementation

The following code is the most basic and popular implementation of our Web Behaviour Tracking code. The implementation is as simple as placing the following code on every page of your website that you wish Web Behaviour 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 Behaviour 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 Behaviour 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 Behaviour 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 Behaviour 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 Behaviour 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 Behaviour 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

Powered by Zendesk