woensdag 10 december 2014

Tracking email opens with Google Analytics - without using __utm.gif or javascript

Click in e-mail

When sending e-mails out it's allready common practice to make sure every click in your newsletter is tracked by Google analytics

Google has a fine online tool for this which explains all the possible parameters so on analytics you can see the clicks under Conversions / Campaigns
example: http://yourwebsite.com?utm_source=Newsletter&utm_medium=email&utm_campaign=DecemberEdition

E-mail is opened

But what is more difficult is to track if an e-mail is opened. When you install a Google tracker on your website you install a javascript which generates html which renders a __utm.gif on the google servers. While passing through every parameter Google analytics sees which pages are opened

Since it is impossible to run Javascript in a e-mail it is not possibe to use this method.
For some years we included a self generated version of the utm.gif but since August 2014 we've noticed that this method doesn't work anymore

Offcourse this only works if users load the images of the e-mail

No longer using utm.gif

After some hours of debugging I read that Google actually (finally) created a fully documented way to solve this issue. There is now something called the "Measurement Protocol"

The Google Analytics Measurement Protocol allows developers to make HTTP requests to send raw user interaction data directly to Google Analytics servers.
Normally you can only do a HTTP post but HTTP GET is also possible.
So I've put a little PHP code together which generates a img src like this and I can see the events in my Google analytics.

<img src="https://www.google-analytics.com/collect?v=1&tid=UA-XXXX-Y&cid=1234&t=event&ec=Newsletter&ea=EmailOpen&el=DecemberEdition&cs=Newsletter&cm=email&cn=DecemberEdition">

Both pageview as event tracking is very easy now. Check this page for more details
https://developers.google.com/analytics/devguides/collection/protocol/v1/devguide#ecom
Missing from this list are
cs= utm source
cm= utm medium
cn= utm campaign

Geen opmerkingen:

Een reactie posten