Jan 20, 2009 114 reads by Navneet Kaushal

Google Analytics has come up with an update on the code snippet that is placed on websites. The update is done to fix the rare display of a JavaScript message that was usually noticed by the users to sites using Google Analytics.

But why was it changed?

“Adding the try and catch to the snippet removes the possibility that your visitor sees a JavaScript message that doesn't apply to her. It's a fairly rare occurrence because messages like these (frequently in the form of an alert box) can only appear if JavaScript messaging has been enabled on the browser. Most browsers have JavaScript messaging turned off by default, but sometimes people unintentionally turn it on. For those visitors who have enabled messaging, the try and catch will have the effect of halting any messages from the Google Analytics tracking code snippet.”

<script type="text/javascript">
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"));

<script type="text/javascript">
try {
var pageTracker = _gat._getTracker("UA-50020-1");
} catch(err) {}

You just need to log into your Google Analytics account to access your account-specific code snippet.

Navneet Kaushal

Navneet Kaushal

Navneet Kaushal is the founder and CEO of PageTraffic, an SEO Agency in India with offices in Chicago, Mumbai and London. A leading search strategist, Navneet helps clients maintain an edge in search engines and the online media. Navneet's expertise has established PageTraffic as one of the most awarded and successful search marketing agencies.
Navneet Kaushal
Navneet Kaushal
Most popular Posts
Upcoming Events
  • Events are coming soon, stay tuned!