The Google Analytics setup instructions state:
This tracking code snippet should be included in your site's pages so that it appears at the bottom of the page's HTML (or generated-HTML) structure, before the closing <body> tag.
Does their code snippet require this placement to function fully, or does Google suggest this solely because it improves page load performance to have scripts at the bottom?
It's just to improve page load performance. If this code were at the beginning, then if for some reason the analytics code ran slowly, the rest of the page would wait for it to finish or timeout before loading.
The analytics code likely makes queries to Google's servers, so they have to wait for the servers to respond before finishing. If (god forbid) Google's webservers were to be backed up or lagging, this would seriously impact the load time of your website.
There is an article on Better Google Analytics JavaScript that doesn’t block page downloading. See related How do I dynamically load Google Analytics JavaScript? question on SO, too.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With