Kindly ignore yesterday’s post about asynchronous tracking code. After further research it was determined that we didn’t entirely know the full details of how this works with other services like Google Analytics. The code we released was simply waiting for “onload” to fire and then creating the script element that would trigger tracking. While this sort of achieves the same effect (it doesn’t interfere with your site’s loading), it definitely decreases accuracy, which is why we warned about that.
Well, forget all that, k? We just released an updated version that is truly asynchronous, and it should be more accurate, not less. Why? What we didn’t know yesterday was that if you inject a script element into the DOM, all modern browsers by default will download that script asynchronously, which means in parallel with anything else that is already downloading to a visitor’s browser. I’m embarrassed I didn’t know about this trick, but it’s true.
Taking this a step further, we modified the actual tracking code that you link to from your site so that the beacon it sends back to log data is also based on an injected script element, which means it now is asynchronous as well. Previously, we were using an image, which does not get this benefit.
We’ve been testing this new stuff most of the day for the tracking of getclicky.com, and it’s working very nicely.
So, if you do absolutely nothing, you will still automatically get the benefit of the asynchronous logging of data. You may still see “waiting for in.getclicky.com…” in your browser’s status bar, but it is not interfering with the downloading of other items from your web site.
But, if you want full asynchronicity, then go grab a fresh copy of the code from your tracking code page. This new code that you paste onto your site will also inject the tracking code script into your site’s HTML, which will give you the full benefit of this functionality.
On yesterday’s post, someone asked why we still recommended pasting it into the bottom of your site, rather than the head like Google Analytics suggests. The way the code from yesterday was designed, there was no benefit to placing it higher. But today, things are different. However, from what we have read, Google’s recommendation is incorrect. They recommend you place the async code inside your site’s “head” tag, but this code then manipulates the “head” object directly before the browser has fully parsed it. Everything I have read says you should not do that, as it can cause serious browser malfunction. If you want to place this code higher up, we recommend doing so at the very top of your body element, rather than the bottom. But we really don’t think it will make much of a difference either way.
Ok, go enjoy!