Should I put the Google Analytics JS in the or at the end of ?

Putting it at the end of the <head> section helps ensure the your metrics are tracked even when a user doesn’t let the page finish loading.

They used to tell you to put it at the bottom of the page, before they added support for handling partial loading of pages.

Directly from Google:

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 <head> section,
and we recommend placing the snippet
at the bottom of the section
for best performance.

See Google Analytics Help: Add the tracking code directly to your site

Leave a Comment