Update: this project now has its own GitHub repo: https://github.com/davidmurdoch/ga-localstorage
TL;DR:
Click here to make the web faster. Oh, and share on Twitter, too!
TL;RA:
In 2010 I postulated on Stack Overflow that it may be possible to use Google Analytics without the baggage its cookies bring.
The problem is that when you add Google Analytics to your website you also add up to 250 bytes of HTTP Cookies to every single HTTP request on your page's domain. You may also be sending some of these cookies in requests to subdomains, as well (about 30 bytes worth).
As of September 1 2014 HTTP Archive reported that the average number of requests per page is 98. If we assume the worst case, that all requests are on the same domain, that amounts to nearly 25,000 (98 × 250 = 24500) uncompressed bytes sent on every page load, for absolutely no reason. (When using HTTP 2.0/SPDY domain sharding is usually considered a performance anti-pattern, so this worst-case scenario may become common). To make matters worse, most users' upload speeds are abysmally slow, especially over 3G.
After nearly 3 years of that Stack Overflow question being unanswered Elmer came along and provided a working proof-of-concept. Being the HTML5 Boilerplate advocate that I am, I immediately opened an issue on GitHub and started down a path to tweak the Google Analytics snippet to accomplish two goals:
- be smaller (in relation to the original snippet + its cookies)
- be cookieless (in browsers that support it)
Now that this issue is the oldest open issue on the project, I think it is time I do my part and wrap it up. Hopefully all that is left for us to do is test the implementation. If you want to help, go here (//davidmurdoch.com/google-async-analytics-using-localstorage-test/) and get your friends, colleagues, partners, and family to visit as well. If you have the time, please open it in different browsers and devices.
As Smokey the Bear once famously quipped:
Only You Can Prevent Unnecessary Bytes in Request Headers
(or something like that).
If you'd like to be added to the list of users who can read and analyze the captured tracking data, send your email address to .