Install Web behavior tracking

Learn how to install web behavior tracking to get valuable insights into how customers and prospects use your site.

Overview

There are a few variations of web behavior tracking code that you can install on your site. The variation you pick depends on your requirements and technical ability.

Most users install our basic implementation. This is the least time consuming and the simplest to get started with. If you're in doubt or don't fully understand the other options available then you should use the basic implementation.

Create your Web Behavior Tracking profile

Use Web Behavior Tracking to create unique tracking profiles containing tracking code that you can add to your website to gather browsing insights by sessions. If the Web Behavior Tracking script is set to track a top-level domain and sub-level domains, it tracks as one continuous session. 

A session is any activity that occurs on a domain between the time a user arrives and the session expires.

To create a web behavior tracking profile:

  1. Go to Settings > Access

    WBT_settings_select_access.png
  2. Select the Web behavior profiles tab and then select New profile or Create on now.WBT_new_profile.png
  3. For Name, enter a name for your profile.
    For example, Main website.
  4. For Website domains, enter up to 15 unique website domains where this code might be placed.
    • You don't need to include http(s)://www.
    • Subdomains of 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 can send data through to your account.For Website domains, enter up to 15 unique website domain URLs where this code might be placed. 
  5. Select Create.WBT_profile_name_and_domains.png
  6. On the Web behavior tracking profile, you can see and edit various options:
    • Unique ID
      The ID of this Web Behavior Tracking profile. 
    • Name
      The name of your profile. You can edit this.
    • Website domains
      Up to 15 unique website domains you entered in the previous step. You can add and remove domains.
    • Ajax single page
      If you have a single page website, or load content using Ajax, turn on the Ajax single page toggle. If you're not sure, check with your website administrator.
    • Track abandoned carts (applicable for our non-Magento users)
      If you have a store and want to track the contents and value of abandoned carts that don't reach your checkout, turn on the Track abandoned cart toggle. Once this is turned on, you select Follow these steps to complete this script's setup, which takes you to our support article about setting up our abandoned carts module.
    • Enable guest carts (applicable for our non-Magento users)
      You see this option if you choose to track abandoned carts. If any visitors to your site abandon their carts and they aren't contacts in your account, you can automatically create a new contact for each visitor. If you turn on the Guest checkout toggle, all unknown visitors to your site who abandon a cart become contacts in your account. You can then send them abandoned cart emails.

      When you turn on abandoned carts for guests

      It's your responsibility to make sure you're clearly displaying the correct consent text on your site.

      We strongly recommend leaving your Regulatory settings on Enforce double opt-in for signups from signup forms and some API methods only (default). If you have to enforce double opt-in for all signups, then we don't recommend using abandoned cart emails for guests as the process won't work correctly. 

  7. From the Tracking field box, copy all the tracking code to your clipboard.
    You must include the <script> </script> tags.
  8. Paste to insert the tracking field into the head of any websites listed on the website domains in this profile.
  9. Once done, select Save.
    tracking-profile-settings.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 behavior 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. 

(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');

window.dmPt('create', 'DM-SAMPLE-01');
window.dmPt('track');


Manual page tracking implementation

This is the same as basic implementation, except you can call this function to manually notify web behavior tracking that the page has been viewed:

window.dmPt('track');

Custom values implementation

As default, Web Behavior Tracking sends Engagement Cloud 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. 

(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');

window.dmPt('create', 'DM-SAMPLE-01');

// 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 Engagement Cloud 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.

(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');

window.dmPt('create', 'DM-SAMPLE-01');
// Associates email address with the user device (hardcoded example, needs to be replaced with actual email)
window.dmPt('identify', 'example@example.com');
window.dmPt('track');

Please note

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

Tracking subdomain implementation

To add a domain to window.dmPt('create', 'DM-SAMPLE-01');, note that all specified domains should be subdomains, like in the examples above. For example, you can't track across, example.com and anothersite.com

We add a cookie, based on the subdomains in the list that match the website URL. A domain always matches a subdomain URL. Ensure the domain name is at the top of the list.

Sub domain tracking implementation (new section, needs copy):

(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');

// Enables tracking for domains example.com and sub.example.com
window.dmPt('create', 'DM-SAMPLE-01', 'example.com,sub.example.com');
window.dmPt('track');
Did you find this article helpful?

Can we help?

Thanks for using Engagement Cloud. If you need more help or support, then contact our support team.