Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
O2 Script - Send data to Google Analytics via get request (of Image)
//descriptions from http://www.lunametrics.com/blog/2011/10/04/utmgif-request-parameters/
var utmwv = "5.3.8"; // Tracking code version
var utms = "1"; // Session requests. Updates every time a __utm.gif request is made. Stops incrementing at 500 (max number of GIF requests per session).
var utmn = "1797201820"; // Unique ID generated for each GIF request to prevent caching of the GIF image
var utmhn = "teammentor-33-ci"; // Host name, which is a URL-encoded string
var utmcs = "ISO-8859-1"; // Language encoding for the browser. Some browsers don’t set this, in which case it is set to “-”
var utmsr = "1440x852"; // Screen resolution
var utmvp = "1440x751"; // Size of Viewing Pane
var utmsc = "32-bit"; // Screen color depth
var utmul = "en-us"; // Browser language
var utmje = "1"; // Indicates if browser is Java enabled. 1 is true.
var utmfl = "11.5%20r31"; // Flash version
var utmdt = "TeamMentor"; // Page title, which is a URL-encoded string
var utmhid = "953523754"; // A random number used to link the GA GIF request with AdSense
var utmr = "-"; // Referral, complete URL
var utmp = "%2FteamMentor"; // Page request of the current page
var utmac = "UA-37594728-3"; // Account string, appears on all requests
var utmcc = "__utma%3D82202515.932366965.1357920813.1358082098.1358084709.5%3B%2B__utmz%3D82202515.1357920813.1.1.utmcsr%3Dlocalhost%3A3187%7Cutmccn%3D(referral)%7Cutmcmd%3Dreferral%7Cutmcct%3D%2FteamMentor%3B";
// Cookie values. This request parameter sends all the cookies requested from the page.
var utmu = "q~"; // This is a new parameter that contains some internal state that helps improve ga.js
var gaRequest = ("https://www.google-analytics.com/__utm.gif?" +
"utmwv={0}&utms={1}&utmn={2}&utmhn={3}&utmcs={4}&" +
"utmsr={5}&utmvp={6}&utmsc={7}&utmul={8}&utmje={9}&" +
"utmfl={10}&utmdt={11}&utmhid={12}utmr={13}&utmp={14}&" +
"utmac={15}&utmcc={16}&utmu={17}").format(
utmwv,utms,utmn ,utmhn ,utmcs ,utmsr ,utmvp ,utmsc ,utmul,
utmje, utmfl, utmdt, utmhid, utmr, utmp, utmac, utmcc, utmu);
return gaRequest.GET();
var id = "id".o2Cache<int>("id".o2Cache<int>()+1);
//descriptions from http://www.lunametrics.com/blog/2011/10/04/utmgif-request-parameters/
var utmwv = "5.3.8"; // Tracking code version
var utms = id; //"1"; // Session requests. Updates every time a __utm.gif request is made. Stops incrementing at 500 (max number of GIF requests per session).
var utmn = 1797201820 + id; // Unique ID generated for each GIF request to prevent caching of the GIF image
var utmhn = "teammentor-33-ci"; // Host name, which is a URL-encoded string
var utmcs = "ISO-8859-1"; // Language encoding for the browser. Some browsers don’t set this, in which case it is set to “-”
var utmsr = "1440x852"; // Screen resolution
var utmvp = "1440x751"; // Size of Viewing Pane
var utmsc = "32-bit"; // Screen color depth
var utmul = "en-us"; // Browser language
var utmje = "1"; // Indicates if browser is Java enabled. 1 is true.
var utmfl = "11.5%20r31"; // Flash version
var utmdt = "_TITLE__" ; // Page title, which is a URL-encoded string
var utmhid = 953523754 + id; // A random number used to link the GA GIF request with AdSense
var utmr = "-"; // Referral, complete URL
var utmp = "_A_PAGE_"; // Page request of the current page
var utmac = "UA-37594728-3"; // Account string, appears on all requests
//var utmcc = "__utma%3D82202515.932366965.1357920813.1358082098.1358084709.5%3B%2B__utmz%3D82202515.1357920813.1.1.utmcsr%3Dlocalhost%3A3187%7Cutmccn%3D(referral)%7Cutmcmd%3Dreferral%7Cutmcct%3D%2FteamMentor%3B";
var domainHash = ""; //"82202515";
var randomNumber = 1000000000.random(); //"932366965";
var timeStamp = DateTime.Now.unixTime();;//"1357920813";
var visitorCount = "1";
var utmcc = "__utma={0};+".format(
"{0}.{1}.{2}.{2}.{2}.{3}".format(
domainHash,randomNumber,timeStamp, visitorCount )).urlEncode();
// Cookie values. This request parameter sends all the cookies requested from the page.
var utmu = "q~"; // This is a new parameter that contains some internal state that helps improve ga.js
var gaRequest = ("http://www.google-analytics.com/__utm.gif?" +
//"utmwv={0}&utms={1}&utmn={2}&utmhn={3}&utmcs={4}&" +
//"utmsr={5}&utmvp={6}&utmsc={7}&utmul={8}&utmje={9}&" +
//"utmfl={10}&" + "&utmhid={12}utmr={13}"
"utmdt={11}&utmp={14}&" +
"utmac={15}&utmcc={16}"
//&utmu={17}"
).format(
utmwv,utms,utmn ,utmhn ,utmcs ,utmsr ,utmvp ,utmsc ,utmul,
utmje, utmfl, utmdt, utmhid, utmr, utmp, utmac, utmcc, utmu);
return gaRequest.info().GET();
var id = "id".o2Cache<int>("id".o2Cache<int>()+1);
//descriptions from http://www.lunametrics.com/blog/2011/10/04/utmgif-request-parameters/
var utmwv = "5.3.8"; // Tracking code version
var utms = id; //"1"; // Session requests. Updates every time a __utm.gif request is made. Stops incrementing at 500 (max number of GIF requests per session).
var utmn = 1797201820 + id; // Unique ID generated for each GIF request to prevent caching of the GIF image
var utmhn = "teammentor-33-ci"; // Host name, which is a URL-encoded string
var utmcs = "ISO-8859-1"; // Language encoding for the browser. Some browsers don’t set this, in which case it is set to “-”
var utmsr = "1440x852"; // Screen resolution
var utmvp = "1440x751"; // Size of Viewing Pane
var utmsc = "32-bit"; // Screen color depth
var utmul = "en-us"; // Browser language
var utmje = "1"; // Indicates if browser is Java enabled. 1 is true.
var utmfl = "11.5%20r31"; // Flash version
var utmdt = "_TITLE" ; // Page title, which is a URL-encoded string
var utmhid = 953523754 + id; // A random number used to link the GA GIF request with AdSense
var utmr = "-"; // Referral, complete URL
var utmp = "_A_PAGE"; // Page request of the current page
var utmac = "UA-37594728-3"; // Account string, appears on all requests
var _utmcc = "__utma%3D82202515.932366965.1357920813.1358082098.1358084709.5%3B%2B__utmz%3D82202515.1357920813.1.1.utmcsr%3Dlocalhost%3A3187%7Cutmccn%3D(referral)%7Cutmcmd%3Dreferral%7Cutmcct%3D%2FteamMentor%3B";
var domainHash = ""; //"82202515";
var randomNumber = "932366"; //1000000000.random(); //;
var timeStamp = "1358127189"; //DateTime.Now.unixTime();;//"1357920813";
var visitorCount = "1";
var umta = "{0}.{1}.{2}.{2}.{2}.{3}".format(domainHash,randomNumber,timeStamp, visitorCount);
var utmcc = "__utma={0};+" .format(umta).urlEncode();
/* if we want to store campain data
var source = "ABC"; // needs a value
var medium = ""; //use "referral" to will mark it as refereal in GA GUI
var utmz = "{0}.{1}.1.1.utmcsr={2}|utmcmd={3};".format(domainHash,timeStamp, source, medium);
var utmcc = "__utma={0};+__utmz={1}" .format(umta, utmz).urlEncode();
*/
// Cookie values. This request parameter sends all the cookies requested from the page.
var utmu = "q~"; // This is a new parameter that contains some internal state that helps improve ga.js
var gaRequest = ("http://www.google-analytics.com/__utm.gif?" +
//"utmwv={0}&utms={1}&utmn={2}&utmhn={3}&utmcs={4}&" +
//"utmsr={5}&utmvp={6}&utmsc={7}&utmul={8}&utmje={9}&" +
//"utmfl={10}&" + "&utmhid={12}utmr={13}"
"utmdt={11}&utmp={14}&" +
"utmac={15}&utmcc={16}"
//&utmu={17}"
).format(
utmwv,utms,utmn ,utmhn ,utmcs ,utmsr ,utmvp ,utmsc ,utmul,
utmje, utmfl, utmdt, utmhid, utmr, utmp, utmac, utmcc, utmu);
return gaRequest.info().GET();
var utmdt = "Page Title".urlEncode(); // Page title
var utmp = "/Page/Path".urlEncode(); // Page Virtual Path
var utmac = "UA-37594728-3"; // Account ID
var randomNumber = "9323699"; //1000000000.random(); //;
var timeStamp = "1358127189"; //DateTime.Now.unixTime();
var utmcc = "__utma=.{0}.{1}.{1}.{1}.1;+".format(randomNumber,timeStamp);
var gaRequest = ("http://www.google-analytics.com/__utm.gif?" +
"utmdt={0}&utmp={1}&utmac={2}&utmcc={3}").format(
utmdt, utmp, utmac, utmcc);
return gaRequest.info().GET();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment