View Full Version : Google Analytics JS slows site?

06-22-2009, 01:14 AM
I've noticed that my site has been loading slower lately, especially in google images. I'm thinking that this could be due to the google analytics javascript. I was told that page load slows down if its placed on top (which I have). Is this true? I'm not really warming up to GA but I also don't want to nix it completely. Bottom placement doesn't work for me as GA does not record then.

06-22-2009, 03:56 PM
You are contacting a 3rd domain and their servers can be slow at times. If it is at the top, your page has to wait until it is resolved and returns data.


06-23-2009, 03:45 PM
Bottom placement doesn't work for me as GA does not record then.

Yes it does, unless you have frames or something odd that prevents it from tracking correctly.

However, since the code isn't in the HEAD section of the code, your visitors can move around your site before the GA code has finished executing (thus not tracking). Google actually recommends that you stick the tracking code at the bottom of your page.

A1ien51 got it right - since you're waiting for a response from the Google server, your loading time is dependent on (1) your visitors internet speed, and (2) Google's current bandwidth. You'll encounter this with any JS-based analytics tool, so if this issue is critical then just install a server log-based application. Google Analytics is far from perfect, but I think it's an awesome tool considering it's free.

As smart as those people at Google seem to be, I've also noticed that in a lot of their APIs (Analytics, AdSense, and Maps to be specific) they use a gazillion global variables rather than creating a single Google namespace object. While this wouldn't slow anything down, it does lead me to believe that their code isn't engineered as well as it could be or that it simply hasn't been optimized. As a result, the files might be bloated and take longer to download.

Of course I don't work at Google, so maybe I'm just missing something. :p

06-23-2009, 06:39 PM
Don't get rid of Google Analytics!! It's such a resourceful tool if you utilize the priceless information provided in the statistics. You can really determine where your advertising money is spent the best. I've always only put GA at the bottom of my webpages and have never had a problem with sites loading because of it. If you have any questions about GA reports/statistics/basic info specifically, don't hesitate to contact me. I'd be happy to help you.