Tutorial :does Google analytics make a major effect on time to download a static web page?



Question:

I understand that by simply adding a script to the end of the body tag of a html document one makes it processable by Google analytics. My question is, is this likely to have much effect on performance (download time and server load)? Let's assume a static page of say 100k served by IIS. Thanks.


Solution:1

Will my website's appearance or performance be affected by Google Analytics?

The appearance of your website will never be affected by your use of Google Analytics - we don't place any images or text on your pages. Likewise, the performance of your pages won't be impacted, with the possible exception of the very first page-load after you have added the tracking code. This first pageview calls the JavaScript on Google's servers, which may take slightly longer than a regular page load. Subsequent pageviews will use cached data and will not be affected.

It's important to note that many websites on the internet use the same Javascript from the same location on Google's servers, so only rarely will a new user come to your site without already having that file cached locally.


Solution:2

Yes it does have a performance hit see http://dotnetperls.com/Content/Google-Analytics-Speed.aspx . To speed up its recomended that you download the ga.js file locally and call that instead,Explained here http://www.askapache.com/javascript/google-analytics-speed-tips.html.


Solution:3

Edit: Google has released Asynchronous Tracking. I haven't tried it yet, but I guess that it addresses the issues listed below.

I think Google Analytics can make a website slower because it does happe that ga.js takes noticably long to load, and this can cause some problems:

  • If you have a JavaScript that triggers on window.onload (that includes the old school <body onload=""> syntax), then it wont fire until the web page has downloade complety. Using something like jQuery's ready event might remedy this, though.

  • Most browsers do not fill in saved user names and passwords until the web page has loaded completely.

  • It is not easy for the average user to spot that a web page is simply waiting for the Analytics script to load, so they might be waiting for the little download animation to finish even though the page has essentially finished downloading.

  • You could follow niallbrowne's suggestion of downloading ga.js and serving from your own web server. But this should be a last resort, since ga.js is cached across web sites and only expires once a week.


Solution:4

Yes.

I feel browsing speed is much better since I added google analytics to addblock filter.


Solution:5

No.

If you put it at the end it will be loaded last, so even if Googles servers are a bit slow your visitors will never notice.

ga.js is 9.58k and a logging call is about 1.2k. The js will be cached after the first load (I guess even across sites?) so it's really negligible size wise.


Solution:6

Even if you put Analytics code at the bottom of your code, from a users perspective the site hasn't loaded till the little blue bar at the bottom has gone away.

This means that your site will 'feel' slower, depending on (surprise surprise) how laggy your users connection is. For Dialup users and users accessing your websites from abroad (where request lag is a higher concern) the extra request will definitely mean a slightly less responsive website.

However, given that every image, every javascript file and any other embedded object is an additional request, if you're already using a rich website layout, this is no reason not to use analytics.


Solution:7

The user's experience is definitely slowed down by GA on a slow connection.


Solution:8

Remember that not every user has fast US based connections.

If you are on a slow connection from a country outside the US, the difference is certainly noticeable.

People running slower computers or browsers outside the norm (i.e. old versions, mobile phones etc) may all be affected by the javascript execution time.


Solution:9

Sometimes I experience lags in pages that use it. I can track the problem to GA since it's the only script waiting to get loaded. I know this shouldn't happen but with some page requests it does rather randomly. Not that it usually matters since the whole page is already loaded so you can start reading. But it becomes a small problem with pages that use ajax or generaly do stuff on document ready event. So I add it to my adlock filters.


Solution:10

Take a look at what the competition says.


Solution:11

Personally I really can't see that there would be much of a difference at all, your browser would cache it after the first request and use it there after on each other page.

The script is loaded at the very bottom of the page as well so everything else should already be loaded.


Solution:12

Regarding server load, the scripts are pulled from Google's servers, not yours so there will be no noticeable server side impact. Obviously your pages will all be slightly larger than they were without the code to load the JavaScript, but you'll never notice the difference.


Solution:13

Note too I've seen GA download a little GIF file with a hash attached to it... but I doubt the size of this will have much of an affect on performance.


Solution:14

If you add the code to the bottom of the page then it probably won't make much of a difference.

If however, you want it to make no difference then I'd take a look at this link:

http://lyncd.com/2009/03/better-google-analytics-javascript/

It describes the approach that Steve Souders took to completely avoid any kind of I/O block.


Solution:15

Although downloading and running the actual ga.js is fast, what I've noticed all across Europe, on different connections/computers/OSes/browsers, is a MAJOR lag (anywhere from 0 to 30 (thirty) seconds) between the last byte of HTTP request and first byte of HTTP response.

This is understandable, given the immense popularity of GA, but this is happenning before window.onload fires. So, if your page relies on JS and your users hit this lag, they are not going to analyze which component is responsible - they'll assume your site is horribly slow.

A workaround for this is to register a window.onload function which will add the GA script. Example (using "window.onload=function()" for simplicity):

window.onload = function() {      var gaJsHost = (("https:" == document.location.protocol)                         ? "https://ssl."                         : "http://www.");      var s = document.createElement('script');      s.src = gaJsHost + "google-analytics.com/ga.js";      s.type='text/javascript';      var bodies = document.getElementsByTagName('body');      if (bodies.length > 0) {          bodies[0].appendChild(s);      } else { // this should never happen, but sometimes does (curse you IE6!)          document.appendChild(s);      }        // this says 100ms, but won't happen until ga.js is loaded      window.setTimeout(function(){          if (window['_gat']) {              var pageTracker = _gat._getTracker("UA-xxxxxx-x");              pageTracker._trackPageview();          }      },100);  }  

Note:If u also have question or solution just comment us below or mail us on toontricks1994@gmail.com
Previous
Next Post »