I have the following code:
var selectedLevel = true;
if (selectedLevel === true) {
var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));
try {
var pageTracker = _gat._getTracker("UA-XXXXXXX-XX"); // <-- The ID _is_ here
pageTracker._trackPageview();
} catch(err) {}
}
I am expecting to see cookies being set in FireCookie but I see nothing. The ga.js does appear to be loading in though, according to my Firebug NET tab.
Is there a reason anybody knows of why the cookies wouldn’t be getting set?
I suspect that because the try/catch block is in the same script, the line getting the tracker is being executed before the other script loads and fails because
_gatisn’t defined. Try putting it in its own script block like the Google docs suggest.