Skip to content

Instantly share code, notes, and snippets.

@tommymarshall
Created September 24, 2012 16:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tommymarshall/3776989 to your computer and use it in GitHub Desktop.
Save tommymarshall/3776989 to your computer and use it in GitHub Desktop.
GA Print Tracking
trackPrint: function() {
var timestamp = new Date().getTime();
var img = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/__utm.gif?';
img += 'utmac=UA-6451336-1&';
img += 'utmp=' + window.location.origin + '/print' + window.location.pathname + '&';
img += 'utmcc=__utma%3D[INSERT UTMA VALUE].' + timestamp + '.1%3B%2B__utmz%3D[INSERT UTMZ VALUE]%3B';
console.log(img)
$('<style media="print">body:after { content:url("' + img + '"); }</style>').appendTo('head');
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment