Google Analytics have added a slight tweak to their tracking code in the past 2 days to include a try catch block, which hopefully will result in any problems arising with contacting their server will not stop the page from loading. The small tweak adds a try catch block at the end of the code.
New Google Analytics Tracking Code
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-1″);
pageTracker._trackPageview();
} catch(err) {}
Old Google Analytics Tracking Code
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”));
var pageTracker = _gat._getTracker(”UA-xxxxxxx-1″);
pageTracker._initData();
pageTracker._trackPageview();









November 14th, 2008 at 7:03 pm
It also prevents the runtime error dialog from popping in IE7.
No notice as of yet on the GA Blog. They just released enterprise-level reporting to all users, so I’m thinking they don’t want to take any attention away from this major move with such a small code tweak.
November 19th, 2008 at 6:08 pm
Just spotted this. Weird that there’s still no official mention on the Analytics blog.
November 26th, 2008 at 12:27 pm
In FF this new code creates an js error:
missing { before catch block
} catch(err)
Do you have any problems with it?