Some time ago I was twiddling with my blog template, when I had the "great" idea of modifying the Google Analytics tracking code such that it checks the successful loading the external script before calling the logging function, to avoid generating errors when the script failed to load (because of NoScript, hosts file entry or other reasons). So I modified it like this (warning! this contains errors!):
<script type="text/javascript">
_uacct = "UA-432874-2" if (urchinTracker) urchinTracker();
</script>
The """ encoding was needed because the blogger template needs to be valid XML. So what did I miss? The little fact that the two statements (assignment and if) were not separated by ";" or a newline, knocking out my analytics. This is not a big problem, since I'm not very interested in them, but it is still nice to have. Lesson learned (hopefully): measure twice, cut once. Now for the correct code if you wish to insert similar safeguards in your Blogger template:
The "old" style code:
<script src='http://www.google-analytics.com/urchin.js' type='text/javascript'>
</script>
<script type='text/javascript'>
_uacct = "...your tracking code here...";
if (urchinTracker) urchinTracker();
</script>
The "new" style 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'>
if (_gat) {
var pageTracker = _gat._getTracker("...your tracking code here...");
if (pageTracker) pageTracker._trackPageview();
}
</script>