Tracking in Google Analytics without Cookies or JavaScript

Google Analytics is used by around 60% of the top 100,000 websites,(1) and we’re guessing that most of our blog readers are also users. That said, while having the technology used on your website is an essential step, the insights you glean from it are only as good as the data flowing in. We know that it’s nearly impossible to ensure that Google Analytics will capture and store 100% of your users’ data with 100% accuracy – but there are way  to improve accuracy and coverage. One of those ways? Track user data into Google Analytics without cookies or Javascript. We’ve released an open source PHP code in the Github community to help you get around this. Read on to learn why this could be useful for your website.

Tracking-in-GA-without-cookies-or-JavaScript-feature.jpg

The data you could be missing out on

Google Analytics relies on two pieces of browser technology to track website users: cookies, and JavaScript. The most recent ‘Universal’ version of Google Analytics uses fewer cookies than previous versions, but still requires persistent cookie storage and retrieval to correctly distinguish users. And if JavaScript is disabled or blocked by your users, the tracking code will not run at all.

You may be tempted to assume that this is not a problem – surely very few users block JavaScript or cookies?

Actually, research in 2011 showed that in a month, around 28% of Australian web users delete their first-party cookies (the type used by Google Analytics) and the rate was even higher for third-party cookies.(2) Deleting is pretty much as good as not accepting the cookie as far as accurate tracking is concerned. Since then, there have been regulatory impositions, such as the 2011 introduction of the European Union’s ‘e-privacy directive’, bringing the issue of consent more into the open and giving powers to users.

And as for JavaScript, in 2013 UK developers working on an online government electoral registration system found that a small 0.2% of users had JavaScript blocked or not enabled on their browsers. An additional 0.9% were not having the JavaScript run at all – a total of 1.1% of users being missed by JavaScript.(3)

In short, limiting your tracking to JavaScript-running cookie-accepting users could mean that your data is undercounting and, worse, biased.

Loves Data’s Open Source solution: cookieless

Thanks to a feature of Universal Analytics called the Measurement Protocol, it is possible to to send hits to your Google Analytics account without JavaScript. Furthermore, even if it is not possible to use cookies for distinguishing individual users, one can derive a ‘good-enough’ id using a browser fingerprint.

Loves Data has developed a PHP solution to do this for you, provided your website supports PHP scripts. Just visit the Github repository and install the code on your site (or ask your web developers to do so for you). The file /track/config.php just needs some minimal changes for your configuration, such as the directory on your website where the solution will sit and, of course, your Google Analytics property id. As a bonus, the script can even send hits into your own MySQL database – just uncomment and modify the four lines in the config.php file accordingly!

A few things to keep in mind

There are all sorts of reasons why your users might block or delete their cookies, or not run JavaScript, which may have absolutely nothing to do with privacy concerns. But do remember that the reason could have been a desire to maintain control over their data. There are three things to bear in mind:

  • Legal: make sure that you do not fall foul of the law. Naturally, we are not in a position to provide you with legal advice, but for our Australian visitors, the Office of the Australian Information Commissioner has excellent advice on their website (and, by the way, if you do visit their site, you might be interested to know that they they are tracking you using Google Analytics!)
  • Contractual: remember that you have agreed to your Google Analytics terms of service. As we write this blog, section 7 requires that you post a privacy policy which discloses your ‘use of Google Analytics and how it collects and processes data’. It also requires that you do ‘not circumvent any privacy features (e.g., an opt-out)’, so don’t use the solution posted in this blog if your users have opted out of tracking on your site, for instance if they choose not to tick a ‘consent to tracking’ pop-up on your site.
  • Ethical: the ethical considerations are, naturally, ones for each organisation to consider individually. But we would remind you that cookies and JavaScript are often blocked or unavailable for all sorts of reasons that are nothing to do with privacy or the conscious choice of your users.

We’d love you hear your views, and your success stories if you have deployed this solution. Tell us in the comments below.


1 Source: trends.builtwith.com/analytics/Google-Analytics, May 2015
2 Source: ‘The Impact of Cookie Deletion on Site-Server and Ad-Server Metrics in Australia’, comScore Inc., 2011
3 Source: https://gds.blog.gov.uk/2013/10/21/how-many-people-are-missing-out-on-javascript-enhancement/