Vincent
Vincent

Reputation: 1157

Using signature to track email open with GA per email (not campaign)

I would like to track email opens with Google Analytics using the signature in the email. There are quite some articles on this (e.g. Tracking email opens in Google Analytics) however as I understand it, these would only provide a general open rate per campaign. E.g. if I send 100 emails, it would send me the % of emails that were opened.

What I would like to know, is what exact email has been opened. Let's say I send 4 emails, I would like to know which of these 4 emails was opened. Since all examples use a general GA campaign, this is not covered in these solutions (right?).

I guess in some way, it would have to pass a unique ID with the pixel upon adding the signature. Potentially through the Scripts API? Any ideas on how this could be done? I doesn't have to be through the signature, I just figured this would be easiest. If there are other ways of doing this when an email is created or sent, then this would also be very helpful.

EDIT: Requirement to the solution would be that I install or connect it once, and from there on it will add this unique ID automatically (or upon adding the signature).

EDIT 2: I came up with a potential solution, however I am not confident this is best practice. I could use the Google Apps Admin SDK to set a signature for a user, which includes a unique tracking code. As soon as an email with this tracking code is sent, I could update the signature again with a new tracking code. It's the best I've come up with so far. Maybe it sparks some other ideas...

EDIT 3: In response to the campaign suggestions: the idea is that this tracker should be easy to add when I send a normal email from GMail. Therefore solution like SendGrid are not suitable, cause I would habe to leave my normal email client for it.

Upvotes: 1

Views: 2428

Answers (3)

Chris Traverse
Chris Traverse

Reputation: 113

http://dyn.com/blog/tracking-email-opens-via-google-analytics/

Using the above technique you can apply a unique userID (non identifiable, obviously) to each user and then in your scenario where you send 4 different emails and want to know which was opened you could modify the following :

cs=newsletter   Campaign Source allows segmentation of campaign types
cm=email    Campaign Medium could segment social vs. email, etc.
cn=Campaign_Name    Campaign Name identifies the campaign to you

so cn=emailOne / emailTwo / emailThree / emailFour etc.

On a side note, if I were being sent 4 emails in quick succession the only reason I would open one would be to find the unsubscribe link.

Upvotes: 1

Russ Savage
Russ Savage

Reputation: 1484

I know this isn't the full answer, but your question mentioned Google Apps Scripts as a possible workaround. If you want to create a beacon that will register with Google Analytics, here is a function to do it. Just make sure you update the parameters at the top of the function.

/********************************
* Track in Google Analytics
********************************/
function getBeacon(campaignName) {
  var TAG_ID = 'UA-XXXXXXXX-X';
  var CAMPAIGN_SOURCE = 'email';
  var CAMPAIGN_MEDIUM = 'email';
  var CAMPAIGN_NAME = campaignName;
  var HOSTNAME = 'www.your-domain.com';
  var PAGE = '/email-campaign-page';
  var DOMAIN_LINK = 'http://'+HOSTNAME+PAGE;

  //Pulled from: http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript
  var uuid = 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, 
    function(c) {var r = Math.random()*16|0,v=c=='x'?r:r&0x3|0x8;return v.toString(16);});

  var url = 'http://www.google-analytics.com/collect?';
  var payload = {
    'v':1,'tid':TAG_ID,'cid':uuid,    
    't':'pageview','cs':CAMPAIGN_SOURCE,'cm':CAMPAIGN_MEDIUM,'cn':CAMPAIGN_NAME,
    'dl':DOMAIN_LINK
  };
  var qs = '';
  for(var key in payload) {
    qs += key + '=' + encodeURIComponent(payload[key]) + '&';
  }
  url += qs.substring(0,qs.length-1);
  return url;
}

You can run that from a Google Script and it will return a url that when placed in an image tag, will register with Google Analytics.

function sendEmail() {
  var TO = ['[email protected]','[email protected]','[email protected]'];
  for(var i in TO) {
    var toEmail = TO[i];
    var uniqueIdentifier = Utilities.base64EncodeWebSafe(toEmail);
    var trackingUrl = getBeacon(uniqueIdentifier);
    var htmlBody = '<html><head></head><body>';
    htmlBody += 'This is my email! Come to my <a href="http://www.example.com">site</a>!';
    htmlBody += '<img src="'+trackingUrl+'" style="display:none;"/>';
    htmlBody += '</body></html>';
    var options = { 
      htmlBody : htmlBody,
    };
    var subject = 'My Email Subject';
    MailApp.sendEmail(toEmail, subject, 'You should have an html email reader by now.', options);
  }
}

The one thing i would watch out for is that with Google Analytics, you should not be tracking things at the email address level (PII shouldn't be in GA). When you said you want to track 4 unique emails, i assumed you meant 4 batches of emails, each with their own id.

Thanks,
Russ

Upvotes: 1

Eduardo
Eduardo

Reputation: 22834

Yes, you can do that, you can reinvent the wheel and hack Google Analytics to track something it was not designed to do. Spend a lot of time trying to integrate that into your email sending and making sure that it outputs a gif into each email with a unique identifier and sending that to GA using the Measurement Protocol. Then all you have to do is just pull this data from GA using their API and reconcile the unique identifiers back to the emails on your end and there you go.

OR You can not reinvent the wheel. Use one of the several tools available for email marketing that have these features baked in.

SendGrid and MailChimp are good options to start looking at.

Upvotes: 0

Related Questions