Wednesday, May 16, 2012

Adding Google Analytics to Blogspot

Similar to "Adding Google Adsense to Blogspot", you need to first convert your Analytics code to html code.

In order to add Google Analytics to Blogspot, sign in to your Blogspot account, click “template”, click “edit html”, check “expand widget templates”, scroll all the way down to somewhere in the middle, right after all the stylesheet code and before the </head>, paste the followings:



&lt;script type=&quot;text/javascript&quot;&gt;

  var _gaq = _gaq || [];
  _gaq.push([&#39;_setAccount&#39;, &#39;UA-AAAAAA-A&#39;]);
  _gaq.push([&#39;_trackPageview&#39;]);
  (function() {
    var ga = document.createElement(&#39;script&#39;); ga.type = &#39;text/javascript&#39;; ga.async = true;
    ga.src = (&#39;https:&#39; == document.location.protocol ? &#39;https://ssl&#39; : &#39;http://www&#39;) + &#39;.google-analytics.com/ga.js&#39;;
    var s = document.getElementsByTagName(&#39;script&#39;)[0]; s.parentNode.insertBefore(ga, s);
  })();

&lt;/script&gt;

Replace  UA-AAAAAA-A with your own Analytics ID.

No comments:

Post a Comment