Install Web behavior tracking

Learn how to install our web behavior tracking script on your site to begin passing Webinsight data in to your Dotdigital account.

Overview

There are several ways to modify the web behavior tracking code to take advantage of additional functions. The modifications you choose to make depend on your requirements and technical ability.

Most users install the script without any significant modifications, as this is the least time consuming and simplest way to get started. If you're in doubt or don't fully understand the additional options available then you should use the standard implementation. We always recommend that you have your website developers help you with this process.

Before you start

Things you need to know:

  • You must have the Can manage account permission enabled to access web behavior tracking.

    To learn more, check out the article Restrict and grant user access permissions.

  • Some of our ecommerce integrations apply the web behavior tracking script to your site automatically. You might still need to create a web behaviour tracking profile and enter the resulting ID. Check the specific installation instructions for your integration in the Integrations area of our Help Centre.

Create your web behavior tracking profile

A web behavior tracking profile allows you to define which website domains should be able to pass WebInsight data in to your Dotdigital account. WebInsight data is gathered by session - a web behavior tracking session begins logging user activities from when the user arrives on your site until they leave or have been idle for 35 minutes.

To create a web behavior tracking profile:

  1. Go to Settings > Access.
  2. Select the Web behavior profiles tab and then select NEW PROFILE.
  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.
    1. You don't need to include http(s)://www.
    2. Subdomains of a specified parent domain are automatically tracked and don't need to be specified - a single session can include activity on the parent and sub-domains.
    3. Specific subdomains, such as shop.domain.com, can be listed without their parent domain.
    4. Only website domains that are listed under this profile can send data through to your account.

      If you want to be able to track more than 15 unique domains, you can create an additional web behavior tracking profile.

  5. Select CREATE.
    WBT-profile.png

Edit your profile

On the Web behavior tracking profile page, you can see and edit various options. You are taken straight to this page once you create a new web behavior tracking profile, but you can access a profile at any time to edit it:

  1. Go to Settings > Access.
  2. Select Web behavior profiles.
  3. Select Edit to the right of the profile.

There are a number of fields that you can see and make changes to:

Unique ID The ID of this web behavior tracking profile. This cannot be edited.
Name The name of your profile. This can be edited.
Website domains Up to 15 unique website domains. You can add or remove domains.
Status You can set the profile to be Enabled or Disabled.
Ajax single page If you have a single page website, or load content using Ajax, switch this toggle to On. If you're not sure, check with your website administrator.
Track abandoned carts (applicable for 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, switch this toggle to On. Then, 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 non-Magento users) This option becomes visible if you choose to track abandoned carts. If any visitors to your site abandon their carts and they aren't contacts in your account, a new contact is created for each visitor whom the script is able to identify by email address. You can then send them abandoned cart emails.

When you turn on abandoned carts for guests

It is your responsibility to make sure that you are clearly displaying the correct consent text on your website.

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.

As you make changes, the script displayed in the Tracking code field is automatically updated. Once you're happy with the configuration of your profile, select Save.

Install the script

  1. Copy all of the tracking code to your clipboard from the Tracking code field.

    You must include the <script> </script> tags.

  2. Provide this tracking code to your website developers. They will need to add the code into the <head> of each of the websites you listed under Website domains.
    wbt_script.png

Script implementation options

Depending on your website’s configuration, and the information and users you want to be able to track, the code you implement varies. Below is an outline of each implementation you can use and an example of how the script looks.

Script examples

The scripts we provide below are for illustrative purposes only. You must use the script generated for you in your Dotdigital account. Some implementations will require further customisation by your website developers.

Basic implementation
The following code is the most basic and popular implementation of our web behavior tracking script. The implementation is as simple as placing the following code on every page of your website that you want to be able to track a user's behavior on. This process is identical to other similar tracking tools, for example Google Analytics.

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

Tag Management tools

While the web behaviour tracking script is compatible with tools such as Google Tag Manager, in order to track additional activities which do not occur on page load, your web developers will still be required to modify the script.


(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 essentially the same as the unmodified implementation, except that you can call this function to manually notify web behavior tracking that the page has been viewed, for example, to identify an event that occurs after the initial page load:

window.dmPt('track');

Custom values implementation
By default, the web behavior tracking script sends Dotdigital the following information:

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

If you want to include more data than this so that you have more information available to use in segments or automations, for example, then we provide the ability to submit custom page values with each page request.

You can provide the web behavior tracking script 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', { keyName1: 'Hello', keyName2: 'World' });

User identification implementation
By default, the web behavior tracking script identifies a user when a recipient clicks through from one of your Dotdigital campaigns to your website.

You might have additional ways that a user provides you with their email address whilst visiting your site, for example, a customer login form or newsletter subscribe option at checkout.

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

User emails

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 through your website. This will be a customised process unique to your site, so your website developers will need to make the necessary amendments to the script to enable this. It is not possible to use an identifier other than email address.

Check it's working

Once you've set up web behavior tracking, it can take up to one hour before you start seeing data being passed in to your account.

To check you're tracking data and correctly associating it to a contact:

  1. Send yourself a test campaign that includes a link to the site where you have installed the web behavior tracking script.
    • To learn how, check out the article Create, test, and send an email campaign.

    • You can't use the Link to page option as it is a system link and doesn't add the tracking parameters to the URL. Instead, add it as a Hyperlink.Add-hyperlink.png
  2. Open the link from the email, and browse a few pages of your site.
  3. Wait one hour to allow the data to pass into the account, then, in Dotdigital, go to Email > Contacts > All contacts.
  4. Find and select the contact record that you sent the test campaign to.
  5. On the Single customer view page, select Insight data.
  6. Expand the Collections drop-down menu, and select Webinsights.

    WebInsights only appears if there is data available.

  7. Select the individual Webinsights data file to view it in more detail.
    wbt_record.png

See more

Did you find this article helpful?

Can we help?

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