Posted on April 25, 2009 - by Dr. Div
Google Analytics Tracking Code Gets an Update: Try/Catch
Google Analytics recently made a revision on its tracking code (GA) and added the try/catch function at the end of the the code to possibly prevent any error messages or “Exceptions” from being displayed to end users. If you’re using Google Analytics on your website, I recommend updating your tracking code by copying from the code from your Google Analytics Account > Analytics Settings > Profile Settings > Tracking Code.
<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>
<script type="text/javascript">
try {
var pageTracker = _gat._getTracker("UA-XXXXXXX-X");
pageTracker._trackPageview();
} catch(err) {}
</script>
Dr.Div
