2
votes

I my website currently has traditional (non-async) Google Analytics tracking code at the bottom of the body.

<script type="text/javascript">            
    var gaJsHost = (("https:" == document.location.protocol) ? "https://" : "http://");
    document.write(unescape("%3Cscript src='" + gaJsHost + "stats.g.doubleclick.net/dc.js' type='text/javascript'%3E%3C/script%3E"));           
</script>

I am planning to upgrade to the Universal Analytics tracking code. Can the new tracking code go in the body or should it be only placed in head (just before the tag) as stated by Google? Thanks.

1

1 Answers

3
votes

Google says in Set up the web tracking code

Paste your snippet (unaltered, in it’s entirety) into every web page you want to track.
Paste it immediately before the closing </head> tag. If you use templates to 
dynamically generate pages for your site (like if you use PHP, ASP, or a similar
technology), you can paste the tracking code snippet into its own file, then include
it in your page header.

I know of people who have put it in the body as well at the bottom of the page, so yes you can put it in the body if you want. It will still work. Personally I always put it in the header, if Google recommends it they must know what they are talking about.