5x Faster. Introducing the New GSTC

GoSquared Tracking Code 5x Faster

We’re always improving the speed and efficiency of all components in the GoSquared system. We believe a well oiled machine is paramount to operational success. This week we decided to focus on the first point of contact between your traffic and our system: the GSTC (GoSquared Tracking Code). We’ve made it more efficient, completely unobtrusive, and up to five times faster!

As most of you already know, the GSTC is the light bit of JavaScript code you place on your website pages that invokes a separate remote script (the GoSquared Tracking Engine). The Tracking Engine then collects and sends information about your traffic to our servers, feeding our data hungry apps with information you use to visualise and analyse your traffic. We know that the performance of this code is pivotal not only to the accuracy of our reports. It is essential to the speed and efficiency of your website, and so we’ve developed the new GSTC to be as fast and as invisible as a cheetah in the desert grass.

The Vices of the old GSTC

The old GSTC was a simple snippet of Javascript code which we asked you to place at the bottom of your HTML web pages before the closing </body> tag. This was for a good reason. <script> tags “block” the page they are on from continuing to load until their linked remote script is loaded and executed by the browser, which could take anything from a few dozen to several hundred milliseconds. Additionally, if for whatever reason the remote content takes an age to respond, the page will not be allowed to finish loading until the remote content is properly loaded. This would interfere with any load event handlers on the page, and block any content underneath the script from loading. At the footer of your page this causes minimum disruption to the way your page loads. But even minimal disruption is too much!

Another limitation was the way we distributed the GSTE. The GSTC we gave you asked our servers for specific GSTE code which was customised for your particular account. Processing this information wasted valuable loading time and made average GSTE response time (and therefore blocking time) in excess of 300ms. This setup wasn’t ideal for a variety of reasons, so we decided to make things a whole lot better.

The Virtues of the new Tracker

Completely unobtrusive

This shiny new GSTC knows you don’t have time for it to get in your way. That’s why it won’t ever interfere with the way your page loads, looks and responds.

We’ve rewritten the snippet of Javascript code you place into your website HTML. OK, sure, it’s a bit longer but with every added line of code the GSTC becomes increasingly powerful. It now looks something like this:

<script type="text/javascript">
var GoSquared={};
GoSquared.acct = "GSN-0000000-X";
(function(w){
function gs(){
w._gstc_lt=+(new Date); var d=document;
var g = d.createElement("script"); g.type = "text/javascript"; g.async = true; g.src = "//d1l6p2sc9645hc.cloudfront.net/tracker.js";
var s = d.getElementsByTagName("script")[0]; s.parentNode.insertBefore(g, s);
}
w.addEventListener?w.addEventListener("load",gs,false):w.attachEvent("onload",gs);
})(window);
</script>

This code is just great, and your website will love it. It’s snugly wrapped inside a self executing function. This means it runs as soon as it is loaded and doesn’t pollute your global JavaScript namespace (apart from the GoSquared object of course, but we think you can just about spare us that). Furthermore, although the function executes as soon as the page loads, we do not perform any GSTE loading until the browser fires the “load” event. This event indicates that your page is loaded in your visitor’s browser and that the view is ready to be tracked. By eagerly waiting to do our stuff until then, your page is never prevented from loading how it normally would without the tracker there. Awesome.

Free home delivery in a few dozen milliseconds.

Bet your local pizza place can’t match that. One of the key areas of improvement is how this code invokes the GSTE. After some caffeine-fuelled tinkering of our server architecture, we’re now able to put a universal (as opposed to site-specific like the old version) GSTE on a Content Delivery Network (CDN) and have the above GSTC load and run that file directly. This means that the GSTE will always be loaded from the CDN edge location nearest to the visitor, so response & load times are always kept to an absolute minimum. In our geeky experiments, the average time from GSTE request to execution of this new code is around 66.2ms. That’s nearly 5 times faster than the old system. Yikes!

Ready for more

The new tracking system is highly extensible, and we will be developing it further in correlation with the evolution of our apps. Stay tuned for more exciting developments.

Go get her!

You can find the new GSTC in the “Tracking Code” tab of your Site Manager. We encourage you to replace the old GSTC as soon as possible. The old tracker will always work, it just isn’t as cool as the new one!

Still haven’t used GoSquared?

Sign up for a 30 day free trial now and start monitoring your website’s traffic in real-time!