If you want to use Google Analytics to track your website traffic, hopefully you are using a good website builder that lets you do this easily in seconds, or you have coded your website with “php includes” – because you will need to include this on every webpage that you want traffic statistics for! This can be very tedious otherwise – and just think you will have to repeat the process whenever Google upgrades the coding! No worries if you are using Ultimate Web Builder software…You can do this with one easy step on UltimateWB, using the Ad(d)s app.
Ok, so now onto the title question, where should you put the Google Analytics code? Google now recommends you place the code before the “</head>” tag. The recommendation used to be to place it before the “</body>” tag, due to possible issues of the javascript coding stalling your webpage to load. But they have changed their coding since. You can really copy/paste the Google Analytics code anywhere on your webpage that you want – in its own section, not in the middle of text or other coding block, of course.
Using UltimateWB software, to place the Google Analytics code right before the “</head>” section as recommended by Google, just copy/paste the code into the Ad(d) named “In head section, right before end head tag”. Then the software does the rest. If you are using the WordPress blog app integrated in UltimateWB, then you can take care of the Google Analytics code placement in both your website and WordPress easier and faster by placing the code in a new Ad(d)s on your UltimateWB website admin panel. Then copy/paste the generated Placeholder Text into your header file or footer file (List Pages > Edit Page) – both of these page sections are incorporated in your UltimateWB integreated WordPress blog. Otherwise, you would have to follow separate instructions for incoporating it in your WordPress blog pages.
Does it make a difference where you put the Google Analytics code? The higher up in the page you put the Google Analytics code, the sooner the traffic statistics program gets the visitor hit. If the website visitor quickly leaves the page before the Google Analytics code is loaded, their visit won’t be counted by Google. …Probably don’t want to count that anyways, right?!
Related: Google Analytics vs Awstats – which is better, more accurate, useful?