How to Bypass Ad Blockers with CAOS for Google Analytics

Ad Blockers, a thorn in the side of every online business. Wouldn’t it be great if we could bypass those Ad Blockers and keep our Google Analytics data accurate?

That’s what Steve from Its420somewhere.com thought, when he contacted me with a well-researched feature request for CAOS. A stealth mode to bypass (most) ad blockers. Today I’ll show you the base principles of bypassing Ad Blockers and protecting your Google Analytics data with CAOS.

Why should I bypass ad blockers?

Before we dive into the how’s, the why might be a better place to start.

We can all agree that trustworthy analytics data is key for any online business. You, a business/blog owner, want to know your customer/visitor.

A graphic showing more accurate Google Analytics data. A signifant increase of traffic.
Using CAOS’ Stealth Mode gave me more accurate Google Analytics data.

I respect the choice to use an ad blocker on the internet. I use it too. To protect my privacy, but more importantly, to protect my system. Advertisements are often injected with malware. That’s one of the reasons why I removed the advertisements on this site a few months ago.  To protect you, my guest.

Then isn’t it a dangerous practice to bypass ad blockers? In case of advertisements and/or malware, yes. In case of Google Analytics, no. As long as it is used responsibly. This means:

How does an Ad Blocker work?

Each ad blocker uses a different approach.

In earlier versions, CAOS already circumvented the easier ad blockers, since they’d only block files loaded from google-analytics.com. Hosting analytics.js locally resolved that.

Nowadays most ad blockers (including the tracking protection built into browsers) will simply block all requests made to blacklisted domains, such as google-analytics.com, while some extensions block files ‘intelligently’ — based on the content of a file.

We can work around the first approach with relative ease, while attempting to crack the latter means crossing some serious ethical boundaries.

  • The Wait is Over.

    Get the Newsletter you've always wanted, now!

    Sign up to receive Biweekly, Free Optimization Tips for WordPress.

    No spam. I promise.

  • How to Sneak your Data past Security

    It’s starting to sound like I’m teaching you how to smuggle USB sticks across the border. You wish! But while we’re on the subject: peanutbutter.

    Most ad blockers block all requests to blacklisted domains. This is exactly where its weakness lies. It can’t (and shouldn’t) block requests to the current domain, because that would cause some serious errors — rendering the ad blocker itself unusable.

    Exploiting this weakness is best explained using this stunning illustration, made by yours truly — autographs after the show, please:

    How to Sneak Google Analytics Data past Ad Blockers
    You can protect your Google Analytics data by making a detour through your website’s server.

    Usually, the webpage instructs the browser to make a request to google-analytics.com/collect?a=1&b=2&etc=etc. The ad blocker ‘sees’ this request and says: nuh-uh!

    To bypass the Ad Blocker, we need to send Google Analytics’ data through the server hosting the website. We instruct the browser to make a request to yourdomain.com/collect?a=1&b=2&etc=etc and that request is proxied to Google Analytics’ Measurement API — through the backdoor, so to speak — where the ad blocker is not present.

    Prevent Ad Blockers from Blocking Google Analytics Data with CAOS

    At this point, you must — you should, actually — be thinking: what an amazing idea — and an even more amazing person! How do I get my hands on this?

    Well, If you’re already using CAOS, you might’ve noticed the new Stealth Mode Lite in the plugin’s settings.

    CAOS Stealth Mode Lite is visible under CAOS' Extensions tab.
    Simple check the box, save changes, manually update analytics.js and you’re ready to go!

    Since v2.7.0 CAOS is officially the only Google Analytics plugin for WordPress with Stealth Mode technology, allowing you to bypass ad blockers and browser built-in tracking protection, preserving your precious Google Analytics data.

    Stealth Mode Lite bypasses some, less agressive and/or intelligent ad blockers. The Super Stealth Upgrade for CAOS intelligently bypasses all Ad Blockers.

    But that’s not all, both flavours of Stealth Mode Technology can be used in compatibility mode. This means that you can use it combined with Monster Insights, WooCommerce GA Integration and all other Google Analytics plugin supported by CAOS! Go ahead, download CAOS now and try Stealth Mode Lite or, purchase CAOS Super Stealth Upgrade.

    Daan van den Bergh

    Daan van den Bergh is a carefully seasoned web developer. His methods consist of thinly slicing your website’s beef and serve you with a platter of the best performance carpaccio on a bed of rocket — the only thing he’s more passionate about is food. Hire him at ffwp.dev.

    3 thoughts on “How to Bypass Ad Blockers with CAOS for Google Analytics”

    Leave a Comment

    This site uses Akismet to reduce spam. Learn how your comment data is processed.