How to track your emails?

Updated by Ole Dallerup

Please only implement the scripts below IF you are currently using the legacy version 1.0 of Dreamdata's Web Tracking script. Otherwise, we recommend using the new Web Tracking script, version 2.0, which has built-in support for form tracking, intent sources and other integrations.

How to track your emails?

Most companies send emails for marketing, sales, and product-related information using Mailchimp, Customer.io, ActiveCampaign, or similar. This article will describe how you best ensure that tracking those emails and providing the activity gets into your customer's journey.

For all cases, we recommend you set up UTM parameters on all links in your emails, setting utm_source, utm_medium, and utm_campaign as shown in the example.

https://dreamdata.io?utm_source=newsletter&utm_medium=email&utm_campaign=b2b_revenue_attribution

This will give you the basic and ensures that the Dreamdata tracking script can take the UTM parameters and use them for your analytics.

Note: Dreamdata does not recommend attribution on either email sent or open. It's too weak a signal and will generally over-attribute emails.

Linking to sites without your tracking script

If your emails link to sites that do not have your tracking script, then the UTMs won't be tracked, and you won't see the click in the customer journey. In such cases, you have two options:

1. Add tracking script to the website (recommended)

2. Using a redirect service where tracking is added

Add the tracking script to your commercial websites and landing pages. However, it might not be possible, maybe it's not your website at all, or perhaps the site does not support you adding custom scripts.

In such cases, you might want to create a small redirect page, where you send users to track them and then redirect them to the page you intended. Here is an example code we use at Dreamdata for this purpose. For example, try to click https://dreamdata.io/redirect?url=https://google.com it will send you to Dreamdata, show a Dreamdata logo (and track you) and send you to Google.

The below code snippet assumes you are either using Dreamdata analytics.js or Segment. The script waits for the analytics script to be ready, and when it redirects the user to the URL parameter. At this point, the tracking script would have fired the page track, which would have picked up any UTMs, and cookies already on that computer.

window.analytics.ready(function() { 
var getParams = function (url) {
var params = {};
var parser = document.createElement('a');
parser.href = url;
var query = parser.search.substring(1);
var vars = query.split('&');
for (var i = 0; i < vars.length; i++) {
var pair = vars[i].split('=');
params[pair[0]] = decodeURIComponent(pair[1]);
}
return params;
};

var params = getParams(window.location.href);
var url = params.url;

if (url) {
window.location.href = url;
}
});

URL parameters

There are even more advanced cases when you might want to send additional information in the URL and identify the users as soon as they click the link. That is possible if you either have reasonable control over your user IDs or ok with sending the user's email in an URL parameter. The more privacy-friendly method might be only sharing the user's company identity.

For example, if you parse the user's company website in the URL parameter, ajs_group_website=example.com Dreamdata can associate that user with example.com without further information. In the customer journey, the user will be anonymous under example.com until the user might identify his/her email.

https://dreamdata.io?ajs_group_website=example.com

Here you can read more about supported URL parameters.


How did we do?