Upcoming LunaMetrics Seminars
Pittsburgh, Jan 12-16 Boston, Jan 12-16 New York City, Jan 26-30 Denver, Feb 9-13

Email Tracking in Google Analytics with MailChimp

This is Part 1 of a 2-part series. >> Part 2

The Problem:

You have some data about your email marketing (for example, open rate) in your email marketing software, and data about visits to your site from email marketing elsewhere (namely, Google Analytics).

Wouldn’t it be great to see an end-to-end view of all that data in one place? With Universal Analytics and the Measurement Protocol, you can, and I’ll show you how, step-by-step.

Today’s post will kick things off by looking first at how to track email opens in Google Analytics. My next post will show how to tag a visitor with a unique ID, so you’ll be able to track them across devices (like in the image below). Finally, we’ll tie it all together so you can see visitor behavior from opening your email to visiting your site and (hopefully!) converting.

Email tracking in Google Analytics with MailChimp

The Solution:

We’ll use MailChimp - a popular (and free, if you want to play along) email marketing manager to walk you through how to set this up, but you should be able to apply the same steps to any email marketing solution you use.

* Disclosure: LunaMetrics uses MailChimp to power our email marketing. However, this post was written independently, without their knowledge or input.

I’ll assume you are comfortable working with UTM campaign parameters to track your marketing activities (you’ll need to know this). For a refresher, check out the following articles:

About Custom Campaigns – Google Analytics Help Center

Best Practices for Creating Custom Campaigns – Google Analytics Help Center

4 Steps to Better Campaign Data in Google Analytics – Dorcas Alexander / LunaMetrics

Google Analytics Campaign Tagging Tool – Jim Gianoglio / LunaMetrics

Step 1: 

First things first. You’ll need to create a new custom metric in the Google Analytics admin interface for your Web Property.

Log in to Google Analytics, and click on Admin in the top right. Select the appropriate Account and Web Property, and click on Custom Definitions under the Web Property column. Then click on Custom Metrics.

Custom dimensions and metrics in Google Analytics

 

In the next window, click on the New Custom Metric button, and give your custom metric a name, formatting type, minimum and maximum value, and make sure the box is checked for Active. I recommend the setting shown below:

Custom metrics in Google Analytics

Step 2: 

Next, you’ll need to log into MailChimp (or whatever you’re using) and start a new email campaign. For our example, we’ll use the “Regular Ol’ Campaign” option.

MailChimp - Create a Campaign

Step 3:

Start by following the wizard in MailChimp – it’s a series of 5 steps to launch your campaign:

MailChimp campaign steps

Do the first two – Recipients and Setup – this is where you decide which list your sending to and some other basic information, like subject line, reply-to email address, etc.

Step 4:

Design your email. This is where you choose your template, or work from scratch, to create the content of your email. If you want to follow along with this example, select the Drag & Drop Editor.

MailChimp drag and drop editor

Step 5:

Choose a template to get started, then create your email. Include all the images, headlines, text, and buttons that will make your list subscribers sing your praises, click on your links and buy your products.

Step 6:

Now the good part. You need to add a Text content block to your email. I suggest at the bottom, but anywhere will work.

Adding text block to email in MailChimp

 

Now you need to edit the content of this block. Click on the angled brackets icon (pictured below) to edit this content in code view.

Tracking email opens in MailChimp

This is where the magic happens – you ready? Put in the following:

<img src=”http://www.google-analytics.com/collect?v=1&tid=UA-XXXXXXX-YY&cid=*|UNIQID|*&t=event&ec=email&ea=open&el=*|UNIQID|*&cs=newsletter&cm=email&cn=062413&cm1=1″ />

Let me break that down for you.

<img src= … Basically, you’re fooling the email into thinking it has to load an image. There’s no real image file, but the source that we specify is the GET request that sends our data to Google Analytics. So when your email tries to fetch the “image,” it’s actually sending the data for you. Keep in mind, the email recipient has to allow images for this to work.

http://www.google-analytics.com/collect? This is the API endpoint for the Measurement Protocol. In layman’s terms, this is where we’re sending the data. The data that’s being sent comes next, in the form of query parameters.

v = 1 Protocol Version (required)

tid = UA-XXXXXX-YY Tracking ID / Web Property ID (required)

cid = *|UNIQID|* Client ID (required). This anonymously identifies a particular user, device, or browser. The value – *|UNIQID|* – is a dynamic parameter (aka merge tag) in MailChimp that will fill in the user’s MailChimp ID.

t = event  Hit type (required). We’re tracking this with event tracking, hence the event hit type.

ec = email Event Category

ea = open Event Action

el = *|UNIQID|* Event Label

cs = newsletter Campaign Source

cm = email Campaign Medium

cn = 062413 Campaign Name

cm1 = 1 Custom Metric 1

You can learn more about these parameters by reading up on the Measurement Protocol Parameter Reference guide.

Keep in mind, you want to be consistent in your naming conventions for your campaign source, medium and content. Any links in your email that go to your site should be tagged with the same source, medium and campaign as above. Following the example above, your links would be tagged as follows:

www.mysite.com/landing-page/?utm_source=newsletter&utm_medium=email&utm_campaign=062413

 

Step 7:

Finish the remaining steps of the email campaign wizard (Plain-Text and Confirm) and send out that email!

Step 8: (optional)

Log into Google Analytics and open up your Real Time reports to see people opening your emails in real time. Can I get a “woop-woop?”

 

The results:

Now, when someone opens up your email, it will record an Email Open as a metric, and you’ll see this showing up in your event tracking reports:

Email opens in Events Reports

 

In Part 2, I show you how to connect visits from the same visitor across devices. This will let you see if John Doe opened your email on his phone, then later visited your site from a link in the email on his desktop, then came to your site from a paid search ad on his tablet.

Jim Gianoglio

About Jim Gianoglio

Jim Gianoglio is a Senior Digital Analyst at LunaMetrics. He works with implementation and analysis of Google Analytics, and spearheads the LunaMetrics Google Analytics seminars across the country. Want to see him in action? He'll be leading some of our upcomingGoogle Analytics trainings. Before succumbing to the siren song of analytics, he led the SEO campaigns of Fortune 500 companies in the insurance, retail and CPG industries. Things you didn’t know about Jim: he has biked from Pittsburgh to Washington DC, photographs weddings, and roasts his own coffee beans.

http://www.lunametrics.com/blog/2013/06/17/email-tracking-google-analytics/

56 Responses to “Email Tracking in Google Analytics with MailChimp”

Yoray says:

woop-woop! :)
cool post luna

p.s
cid = client id – not user id
http://www.youtube.com/watch?v=CzmNbmwDMUs

Thanks Jim. That’s a neat trick. Also, I didn’t realize Google had this API to simulate a website visit.

Do you know if other email service providers, like ConstantContact fill the “cid = *|UNIQID|*”?

Also, I have noticed that you guys do what you preach. There are always some UTM tags in my browser URL when I visit this blog.

Hi Jim! Thanks for this! I was looking for a way to get data from GA that I can compare with what MailChimp is providing.

Subscribed and shared! Looking forward to the next post.

Niroshan says:

Nice implementation Jim. Very helpful and innovation idea. If you could match the CID to link user session you could find initial traffic source details to email openers with more dimentions .

@Yoray – thanks for the “woop-woop” :)

@Puru Choudhary – I haven’t looked into any other email providers yet, but I’m sure many of them will have some way to dynamically add these parameters. For example, in Constant Contact you can use “contact variables” to fill in this info. Look at page 34 of this doc for more details:

http://img.constantcontact.com/docs/pdf/building-your-emails-with-the-advanced-editor-tool-constant-contact.pdf

@Niroshan – I’ll cover that in the next post ;)

Alex Ramadan says:

Clever, definitely going to try this at some point!

James says:

Thanks for a great tip!

We’re looking into whether we can insert a mailchimp merge tag for the cn= campaign name element, so that we can ‘set and forget’, as every other element will stay the same for every campaign.

Our best guess so far is *|CAMPAIGN_UID|* – will this work?

@James -

The *|CAMPAIGN_UID|* merge tag only pulls in the unique ID for the campaign (for example, “df6195c352″). If you select the option in MailChimp to “Add Google Analytics™ Tracking To All URLs” in the Setup step, you then have to type in the “Title for campaign.”

So if you type in “My Campaign” as your campaign title, and someone clicks on a link in your email, it will show up in GA with utm_campain=df6195c352-My+Campaign

So if you want the campaign name for your email opens to match the campaign name for visits from that email (of course you do!) then you’d want to use:

cn=*|CAMPAIGN_UID|*-My%20Campaign

If your campaign name stays the same for all your emails, then you can just “set and forget”, like you mentioned. But if you campaign name changes, you’d have to manually change it (I haven’t found a merge tag for campaign title).

Also, here’s the list of merge tags available – there’s all kinds of other info you could be pulling in:

http://kb.mailchimp.com/article/all-the-merge-tags-cheatsheet

Peter says:

This is a fantastic post. Using this great API trick gives some great data insights into email marketing. Often, many email management software companies (aweber)say they provide this type of analytics insight but actually don’t give as much information as detailed in this post. Thanks Jim, looking forward to your next post.

Oh Jim, this is pretty amazing, just because I was looking for more info about Google Analytics and now I found this. AS you can see, I am more on d-i-y seo that is why a post such as this is a gem to me. Thanks, I will try this out.

Rob Pierson says:

This is a very creative approach, but doesn’t it violate google analytics regulations on personally identifiable information (PII)?

Rob – that’s a very good point! In the case of a MailChimp ID, the ID in and of itself is not PII within GA. By itself, it does not identify a user – it’s just a string of characters and numbers. It’s similar to a transaction ID (which you have in GA if you have ecommerce tracking).

Google can’t identify a user by the transaction ID or MailChimp ID alone. You can – because you have data outside of Google Analytics that you can match up with those IDs. As long as the PII (name, email, phone, credit card number, etc.) isn’t within GA, you’re fine.

There’s always a concern with articles like these that people will see what’s technically possible and do something like putting a person’s name and email in GA (which is easy to do with the merge tags in MailChimp). However, since that’s against GA TOS, the consequences are getting your entire account deleted. Good bye data.

Hai Le says:

Thanks for a great tip

maxim says:

GREAT!!!
5 day of my life ^) rescue

Giuseppe says:

Thanks a lot for this method, it’s going to be very helpful in many ways.

Just one question: does the event hit affects bounce calculations?

@Giuseppe -

Yes – these hits will affect your bounce rate. It may be a good idea to filter these out of your main profile (so your average bounce rate isn’t adversely affected) and then create a profile that does include them.

Evgeniya says:

Hello, thanks for the post!
we have tasted this method, and we have a problem:
in letters which receives our clients, in the source code remains only tag , all our request like src=”http://www.google-analytics.com/collect?v=1&tid=UA-XXXXXXX-YY&cid=*|UNIQID|*&t=event&ec=email&ea=open&el=*|UNIQID|*&cs=newsletter&cm=email&cn=062413&cm1=1″ />
is removed.
when we send the same request just trough the browser, we see it in real-time in Google analytics interface.
Maybe you could give us advice on this problem?

@Evgeniya – when you say “in the source code remains only tag” what exactly are you referring to? Do you mean the utm campaign parameters in links?

I can’t really say why the request is being stripped off – I’m afraid I don’t have enough information about your situation.

What email service are you using (MailChimp, Constant Contact, etc.)? How are you embedding the request in the email? Are you following the example above, or some other way to fit your needs?

Evgeniya says:

Thank you for your response, we solved this problem

Boki says:

What kind of code should I use if I don’t use MailChimp? I would like to add tracking in my email messages sent from gmail.

@Boki -

I’ve played around a little with trying to do this in Gmail and haven’t yet found an easy solution. There are ways it can be done with server side coding, but I was hoping to be able to just go into the Gmail settings and add a “fake” image to the signature. Unfortunately, it doesn’t work.

Jeremy says:

Hey Jim, I’ve been looking into better open tracking, this is a great tip :)

One question though –

Will the user’s ‘device category’ (‘Desktop’, ‘Tablet’, or ‘Mobile’) and other system info be sent along with the data, so we can track mobile vs desktop vs tablet opens? If not, how could we sent the user’s device info to GA along with this GET request?

Thanks!
Jeremy

Michael Ward says:

This is pretty cool and is a great post.

But…

This appears to be a clunky, manual way of getting Google Analytics to do less than what marketing automation systems do automatically.

Build email, send email. Email gets opened. The software knows and shows you who opened it. Email recipient clicks a link and visits pages on your site. All of this activity – every page view, is tracked and reported along with the recipient’s name, email address etc.

Two weeks later prospect visits from their tablet or phone. The software knows. They download a pdf. The prospect submits a form. The software knows.

The system scores each of these events and can alert you when their score reaches a user-defined threshold or when they take a high-value action of your choosing.

I love the direction this post is going but thought readers may want to know that marketing automation systems take this train of thought much further down the track and do it automatically.

I founded a well-known marketing automation software company (Net-Results.com) to take this same path several years ago. Data-based marketing and attribution get me all geeked out :)

@Jeremy -

The device information automatically comes through in the http request header – you don’t have to specify this.

@Michael Ward – I appreciate your comment and agree, there are many systems that take a much deeper dive and connected approach than what is offered in this article. I am merely presenting the options and capabilities that are now possible with Universal Analytics – baby steps first ;)

@C Jeffers – thanks for the heads up on your product. It’s always good to see new software that takes advantage of GA and other common products.

Robin says:

Hey Jim,
Many thanks for this info, I am sure it will prove to be most useful. I still haven’t had a chance to play around with universal analytics yet, all my sites are still using classic analytics. But i would love to try it out with this open rate tracking. Although open rates are available through most e-marketing software, it is very handy to have the ability to track in GA along with visits, goals and transactions.

I do have one question though regarding outlook. How exactly does it know if the user has actually double clicked the email to ‘open’ it? Because some people might a)read the email in the reading pane, b)not read it and continue to scroll to the next email. Can we get accurate data from outlook users, because the image may load even if the user doesn’t open the email.

Many thanks in advance

Andrew says:

Sorry to ask a dumb question…. but I don’t have the option to create ‘custom metrics’ under ‘custom definitions’. The only option available to me is ‘custom data sources (beta)’. Love the post and technique… and I’d like to use the suggestion.

Thank you

@Robin – great question!

It’s been a while since I’ve used Outlook, but as long as the it sends a request for the “image” in the email, then it will be tracked. If you can see email images in the reading pane without double clicking the email, than it will be tracked.

This is somewhat analogous to ad impressions. Just because an ad is served doesn’t mean the person sees it.

@Andrew – If you only see “Custom Data Sources” and not “Custom Metrics” or “Custom Dimensions” that means your web property is not a Universal Analytics property – it’s a “Classic Analytics” property (i.e. asynchronous tracking code).

Currently to get Universal Analytics, you need to create a new web property or account. Eventually there will be a process for upgrading existing web properties/accounts to Universal, but that’s not available yet.

Vin says:

I want to track info list first name, last name, Company, and Phone numbers etc for my email campaigns using google analytics. Please help me.

Dave Davis says:

Can you give an example of a measurement protocol call (URL) that would send an eCommerce transaction? I’m still pretty confused about that. Sending single hit types is fine, but does an ecommerce request need two separate hits to be sent? Or can the transaction item be added then the item added after in the same string?

@Vin –

Tracking PII (personally identifiable information) in Google Analytics (e.g. name, phone number, etc.) would be in violation of GA’s TOS. A unique identifier (like MailChimp user ID) is not PII. The rule of thumb to use here is if someone from Google looked in your analytics, would they be able to identify an individual using the data in GA. Since MailChimp ID by itself does not identify an individual user, it’s fine. You’re more than welcome to take that unique ID and use it as a key outside of GA to match up with PII – OUTSIDE of GA.

@Dave Davis -

The ecommerce data needs to be sent with 2 (or more) hits: 1 transaction hit (http request) that sends the transaction data, and additional item hit(s) for each item purchased.

Here’s the documentation specific for ecommerce tracking with the measurement protocol:
https://developers.google.com/analytics/devguides/collection/protocol/v1/devguide#ecom

Let me know if that doesn’t clear it up – I’m happy to drum up some examples :)

Bobby says:

Interesting but am not seeing any data. Do I need to enable the API or something in order to use the collect function?

@Bobby -

Are you using Universal Analytics? Or are you still using “classic” analytics? One way to find out is to view the source code of a page on your site and look for your Google Analytics tracking code. If you see something like _gaq.push([‘_trackPageview’]) you’re using the classic code. If you see something like ga(‘send’, ‘pageview’) you’re using Universal.

You need to be using Universal to track anything using the measurement protocol. That could be the reason you’re not seeing the data.

Blue_Meanie says:

Hi! thank you for the useful tips. I’m using the pixel for my email campaign however get only the real time data, not the event report. Even after 2 days after the setting. Any advice on what to check? Thank you.

Brian says:

Hi Jim,

This was a huge help and will only lead to bigger things as UA becomes implemented across campaigns ‘universally’. As @Michael Ward pointed out, this post lacks a few identifying characteristics of user information, that could easily be added with using your own site as the src pointer, and adding the necessary custom variables that would be processed on the server side of the 1-pixel image display. One thing you touched on that has me searching for answers, is how this will affect Analytics information. I have noticed that the visits are not counted as bounces (0.00% bounce rate), however, they generate 0 pageviews/visit, and will affect conversion rate and pageviews/visit for the site. Other than separating views in Analytics, is there another way to exclude email opens and other non-visit events from visit tracking to retain proper rate metrics? Thanks again for this post, it was a huge help!

Alison says:

Hi Jim.

Thank you a lot for sharing this useful tip.

I am new to GA. I am trying to put this in my MailChimp campaign but after testing it, I could not see the “Email opens” metric incresed at GA.
That is the link that I am using:

What might be going wrong? Does it take a while to be processed in GA? Maybe it is not being increased because I am only testing the campaign?

TIA
BRs

Alison says:

Sorry. That is the li9nk I am using:
img src=””http://www.google-analytics.com/collect?v=1&tid=UA-44712897-1&cid=*|UNIQID|*&t=event&ec=email&ea=open&el=*|UNIQID|*&cs=Livre%2C+Leve+e+Lendo&cm=email&cn=78c4af325f-lll_newsletter_campaign&cm1=1″

han says:

I don’t use Mailchimp or anything like that–I use a page to test it out. I can see the opens in real-time under events in Google Analytics, but then the data does not show under Behavior > Events. I waited over 24hrs. Just in case, my code is:

Any ideas?

han says:

Oops, the code:

img src=”http://www.google-analytics.com/collect?v=1&tid=UA-xxxxxxxxxx-17&cid=SOME_RANDOM_NUMBER&t=event&ec=email&ea=open&el=open_email&cs=notification&cm=email&cn=open_email_tracking”

Sandra says:

Hello!

This is a great post! Im testing it out but, im currently using constact contact and I’m not sure what to put for:

cid = *|UNIQID|* Client ID (required). This anonymously identifies a particular user, device, or browser. The value – *|UNIQID|* – is a dynamic parameter (aka merge tag) in MailChimp that will fill in the user’s MailChimp ID

Thank you!

Scott says:

I can’t understand why I couldn’t look up any companies Analytics ID and complete mangle their data. Where’s the security?

Christopher says:

Has anyone figured out how to get this to work with Constant Contact?

Vivek Moyal says:

I am not getting the custom metrics it is just showing custom data sources

bekabug says:

Does this post need to be updated? I see the broken image in my emails but I’m not finding any reports for this traffic. Help?

Hi

Great post. Now that GA’s been updated any chance you’ll update the walkthrough?

Mary says:

Great post..
I am trying to see if I have any luck putting this into place within MS Publisher, as the staff member here likes using this platform for his newsletters. He likes the simplicity of how MS Publisher pushes emails out via Outlook. I have converted our Publication to a Web Publication, and I have now been able to insert a HTML code Fragment.

I’m still trying to get my head around the code and what i need to change in order to make it work.

Ryan says:

Can this kind of process be done using KissMetrics?

Justin F says:

This will no longer work for users opening the email with Google: arstechnica.com/information-technology/2013/12/gmail-blows-up-e-mail-marketing-by-caching-all-images-on-google-servers/

Justin says:

Any revision or resolution now that gmail proxies images as mentioned by Justin F?

David Booth says:

Great post guys. I’m looking to track the step RIGHT before the campaign gets sent: The list signup. I’m working on a wordpress site, using mailchimp, and I’m looking for the line of code where I should add my event.. but i’m having a hard time finding it… what should i be looking for? Maybe this is blog-post worthy?

@David Booth -

It depends on the plugin you’re using to implement your MailChimp form. Generally speaking, you’ll only want to fire the event after the form fields have been validated (as opposed to adding a click listener on the form submit button).

@Justin & Justin F -

I’m still looking into this issue. I’ll post a comment with any updates.

Raju says:

I think this info will help for mailchimp users only.

Can you provide me more information about other off line tools like robomail or sendblaster ???

@Raju -

Sorry, but I’m not intimately familiar with robomail or sendblaster. In fact, there are many, many email service providers out there, too many for me to cover all of them.

My hope is that you can use the information in this post (and the “part 2″ post) to get this set up. If you use MailChimp, then it’s easy. Just follow the instructions. If you use a different email service provider (Constant Contact, AWeber, robomail, sendlist, etc.) then you’ll need to work within the tool to get the right information sent.

This may not even be possible for every tool. For example, you need to be able to dynamically insert the unique user ID for each email recipient. In MailChimp, that means using merge tags. In other email tools, you’ll need to figure that one out (again, it may not be possible in all tools).

LV says:

Very helpful, however the ‘email opened’ event is triggered every time as soon as the email is sent to a Gmail account. And after that every time it is opened it is triggered again. Any idea what could be the issue here?

@LV – I think this may be related to the issue of Google caching images in email (but I’m not 100% sure on that).

@Justin and @Justin F – It’s on my list to revisit this and determine the implications and any workarounds. It seems like the image caching in Gmail will still allow us to track the first time an email is opened, just not subsequent opens. This response from MailChimp sums it up better than I can:
http://blog.mailchimp.com/how-gmails-image-caching-affects-open-tracking/

I’ll update this blog post after I’ve had a chance to do some more testing.

I am publishing here a twitter exchange I had with the author. I think it will be valuable for others.

me:
@jgianoglio I suspect that the method described here boosts unfairly the sessions for the source. Agree? -Cheers!

Jim Gianoglio ‏@jgianoglio:
@itso Yes – every email open gets counted as a session. Best to create a new View specific to email info, exclude from main View.