How to use Google Analytics to track your adblock rate

Code to symbolize the script needed to track one's adblock rate

Usage of adblock tools and extensions has been on the rise over the last decade.

eMarketer estimated that there would be more than 76 million adblock users. According to our own adblock report, we discovered over 843 million monthly adblock users across the globe for the same timeframe.

Typically, we see publishers with an adblock rate ranging from 10 to 40%. To put that in perspective, in our analysis on publishers in the top 5 IAB verticals and geos ranked by adblock rate, we discovered that US publishers like ESPN could be losing close to $3.3M annually due to adblocking.

Now, before we start looking for ways to recover adblocked revenue, let’s take a step back.

Ask yourself, “How much of my ad revenue is currently lost to adblockers?” The tricky part about measuring your adblock rate is that it’s influenced by a number of factors, such as your,

  • Traffic geos
  • Number of ads on the page
  • Industry vertical
  • CPMs
  • And more

While we did say that it was tricky, it’s not impossible to track. Luckily, we can use Google Analytics to measure your adblock rate.

Most website owners leverage Google Analytics to understand where their traffic is coming from or identify their most popular content. However, it can also be used to track adblock users.

There are 3 steps involved with tracking your user’s adblock usage via Google Analytics. We found that the easiest way to implement the following steps was through Google Tag Manager. If you haven’t already done so, we would suggest setting up Tag Manager first.

Step #1: Setting up a custom event trigger in Google Tag Manager

We’ll first need to generate a custom event trigger. This will allow you to view the data created by the script found in Step 3. Here’s how to create a custom event trigger:

  1. Click Triggers from the menu on your left and select New.
  2. Click Trigger Configuration and scroll down to choose the Custom Event trigger type.
  3. Enter a name for your trigger. We used AdBlocker for our event name. Don’t forget this name (and the syntax) as we’ll need it for Step 3.
  4. Select “use regex matching” so this field will be able to handle regular expressions.

Step #2: Setting up a custom event tag in Google Tag Manager

Every trigger must be associated with its corresponding tag.

In this step, we’ll be creating a Google Analytics event that will record the number of times an adblocker was detected. Every event requires at least 2 components: Category and Action. You can specify your event further by adding an optional Label and Value field. Here’s a refresher on how to categorize your events.

Typically, events are fired based on link clicks, video plays, form submissions, and specific page visits. Our event will be recorded as page visits.

Now, let’s create a custom event tag:

  1. Click Tags from the menu on your left and select New.
  2. Click Tag Configuration and choose Google Analytics: Universal Analytics. As a reminder, Universal Analytics will be deprecated next July. Instructions on how to set up a GA4 event will be provided closer to the switchover.
  3. Update the Track Type to Event.
  4. Input your Category and Action values. While it is optional, we’ve added a Label to our example.
  5. Select {{Google Analytics Tracking ID}} under Google Analytics Settings.
  6. Add your new custom event trigger under Triggering.
  7. Don’t forget to name your event and hit Save when you’re done!

This event will record the number of times an adblocker was detected on a pageview. In order to calculate your adblock rate, you will need to compare this against the total number of pageview hits. To accomplish this, simply create a new event that is triggered by all page visits.

Step #3: Adding JavaScript code to your website’s header

Armed with our event tag and trigger, we’ll now move on to the technical component of the detection process, the script.

Adblockers use filter lists to remove certain content (like display advertisements) from a user’s web browser. More specifically, it looks for certain requests made from a publisher’s website and attempts to prevent anything that looks like it came from a known ad network or ad exchange from rendering.

With this in mind, our detection script will make a request to download a file found on this filter list. If the browser detects that an adblocker is present, it will block this request. As a result, this action will be recorded by the event we created and show up in Google Analytics.

Simply put, if an adblock user visits your website with this script enabled, the request will always fail. Your new event will record the number of times the script fails. In other words, it will record the number of times an adblocker was detected.

  const googleAdUrl = '';
  try {
   fetch(new Request(googleAdUrl)).catch(_ => dataLayer.push({'event':'AdBlocker'}));      // use the event name you created in Step 1 here
  } catch (e) {

Place this script in the header section of your website.

Test your custom event in Google Analytics

Now comes the moment of truth, testing your event. Luckily, you can test your new event in Realtime within Google Analytics.

From your dashboard, select Realtime under Reports on the menu and choose Events.

Now try accessing your website. Realtime reports will record a new active user.

But we want to record realtime events.

  1. Select Events (Last 30 min) on the Realtime > Events view.
  2. Go back to your website. Turn off your adblocker if you have on installed.
  3. Refresh your cache and reload your webpage.
  4. Return to the Realtime event report to see if an event was recorded. As your adblocker was disabled, no event should be recorded.
  5. Go back to your website. Enable your adblocker this time.
  6. Refresh your cache and reload your webpage.
  7. Return to the Realtime event report to see if an event was recorded. As your adblocker was enabled, an event should have been recorded.

We tested this method 5 times (with the adblocker disabled and then enabled) on our website. As a result, 5 total adblock events were detected.

This script won’t pull in historical data. Therefore, you’ll need to wait a while to compile enough data to infer any actionable insights from it. At which point, you can compare the number of adblock detected events against your total pageview events to get an idea of what your adblock rate is.

One thing to note about this method is that the event will trigger for every pageview visit, not every user. However, this shouldn’t deter you from running this test to get an approximate idea of what your adblock rate is.

In summary

With adblock usage on the rise, it’s imperative that you know your adblock rate. From here, you can employ a number of ways to recover your adblocked revenue.

However, implementing the script discussed in this article will require some experience with tag and code implementation on your website’s backend infrastructure.

Additionally, the aforementioned script does not take Acceptable Ads users into account.

Users that install adblockers that allow Acceptable Ads understand that not all ads are intrusive and need to be blocked. Being unable to identify these users can mean you’re leaving a lot of money on the table. Understandably though, not all publishers will have the resources to implement an adblock detection script that looks for this.

That’s where Blockthrough comes in.

Blockthrough is the market leader in adblock revenue recovery. By helping our publishers monetize with Acceptable Ads, we’ve helped recover over $80M in ad revenue since our launch in 2018. Last year, we were recognized by Adweek as a winner of the 2021 Readers’ Choice Best of Tech Partner Award, under the category Best in Ad Blocking (Ad Recovery) Solutions.

Our technology is built to ensure compliance with the Acceptable Ads Standard. This enables our publishers to monetize adblock users while respecting their advertising experience and preferences.

Not interested in running your own detection script? Use ours instead.

Our detection script will provide an estimate on how many Acceptable Ads users you could be able to monetize, unlocking your true adblock monetization potential.

Speak to our team today for more details. Or, fill out our form below to get started with Blockthrough.

While you're here...

Did you know that the average publisher loses 10-40% of their revenue to ad blocking? What you may not know is that ad blocking has largely shifted to ad-filtering, with over 300M users allowing a safer, less interruptive ad experience to be served to them—in turn supporting their favorite sites and creators.

Blockthrough's award-winning technology plugs into publishers' header bidding wrapper and ad server to scan ad creatives for compliance with the Acceptable Ads Standard to activate this "hidden" audience and generate incremental revenue, while respecting the choice and experience of ad-filtering users.

Want to learn more?