Skip to main content
Install Web behavior tracking

Begin passing Webinsight data in to your Dotdigital account.

Laura Russell avatar
Written by Laura Russell
Updated over 2 months ago

The Dotdigital Tag

The Dotdigital Tag simplifies the process of adding Dotdigital scripts to your site.

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.

  • 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.


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. Expand the User menu and go to Settings > Access > Web behavior profiles.

  2. 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.

      You can leave the list of website domains empty to allow the Web behavior tracking profile to work on any website. However, this has risks. Allowing the profile to operate on any website might increase the risk of account abuse. Consider the potential security implications before leaving the field empty.

  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. Expand the User menu and go to Settings > Access > Web behavior profiles.

  2. 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's 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.

Data that is passed as custom page values is always provided in a string/text format.

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

Retrieve tracked user's details

When a recipient clicks through from one of your Dotdigital campaigns to your website, the web behavior tracking script identifies them. This script then associates their session with the matching contact in Dotdigital. The link between the user and the contact is kept for 365 days.

There are situations where you need to interact with the contact using the Dotdigital API:

  • to enrich any of the contact data fields, preferences, or insight data

  • to add or remove the contact from a list

  • to add the contact to a specific marketing program

  • and more

Using the getTrackedId method, you can retrieve the user's contact ID, which you can then use in the relevant API endpoints available in our developer documentation:

window.dmPt("getTrackedId");

If the user was previously identified by the script and the matching contact is present in the Dotdigital account, the contact ID is returned.

window.dmPt("getTrackedId");
> 123456

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 information 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 or mobile number 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-2408302824-01', '');
window.dmPt('track');

// window.dmPt("identify", "example@example.com"); // Hardcoded example, inject contact email address.
// window.dmPt("identify", { email: "example@example.com" }); // Hardcoded example, inject email as object.
// window.dmPt("identify", { email: "example@example.com", mobileNumber: "00447911123456" }); // Hardcoded example, inject email and mobile-number as object.

User identification

You must replace the example email address or mobile number in the above code with the actual user's email address or mobile number dynamically, as they provide it to you through your website.

This will be a customised process unique to your site, so your website developers need to make the necessary amendments to the script to enable this.


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 an email campaign that includes a link to the site where you have installed the web behavior tracking script.

    • This must be a live send. Browsing sessions from links in test sends are not tracked.

    • To learn more about creating and sending an email campaign, check out the Email basics section of the Help Centre.

    • You must not use the Link to page option, as this is a system link and doesn't add the tracking parameters to the URL. Instead, add your URL 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 Audience > 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
Did this answer your question?