Saturday, May 4, 2013

Google Analytics Tracking Not Installed

I tried to setup Google Analytics for a new blog, and the Tracking Info page kept saying "not installed". I got really frustrated, and then I noticed something.

The old code is something like:

<script type="text/javascript">

  var _gaq = _gaq || [];
  _gaq.push(['_setAccount', 'UA-<your number here>']);
  _gaq.push(['_trackPageview']);

  (function() {
    var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
    ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
    var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
  })();

</script>

The new code is like this:

<script>
  (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
  (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
  m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
  })(window,document,'script','//www.google-analytics.com/analytics.js','ga');

  ga('create', '<your number here>', '<your domain name here>');
  ga('send', 'pageview');

</script>

So I removed the new tracking code, and use the old code with the appropriate account number, and I got the "Status: Tracking Installed" message instantly.

No comments:

Post a Comment