Created
April 26, 2013 20:00
-
-
Save printminion/5470062 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function testGA() { | |
doTrack_('UA-NNNNNN-1', 'YORR_KEY', 'YOUR_SERVICE', 'YOUR_ID'); | |
} | |
function doTrack_(utmac, key, service, user) { | |
var path = '/' + key + '/' + service + '/' + user; | |
try { | |
var host = 'YOUR_HOST'; | |
var utmGifLocation = "http://www.google-analytics.com/__utm.gif"; | |
// Construct the gif hit url. | |
var url = utmGifLocation + "?" + | |
"utmwv=4.4sa" + | |
//"&utmcn=1"+ //added - extra - not required | |
"&utmn=" + (new Date().getTime())+ //unique - cache buster | |
"&utmhn=" + host + | |
"&utmr=" + '-' + | |
"&utmp=" + encodeURIComponent(path) + | |
"&utmac=" + utmac + | |
"&utmcc=__utma%3D999.999.999.999.999.1%3B" + | |
"&utmvid=" + Math.random() + | |
"&utmip=" + '-'; | |
Logger.log('GA:' + url); | |
var response = UrlFetchApp.fetch(url); | |
} catch(e) { | |
Logger.log(e); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment