Forum Moderators: Robert Charlton & goodroi

Message Too Old, No Replies

Should you host Google Analytics locally?

         

goodroi

1:34 pm on Mar 21, 2018 (gmt 0)

WebmasterWorld Administrator 10+ Year Member Top Contributors Of The Month



Speed's influence on SEO keeps growing. There are many direct & indirect reasons why smart SEOs care about speed. In this chase for speed is it smart to locally host Google Analytics? Google does not recommend this. They do update this code and if you host it locally you now need to ensure your site is constantly up to date. Thankfully there are plugins and notifications to help you keep current. If you host it locally you can potentially remove a costly third party call.

Do you think smart SEOs should be hosting Google Analytics locally?

robzilla

2:55 pm on Mar 21, 2018 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Thanks for the reminder, I should probably update the file... I see it's been almost 2 years.

[minutes later] Whew! It's grown from 27580 to 35943 bytes, or 11505 vs 14623 after GZIP. Uncool.

So yes, I do host it locally, but that has nothing to do with SEO, I just find it pointless to fire an external request for something that I can get to the client faster with HTTP/2. And I can cache it for longer than 2 hours, which is the time that Google seems to be setting. However, I don't think it visibly affects speed, so I wouldn't necessarily recommend hosting it locally. Either way is fine.

Analytics was working just fine before I updated the file, so the changes appear to be backward compatible.

I'm still using analytics.js, though. The gtag.js implementation differs a little, but the help page [support.google.com] only talks about code updates so I suppose that too should work locally. I see no real incentive to switch, and the gtag.js file size is 2x that of analytics.js.

MayankParmar

9:54 pm on Mar 21, 2018 (gmt 0)

WebmasterWorld Senior Member 5+ Year Member Top Contributors Of The Month



I do host it locally as for some reasons Google Analytics used to get stuck on 'waiting...', increasing the load time.

I'm using a WordPress plugin for the same.

"you now need to ensure your site is constantly up to date"

ummm... what? :-/

robzilla

10:51 pm on Mar 21, 2018 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



He means you need to keep the Google Analytics script file up-to-date. You could easily automate that, though.

JesterMagic

1:44 pm on Mar 22, 2018 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



I've thought about doing it along with the social buttons like the Like and Tweet buttons.

In the end I decided against it as I didn't want to worry about maintaining the scripts. Google's own Page Speed tools complain about it but I figured Google wasn't worried to much about their own scripts.

I never understood though why they only cache the files for 2 hours...