Google Analytics Email Tracking, Part 2
In part 1 of this series, I showed you how to use Universal Analytics and the Measurement Protocol to track whether or not someone opened your email.
Now we’re going to kick it up a notch use email to tag visitors with a unique ID. This will let you track visitors to your site across devices, like below:
We’ll continue from where we left off after the last post, so I’ll assume you’re already using Universal Analytics, and you have a custom metric set up to keep track of email opens. We’ll continue to use MailChimp to walk you through setting this up, but you should be able to apply these steps to whatever email marketing platform you’re using.
In step 1 of the last post, you created a custom metric in the Google Analytics admin interface called Email Opens to track the number of times an email was opened. This time, you’ll create a new custom dimension called Visitor ID to keep track of individual users.
Log in to Google Analytics and go to the Admin section. Select your account and web property, and click on Custom Definitions under the Web Property column. Then click on Custom Dimensions.
In the next window, click on the New Custom Dimension button, and give your custom dimension a name (I recommend Visitor ID) and set the scope to User. Also, make sure the Active check box is checked.
Now that you’ve set up your custom dimension, it’s time to start populating it. In our example, we’re going to do that through email marketing. When someone opens your email, it will show up in Google Analytics as an email open from visitor ID 12345 (or whatever their ID is). And when they click on a link in the email, it will show up as a visit from that same visitor ID.
To do this in MailChimp, there’s a feature that we’ll take advantage of called Ecommerce 360 link tracking. You’ll find this in the Setup phase when you’re creating an email campaign – check the box for Ecommerce 360 link tracking:
So, what is Ecommerce 360? Basically, it makes it possible to track visitors from your email campaigns, capture transaction information, and pass it back to MailChimp.
But that’s not why we’re using it. We’re using it because when you have it enabled and someone clicks on one of your email links, it adds a couple of parameters to the end of your URL. Specifically, these are the parameters:
The mc_cid parameter is the internal MailChimp campaign ID and the mc_eid parameter is the unique, MailChimp-generated ID for the list member.
In other words, MailChimp is giving you the unique ID to use in your Visitor ID dimension!
To get that ID stored in your Visitor ID custom dimension, you’ll need a tiny bit of script on your page to check for that value in the URL and capture it. If you look at the source code on this site, you’ll see our Universal Analytics code has been updated to include this extra code (lines 9-17):
With the script above, plus the Ecommerce 360 option in MailChimp, you’ll now be capturing the user ID of visitors who click on the links in your emails, but remember, we also want to do that if they open the email (without clicking a link).
To do that, we’re going to modify the code from step 6 in the previous post. This is where we’re placing our “fake” image at the bottom of the email that sends the data to Google Analytics:
The only difference from the previous post (the code above) is that we’re now also going to add the unique ID to the custom dimension. We can do that as follows:
OK, so I admit that you’ll have to roll up your sleeves and get your hands a little dirty with some code. But your efforts will be rewarded with large sums of money and glory.
You’ll now be able to see the following scenario playing out in your data:
Visitor ID 12345 (which you can match back to John Q. Smith in MailChimp) opened your email on his phone on a Monday. Then he opened the same email from his computer on Tuesday and clicked the link to go to your site, where he browse around but didn’t convert. Then he came back to your site on Thursday and made a purchase (or signed up, subscribed, etc.).
Cross device nirvana!