Google Analytics Opt-Out Per Site Browser Extension
Categories: analytics
We’ve recently launched the first version of a Chrome browser extension “GA Opt-Out (Per Site)“, so I thought I’d write up a quick post explaining how it works and why we built it.
What it does
GA Opt-Out Per Site (which I’m going to now call “GOOPS” for the rest of this post, sorry…) blocks GA on a per-site basis. No shocker based upon the name, right? The part that’s a little different is that it doesn’t just block requests to the GA domain(s), it does an internal browser redirect to an empty local file. So you can still see the requests that a particular GA install would have made, but there’s no data sent to Google.
In other words, you can view & debug GA on a site you’re working on without polluting the property with your own traffic.
For example:
https://www.google-analytics.com/g/collect?v=2&tid=G-XXXX... becomes a 307 internal browser redirect to
chrome-extension://demdlmljiclkdffdgioafjfidbeegccn/null-hit-sink.txt
the null-hit-sink.txt file is just a blank file in the extension package.

This means you can still see the measurement protocol requests in Chrome DevTools or even tools like David Vallejo’s Analytics Debugger. Not in the GA4 DebugView of course, since there’s no data reaching the GA4 property.
The extension looks for any requests that match “/g/collect” with “tid=G-“, which means it’ll squelch requests to the regular GA domains like google-analytics.com but also server-side implementations that keep the same GA measurement protocol format like https://sgtm.example.com/g/collect?v=2&tid=G-XXXX.
If you’re using a server-side implementation designed to avoid client-side detection, then naturally GOOPS can’t detect that.
If you want to see more details on how it works, the code is open source:
https://github.com/jhpacker/ga-optout-persite
Why we created it
The problem of excluding internal traffic is evergreen, and this is just another tool in that toolbox of things like: IP filter exclusions in GA, GTM filters, login-based excludes, etc. However we hope the utility to analysts is self-evident! Especially when dealing with lower-traffic websites, nobody wants to have to explain to clients why the 17 checkouts that showed up in GA yesterday were actually just you testing stuff.
I’d had this idea years ago, but it was never worth our time as a small agency before to put the effort into building an extension. until Claude Code made it so much easier. It’s not a highly complicated extension, but it’s still a lot more complicated than the Google-provided GA Opt-out which at its core is just one line of JS:
(function(){window._gaUserPrefs={ioo:function(){return!0}};})()
which sets “ioo” (Is Opted Out) to true and then relies upon gtag.js to check for that and bail out if it sees it.
We’d also like to thank our partner agency Konetiq for help with development.
No comments yet.