Google analytics in header or footer?

Put it in your header. It's asynchronous so it won't block your page from loading and by placing it in your header you'll be more likely to get a accurate stats.


This what google says about it:

Once you find the code snippet, copy and paste it into your web page, just before the closing </head> tag*. If your website uses templates to generate pages, enter it just before the closing tag in the file that contains the section. For the best performance across all browsers we suggest you position other scripts in your site in one of these ways:

  1. before the tracking code snippet in the <head> section of your HTML
  2. after both the tracking code snippet and all page content (e.g. at the bottom of the HTML body)

and here comes the *:

*One of the main advantages of the asynchronous snippet is that you can position it at the top of the HTML document. This increases the likelihood that the tracking beacon will be sent before the user leaves the page. It is customary to place JavaScript code in the section, and we recommend placing the snippet at the bottom of the section for best performance.