Posted Thursday, 17 September 2009 at 22:38 by Andrew Liu
Tagged: Google Analytics
Read more blogs...
One point of interest, that I only recently found out by accident, was that Google Analytics actually causes the browser to load a "GIF" file in the browser. Whats interesting (to me, as a programmer anyway) is:
- The GIF is a valid GIF of 1x1 size, as it should be, so that it is seen as a valid image file by browsers, and probably by image scanners as well.
- The GIF is 35 bytes in size. Smaller than my spacer GIF (which is 43 bytes).
- If the GIF doesn't load, then Google Analytics doesn't track the visit! I found this out the hard way when I was trying to load the Google Analytics code on DOM load. Make sure the GIF is loading!
- Having thought about it (for about 2 minutes), this is probably the best way to implement the tracker. The URL generated to load the GIF is always unique, so there is no chance of caching on the client side. This means that there must be a HTTP call, and Google would then process the call. It also (possibly) allows the google tracking code to be cached by the browser (so long as the URL generated by the script is always unique, which, if based on a time routine, it probably is).