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?
February 4th, 2009 at 12:20 pm
Same ^^
missing { before catch block
[Break on this error] } catch(err)
March 27th, 2009 at 11:35 am
Hi guys,
try to replace
} catch(err) {}
with
} catch(err) { }
and see what happens
August 21st, 2009 at 11:58 am
This error occurs if you’re using smarty without {literal} tag
January 31st, 2010 at 11:21 pm
Thanks Chris,
That extra space got rid of the error.
Greetings.