How to add the new Google Analytics snippet in Blogger

Google released today a new Google Analytics Snippet. It's a whole new alternative way to track website visitors. Here's how to install Asynchronous Tracking snippet in Blogger.
  • Login to your Blogger account. In your Dashboard, go to Layout > Edit HTML and make a backup of your template so you can revive everything just in case something bad happens.
  • Now, remove your existing tracking snippet like the urchin.js snippet. Google does not recommend using both snippets together on the same page. If you're done, proceed to the next step.
  • Find </head> using Ctrl+F and then add the following code before </head>:
<script type="text/javascript">

    var _gaq = _gaq || [];
    _gaq.push(['_setAccount', 'UA-XXXXX-X']);
    _gaq.push(['_trackPageview']);
    (function() {
      var ga = document.createElement('script');
      ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
      ga.setAttribute('async', 'true');
      document.documentElement.firstChild.appendChild(ga);
})();

</script>
  • Do not Save yet. You have to replace UA-XXXXX-X with your own web property ID. To do that, right-click My Account > Open Link in New Window > Analytics. Make sure to select the right Website Profile. If you don't have one, create a Website Profile.
  • Copy your web property ID, which is located beside your Website Profile Name, and then paste it in the code replacing UA-XXXXX-X.
  • Save your template and you're done.