Cross Device Behavior: Google Analytics + Mailchimp

Google Universal Analytics enables marketers and web analysts to move towards user centric measurement using the User ID feature. However, in practice, measuring cross-device behavior is harder than it seems, as in most cases it requires users to log in to a website, which is very often not a common behavior.

As Daniel Waisberg wrote earlier this year, the measurement industry biggest challenge is to find a way to get users to sign in to websites, that would “allow marketers to understand customers and provide them with amazing experiences.”

In this post I will show a method to measure cross-device behavior without requiring users to sign in (it does require registration though). If you are not familiar with Universal Analytics and User ID, I suggest you to read Understanding Cross Device Measurement and the User-ID – a brilliant post by Justin Cutroni.

The challenge in cross-device measurement is associating different sessions in different browsers and devices to the same user. This is not a problem when the user voluntarily logs into our websites. Logging in is a common practice in websites such as Software-as-a-Service solutions, social media platforms, content websites restricted with a paywall, online casinos or banks; but for most websites users will simply go in and out without ever thinking about logging in. Therefore we have limited options to control whether users sign in or not. And it would probably be bad for business if we tried to force them to sign in just for the sake of data precision.

But an alternative solution could be to use our bulk email service to identify all of a user’s devices and associate devices to their proper owner. Needless to mention that this solution would track only those users that have registered with a company at some point in time and provided their email addresses. It still requires registration, but not a log in.

Cross Device Analytics with Emails

Cross Device Measurement with Mailchimp and Universal Analytics

Below I provide an example of how this could be accomplished using Mailchimp. I am going to use a little bit of custom PHP and jQuery, a permanent cookie, and Mailchimp to track cross-device usage without any inconvenience for the user.

First create a mailing list in Mailchimp. I assume this is something every savvy marketer can do. And if you have never used Mailchimp, they offer great getting started tutorials.

In Mailchimp, create a custom signup form field for User ID with field tag USERID (see screenshot below). This is something we need when we send user IDs to Mailchimp and when we generate trackable unique links for subscribers’ emails.

Mailchimp Custom Signup

Now we just need to generate the unique user ID for every subscriber.
In my website template I use PHP to generate unique IDs for all subscribers. Before that I check if the user already has user ID assigned. In that case I will pass the old ID to Mailchimp instead of generating a new one. The code below is what I use:

Of course, because we are just starting to track user IDs every subscriber will get a fresh user ID. In the future, however, we might have subscribers that are already identified with an User ID. They might have subscribed to a different mailing list. Or purchased from our webstore.

Then we include our newsletter signup form on the page (learn more about embedded forms in Mailchimp). In the signup form we add the user ID as a hidden field, and then populate the field with an user ID and pass it to Mailchimp along with the user’s email address.

From the user’s perspective the signup form is just a regular one.

Email Form Analytics

At this point we should also add a permanent cookie to users that contains the freshly generated User ID. I have at least two options: I can add the cookie when the user clicks on “Subscribe” or when the user has actually went through the double opt-in process.

Here we want to use the former option, so I just add the jQuery.Cookie.js library and a piece of jQuery to the template that contains my signup form.

$( "#mc-embedded-subscribe" ).click(function() {
$.cookie('click', '', { path: "/", expires: 3600 });

Note: If you set cookies with jQuery you have to specify the path as “/”. If you don’t, the cookie can only be read within the same URL.

If you want to add the cookie only after the user confirms his/her subscription you have to go to Mailchimp, click Signup forms and select General forms. There you have the option to use custom URLs for signup thank you pages and Confirmation thank you pages. When you create a custom URL for confirmation pages, Mailchimp redirects users to that location after the confirmation email is clicked. On this page you can place the cookie to the user’s browser.

Now, when people start signing up to our list we can see the user IDs collected on Mailchimp.

Mailchimp Analytics User-ID

Next, go to Google Analytics and enable the User ID tracking feature (if this is not already enabled). Below is a screenshot of the Admin panel where you will find a menu called “User-ID” under the Tracking Info section for each of your properties.

User ID Admin

At this point we need to comply with Google’s User ID policy and somehow notify users about the tracking methods in use. In the terms it says that ”You will give your end users proper notice about the implementations and features of Google Analytics you use (e.g. notice about what data you will collect via Google Analytics, and whether this data can be connected to other data you have about the end user).” Perhaps an appropriate place to let them know about this would be to add a notice to the confirmation email.

Now we have our new User ID view on Google Analytics up and running but it does not collect any data yet, we need to implement the new tracking code to the website.

ga('create', 'UA-XXXX-Y', { 'userId': 'USER_ID' });

In practice we need to find a way to populate the USER_ID value (see code above) with the actual User ID, which will be either in the user’s cookie or in the get-parameter of the newsletter subscriber’s link. In order for this to work properly we need to add the following Google Analytics tracking script to our website.

Almost there. Only one step to go.

Now we need only to ensure that when we send Mailchimp campaigns their links contain unique user ID for every subscriber. Let’s suppose we want to send automated campaigns to our mailing list every time we publish a new blog post (read more about RSS driven campaigns).

We go back to Mailchimp, click Create Campaigns – dropdown and select RSS driven campaign. In the Template tab we select Code your own (template, that is).

Mailchimp Template

Here we use Mailchimp’s tags to create the automated campaign from our RSS feed. This campaign is set to be sent every monday and the plan is to publish two posts per week, so the subscriber gets two fresh blog posts once-a-week.

After every link we have to add ?click=*|USERID|*. Mailchimp will replace the *|USERID|* part with the actual User ID assigned to subscriber. When the user clicks the link, she will be assigned with her unique user ID.

Every time she clicks one of my links with a different browser or device, that browser or device will be associated with the user through a permanent cookie.

Concluding Thoughts

Well, of course I might not get all the subscriber’s sessions with this technique. And a creative mind can come up with a number of ways this will not be an accurate method for user tracking. But there are at least three reasons to assume that this will be a very effective way to track unique users.

Firstly, email tends to be the first application people install on their devices and people check compulsively their emails. I do that too.

Secondly, the user is likely to use different devices at different times of the day. Mobile during work hours, iPad after dinner. If I alter my mailing schedule, I’ll have a chance to track all these devices.

Thirdly, as evidence shows, if emails match people’s true interest, a very high percentage of subscribers will actually click the links. Here I am sending – or at least trying to send – interesting content with compelling headlines, Spamming people with mass produced ads will not be an effective method here.

Related Posts