"_gat not defined"
Google Analytics causes some errors (visible by seeing the 'Done, but with errors' type of message in lower part of Internet Explorer 7, or Firebug in Firefox.
Looks like the Google script does not validate if the actual tracking script is already loaded before it is executed.
There are several fixes and work-arounds out there, but I tried several and this is the only code that ultimately worked for me:
<script src="http://www.google-analytics.com/ga.js" type="text/javascript"></script>
<script type="text/javascript">
if (typeof(_gat) == "object") {
var pageTracker = _gat._getTracker("UA-XXXXXX-1");
pageTracker._initData();
pageTracker._trackPageview();
}
</script>
Be sure to replace the "UA-XXXXXX-1" with your Google Analytics account number, and also insure the carriage return does not add any extra spaces.
2 comments:
worked for me. Thanks for sharing.
For me this means that the code simply isn't run - put an alert in the if block. How many other people will this not run for? Not a great solution. Doesn't work for me in IE, or FF, with no ad-blocking... Any solutions? http://www.ralphcapper.eu/2008/new-google-analytics-code/
Post a Comment