Easy question for me! Load Google Analytics in the footer!
- Because I want the best performance possible. I don’t want GA script to slow down initial rendering for things that actually appear on the screen!
- Because your site shouldn’t be loading that slow anyway between header vs footer items. If your site IS that slow, you need to fix it first before slowing it down even further.
- Because GA stats are nice but I don’t look at them THAT much. The most important thing is user experience.
Is there ever an argument for when to put GA scripts in the header?
Sure, there are some. The main one being that having the Analytics script load sooner will ensure that your users are tracked more accurately. The idea is that you don’t want to miss out on what user actions are happening before the script is loaded. There’s also the argument that loading the GA script later may increase your bounce rates because it’ll seem like your users are leaving your site faster.
For the most part, I think all the excuses are bunk. It should only be a 100-200ms difference between loading the GA script in the header vs the footer. If your visitor can decide to leave your site within that time, then was that really even a worthwhile interaction to track in the first place?
There’s also the argument that the GA script is asynchronous and doesn’t block page-render and that the script will load alongside all other JS scripts. That may be so but the still has to be read and processed and who knows what else is going on. I also like what the PagePipe guys had to say on the matter.
Don’t be silly. Load GA in the footer and get on with your life. Serve your users, not Google!
- Which plugin to load Google Analytics? I use CAOS plugin – it saves and serves the file locally from your web-server to decrease external requests from dragging down your pageload.
You could go with something like this if you need to minimize https://minimalanalytics.com .. in the footer of course .. 😉
Hey hey hey, that’s VERY COOL! Have you verified it already??? Just curious what the implications are of using this minimized script.
It would be really cool to know how to add some parameters to the coders for non-beginners like me. In particular, anonymize IP, disable add features and add adjusted bounce rate to the code.
Hi there Johnny,
It works, I use it on my WordPress sites .. You can read on the site about advanced Analytics, seems like some functions don´t work, but I am not using advanced functions in Analytics anyway so for my purpose of standard Analytics it works just fine.
Found your site a couple of weeks ago and there is some good stuff for newbies here .. Don´t have an FB account so I have not checked the FB group your active in though .. and probably won´t either since I am not on FB .. =)
Haha, thanks so much for this. I read up on it a bit at Github but I think I’m just gonna offer it to the community for them to guinea-pig it. 🙂
Haha .. You do that, why do the hard work yourself .. 😉