As google says:
Paste it into your web page, just before the closing
tag.
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