Cookie Consent: Tracking everyone except Europe

Asad Zulfahri
3 min readAug 28, 2020

TLDR? I use Legal Monster for cookie consents and have created a simple solution to enable tracking for users worldwide except for Europe. You can find the full code on my GitHub repo: Legal Monster Consent non-EU bypass

As a digital marketer, user tracking & analytics is important in my line of work. Personally, I consider the ePrivacy, GDPR, and other similar privacy laws as government overreach. The spirit of the law is good but the specific and mostly confusing legal language is simply a joke.

It was intended to protect users’ privacy, and I get that. However, with the competitive digital landscape, it’s making it more difficult for marketers to analyze websites’ performance. The tools that I use such as Google Analytics, Live Session, Albacross, and others make it easy for me to analyze content performance and make iterative improvements for the benefit of my readers.

Yes, I don’t deny that there are some bad apples out there, but do you really think if someone is trying to steal your data, they would care about complying with privacy laws at all?

Legal Monster: Cookie Consent Manager

With ePrivacy, GDPR, PDPA coming into effect, and governments starting to crack down on non-complying sites, there have been hundreds (if not thousands) of cookie consent manager solutions out there. I’ve lost count on how many tools I’ve tried, but in the end, I’ve come up with a simple solution to comply with the law.

Legal Monster is by far the simplest and easiest cookie consent manager to implement on a website. Their free plan (which I use) supports the following features:

  • Free cookie widget
  • Up to 100 pages scanned
  • 1 domain
  • Cookie scan interval: 14 days
  • Audit Trail
  • Supports multiple languages (Danish, German, Dutch, English)
  • Do Not Track support
  • Free Cookie Policy template

The problem with free cookie consent managers

Realistically, the European Union legislative body is only one out there really active in pursuing non-complying websites. And for most global sites, traffic from Europe represents 40–50%. Ok fine, we can still track the rest of the world, right? NOPE! With free consent managers, that is not possible out of the box.

The common issue with free solutions out there is that they lack the ability to detect a user’s location. This means, by default you are potentially losing 100% of user tracking data.

The free cookie consent manager with location detection

So I’ve come up with a simple JavaScript code to enable the Legal Monster cookie consent widget ONLY in Europe. It uses a simple JavaScript code to detect the user’s system timezone. If it detects that a user’s timezone is based in Europe, it will enable the widget, and if not, it will leave Legal Monster disabled for the rest of the world.

The code

<!-- Legal Monster Consent non-EU bypass by AsadZulfahri.com -->
<script>
userTZ = Intl.DateTimeFormat().resolvedOptions().timeZone;
checkTZ = userTZ.indexOf('Europe');
if (checkTZ !== -1) {
console.log("User is in Europe. Activating Legal Monster!");
document.write('\x3Cscript>!function(){var i,e,t,s=window.legal=window.legal||[];if(s.SNIPPET_VERSION=\'3.0.0\',i=\'https:\/\/widgets.legalmonster.com\/v1\/legal.js\',!s.__VERSION__)if(s.invoked)window.console&&console.info&&console.info(\'legal.js: The initialisation snippet is included more than once on this page, and does not need to be.\');else{for(s.invoked=!0,s.methods=[\'cookieConsent\',\'document\',\'ensureConsent\',\'handleWidget\',\'signup\',\'user\'],s.factory=function(t){return function(){var e=Array.prototype.slice.call(arguments);return e.unshift(t),s.push(e),s}},e=0;e<s.methods.length;e++)t=s.methods[e],s[t]=s.factory(t);s.load=function(e,t){var n,o=document.createElement(\'script\');o.setAttribute(\'data-legalmonster\',\'sven\'),o.type=\'text\/javascript\',o.async=!0,o.src=i,(n=document.getElementsByTagName(\'script\')[0]).parentNode.insertBefore(o,n),s.__project=e,s.__loadOptions=t||{}},s.widget=function(e){s.__project||s.load(e.widgetPublicKey),s.handleWidget(e)}}}(); legal.widget({ type: \'cookie\', widgetPublicKey: \'YOUR-WIDGET-KEY-HERE\', });\x3C/script>');
console.log("Legal Monster activated!");
}
else {
console.log("User not in Europe. Tracking enabled!");
}
</script>
<!-- END Legal Monster Consent non-EU bypass AsadZulfahri.com -->

* Remember to replace YOUR-WIDGET-KEY-HERE with your own Legal Monster widget key.

The full implementation instructions are available on my GitHub repo: Legal Monster Consent non-EU bypass

What do you think about all of the privacy laws that are being put in place? Do you believe it is really effective and has measurable results in combating personal data abuse? Let me know!

--

--

Asad Zulfahri

Freelance Technical SEO Consultant. Previously @Zapier @Monster. Internet ninja. Food lover. Certified introvert. Music advocate. World Traveler.