With your own GA requests, don’t exclude, rewrite

Just a quick thing that came up in a linkedin post. If you are working on a website and want to exclude yourself from Google Analytics tracking you have a number of options – exclude filters in the GA interface, various ways of blocking your own calls via the Google Tag Manager (the extremely worthwhile Lunametrics blog has an article on this), using Ghostery or similar  or installing the official opt-out browser extension.

I find filtering and GTM exceptions a  bit cumbersome, and in general blocking means that you can no longer debug your Google Analytics code since either is is not executed in the first place or the http response is blocked (leading to error messages).

So in my opinion (as always your mileage may vary) the best way is to use a local http proxy to redirect requests to the Google Analytics endpoint (google-analytics.com/collect) to limbo and still return a http 200 status. I use the Charles proxy on a Mac (not exactly a recommendation, but it does the job) and redirect via the “map local” tool (from the “tools” menu) to redirect to a local file on my computer (I use a small image file, but I guess I could map a script that logs the request to a file if I needed to).  Charles then returns a 200 status. Now I can use the Tag Assistant (which has a nifty recording feature to monitor subsequent requests) and/or the GA debugger and still be excluded from GA tracking.

Leave a Reply

Your email address will not be published. Required fields are marked *