Google have updated their Analytics code again, this time adding a javascript try statement to prevent Javascript errors being displayed in the browser. This is a good thing, however, as provided by Google, this new code breaks the LiteCommerce template parser. The only solution I currently have is to wrap the Javascript statements in html comments. I had tried wrapping the Google Stats code with the CDATA method but this still breaks the LiteCommerce template parser as well (see http://javascript.about.com/library/blxhtml.htm for Javascript validation fixes).
Here is my current solution (in skins/default/main.tpl) where ****** is your Google Analytics account number and ** is your site number:
1 2 3 4 5 6 7 8 9 10 | <span style="color: #0000ff;"><script type="text/javascript">// <![CDATA[ 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">// <![CDATA[ try{ var pageTracker = _gat._getTracker("UA-******-**"); pageTracker._trackPageview(); } catch(err) {} // ]]></script></span> |