Google Tracker Extension v1.3

by Chris 4/2/2008 2:29:00 PM

I noticed at work that I end up with a javascript error whenever I looked at my website.  The error is "_gat is not defined".  Obviously this was related to the Google Analytics code so I did a little more digging.  It turns out that my work firewall/proxy is blocking access to the Google Analytics script specified:

<SCRIPT src="http://www.google-analytics.com/ga.js type=text/javascript></SCRIPT>

I confirmed this by manually connecting to the address in my browser and sure enough it was being blocked.  So when the Google Analytics script attempted to proceed with the code

var pageTracker = _gat._getTracker("UA-2400138-2");

there was a problem identifying _gat.  So it was time to provide a simple update to my Google Tracker extension to check and see if the _gat was defined before proceeding.  The result is:

<SCRIPT type=text/javascript>
if (typeof(_gat) == "object")
{
var pageTracker = _gat._getTracker("UA-XXXXXXX-X");
pageTracker._initData();
pageTracker._trackPageview();
}
</SCRIPT>

Now that I have the new Google script in place I can avoid the script errors that are displayed...  Yeah!

GoogleAnalytics-v1.3.zip (1.70 kb)

UPDATE (Aug 10th) : I have updated the code to place the Google script at the bottom of the page instead of the header. Please download the latest version.

GoogleAnalytics-v1.4.zip

Comments

Add comment


(Will show your Gravatar icon)  

biuquote
  • Comment
  • Preview
Loading




Powered by BlogEngine.NET Theme by Mads Kristensen Hosted by 1and1 Hosting Sign in
The opinions expressed herein are my own personal opinions and do not represent my employer's view in any way. © 2008 Chris Blankenship

DSCODUC on Technorati  

Stop Spam Harvesters, Join Project Honey Pot   This work is licensed under a Creative Commons Attribution-Share Alike 3.0 United States License  

Welcome to my blog

Welcome to my site

Villainy wears many masks,
none of which so dangerous as virtue…



LinkedIn   GeoURL

Recent Comments

Comment RSS

Wordle Gallery

Shelfari Book Library