Senin, 16 Maret 2009

Back to Basics: Quick tracking code fixes

While browsing through some of the entries in the Google Analytics Help Forum, I found a useful thread on how to troubleshoot tracking code errors. Borrowing heavily from the conversations in the thread, I've summarrized the top ways to fix your tracking code here on the blog. Hopefully, after reading this post, you'll never have to return to work after the weekend to find that you have no data in your Analytics account! 

·  Make sure you have your Google Analytics Tracking Code installed on your site by checking your site's page source. I know, it seems obvious -- but it's actually one of the most common implementation errors our users encounter.

·  Remember to enter the code somewhere between the <body> and </body> tags, preferably towards the </body> tag.

·  Get rid of unnecessary line breaks in your code. Copy the tracking code exactly as it's generated from within your 'Instructions for adding tracking' page. For example,

         document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js

 type='text/javascript'%3E%3C/script%3E"));


should be: 

document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));

·  Having more than one Include filter in a profile may cancel out data collection for that profile. Try removing extra Include filters so that you've only assigned a maximum of one to your profile.

·  Try adding the "{}" after the "catch(err)" in your code. Although modifying the tracking code with this new addition is optional, doing so adds the benefit of removing a JavaScript error message for visitors who unintentionally have JavaScript messaging enabled on their browsers. 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.

An example of the try and catch block is below: 

<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-50020-1");
  pageTracker._trackPageview();
  } catch(err) {}</script>

If you don't believe in the wisdom of crowds, hang out in our Google Analytics Help Forum and you may change your mind. Try asking a question on it or browse through other posts answered by our community of savvy Analytics users (we love you guys!).

Tidak ada komentar:

Posting Komentar