Hi all,
I use a theme from WooThemes at one of my sites, and they place the Google Analytics tracking-code at the very bottom of the pages, just before the closing body-tag as shown at the end of this post.
However Google says the tracking-code should be placed just before the closing head-tag, when you read their documentation on the Analytics website.
I see EllisLab places the code at the bottom here on the forum-pages, just like the WooTheme does, but they place it at the top as Google recommends on the front-page for example.
So my question is: Is there anything special when running EE, that makes it better to have the tracking-code at the bottom? Or does it not matter the least? If it doesn’t matter, it seems strange that so many EE-sites have it in another place than Google recommends. So I bet there is a good reason behind this, and I’d love to learn more about it.
So if anyone has the time to explain this to me, I’d be very grateful 😊
EXAMPLE FROM A WOO-THEME:
... footer code above this ...
[removed]
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-TEST-X']);
_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[removed].insertBefore(ga, s);
})();
[removed]
</body>
</html>