Google Analytics Opt Out (Block Tracking)

December 15th, 2009 by Lars Johansson

SakkTrakk (The Germanizah)—a small hakk to sakk the GA trakker


My colleague Christoffer Luthman at Mark Red has developed a small piece of code that makes it possible for website owners to offer a site-based opt-out function to visitors. It offers the possibility to block being tracked by Google Analytics on individual websites. The opt out does not work on a global level. A visitor has to opt out of being tracked by each website. The process for opting out is easy. There is simply a button to click on!

You may have seen the articles on sites like Econsultancy and TechCrunch about how Google Analytics may become banned in Germany. One of the reasons would be the lack of a possibility to opt out from being tracked without having to adjust cookie settings in the browser.

To offer a little bit of help to German website owners threatened with hefty fines we decided to make this little piece of code. It does not solve all of Google’s problems in Germany, but it’s one step in the right direction. I have written about the other points on my Swedish blog, but will leave that for now and simply focus on the opt out issue.

Test a SakkTrakk example

Download SakkTrakk now!


How does SakkTrakk work? Well, it places a cookie in the web browser for users who do not wish to be tracked. The setting in the cookie determines whether the Google Analytics tracker should be used or if the “mock object” gaOptOut.js should be used.

Implementation

Add “gaOptOut.js” within the head section of all pages:

Google Analytics Opt Out

Instead of using _getTracker(), use getOptOutTracker():

Blocking Google Analytics Script (Opting Out)

Caution: If the user deletes her cookies she’ll be tracked again until she activates SakkTrakk again. This script is provided “as is”, is free to use, and comes without any kind of warranty. Hey! it’s free, what did you expect?! You may alter the script to suit your needs. The script does currently not work if you use asynchronous tracking.

Post in German: Opt out für Google Analytics

PS. My apologies for the name of the product. My bad. I was simply inspired by the use of double k’s in German web analytics tool names. ;) You should also know that Mark Red is a big fan of Google Analytics, but we respect privacy.



Share on LinkedIn

Posted in Google Analytics, Web Analytics | 10 Comments »




Comments

  1. Achtung! Tyskarna och Google Analytics | Webbanalys Says:

    [...] Uppdaterat 15 december: nu finns det en möjlighet till opt out på webbplatsnivå [...]

  2. NIX-Webbanalys (”opta ut” från att bli mätt på Internet) | Webbanalys Says:

    [...] Uppdaterat 15 december: Opt out för Google Analytics på webbplatsnivån. [...]

  3. Tim Evans Says:

    So, you use a persistent cookie to tell GA not to set a persistent cookie, right?

  4. Google Analytics Opt-Out selbst bauen | Web Analytics News Says:

    [...] Analytics selbst bauen kann. Eine hat Marco Hassler vorgestellt und eine weitere habe ich bei Lars Johansson gefunden. Beide beruhen auf dem selben Prinzip. Man setzt einen Cookie in dem der Opt-Out-Status [...]

  5. Google Analytics Opt-Out selbst bauen | Online Marketing News Says:

    [...] Analytics selbst bauen kann. Eine hat Marco Hassler vorgestellt und eine weitere habe ich bei Lars Johansson gefunden. Beide beruhen auf dem selben Prinzip. Man setzt einen Cookie in dem der Opt-Out-Status [...]

  6. Opta ut från Google Analytics | Webbanalys Says:

    [...] engelska: Google Analytics opt out Förslag på annan läsning:Certifierad i Google Analytics (GAIQ)15 tips för Google [...]

  7. Hindra Google Analytics från att registrera rätt IP-adress | Webbanalys Says:

    [...] Samtidigt kan jag påminna om att Mark Red tagit fram en möjlighet att erbjuda besökarna opt out från att bli mätt med Google Analytics. [...]

  8. Opt out från Google Analytics | Webbanalys Says:

    [...] realistiska version: En webbplatsbaserad opt out för Google Analytics Förslag på annan läsning:Excellent Analytics v. 1.0.0.48 har nu släppts!Ny version av Excellent [...]

  9. medienmaul. » Google Analytics Opt-Out Says:

    [...] Funktion durch ein paar Tüftler (Marco Hassler an dieser Stelle und die Kollegen um Lars Johansson an jener) bereits programmiert, einsatzbereit und voll nutzbar war, dort allerdings über das [...]

  10. Opt-out, osynlig för Google Analytics | Might Know Something Else Says:

    [...] föregår alternativa lösningar (som svensk Mark Red’s fullösning) genom att släppa en egen opt-out lösning som gör besökare osynliga för Google [...]

Leave a Comment




Please note: Comment moderation is enabled and may delay some comments. There is no need to resubmit your comment. We use spam protection to filter out comment spam.