Site   Web

December 29, 2015

The Full Guide to Unmasking Ad Blocker Traffic in Google Analytics

Let’s just start off by saying that we’re not going to get into the argument of “are ad blockers wrong or not?” This post is dedicated to first providing you with the necessary tools to understand what percentage of your traffic is blocking your ads. What you choose to do with that knowledge is up to you.

Ad Blocker software doesn’t care about your terms and conditions, or how hard you work to create your content. In the process of blocking your ads, it messes up your Google Analytics tracking — and it leaves you guessing.

Are my ads not loading properly?

Are my ads underperforming?

How many of my visitors never actually see them?

Who’s blocking my ads?

Just to make things clear, we’ll say it again, we’re not going to tell you how to do anything illegal. In fact, we’re just going to utilize a smart code strategy. It’s one that gives us a way to detect when ad blockers are being used. Let’s ask Mr. Doyle why that’s important: “It is a capital mistake to theorize before one has data” — Arthur Conan Doyle

Uncloaking the Ad Blocker Data

Ad Blockers are definitely not as invisible as they might like to think. Of course, that’s not really their primary goal anyway. We’ll tell you, step-by-step, how to copy-paste a little piece of JavaScript code to better understand your ad blocking traffic.

We’re going to give you detailed configuration instructions. We’ll also explain how to understand your new Google Analytics data. So what’s the end result?

You’ll know what percentage of your visitors are using ad blockers

You’ll be able to determine the impact it has on your ad revenue. It’s kind of a big deal. Ad blocking costs publishers an estimated $22 billion during 2015. Usage grew by 41 percent worldwide in the last year. Gulp.

Here are the stats. Let’s figure out the extent of the issue for you:

First Things First – Your Prerequisites

To use this strategy, your site must have both Google Analytics and Google AdSense installed.

We use these as the key elements of the detection hack which, by the way, is by courtesy of the great contributors at Webmaster World. They detect when AdSense isn’t running as expected, which indicates that an ad blocker is in place. So that means ads from any network are most likely getting blocked too. All of your ads are gone… just like that.

FYI, for the purposes of our strategy, we’re ignoring users who are disabling Javascript entirely. This is a very small segment of your traffic. And they are very hard to track. They are likely highly techie/experienced users who are willing to accept a degraded presentation across the entire Web.

Breaking Down the Ad Blocker Detection Code

If you’re expecting to get overwhelmed by a complex code setup, we have a great surprise for you.

The code we are using is actually only 11 short lines — but really smart ones. Now we’ll post the code for you, and then give you a quick overview of what it actually does once added to your pages.

The Code Snippet

if(typeof adsbygoogle !== \"undefined\") {
window.addEventListener(\'load\', function() {
if(typeof ga !== \"undefined\") {
if(typeof adsbygoogle.loaded === \"undefined\") {
ga(\'send\', \'event\', \'AdSense\', \'Ads blocked\', { \"nonInteraction\": 1 });
} else {
ga(\'send\', \'event\', \'AdSense\', \'Ads not blocked\', { \"nonInteraction\": 1 });
}, false);
If you want to track only “Ads blocked” events, you can use this modified version:
if(typeof adsbygoogle !== \"undefined\") {
window.addEventListener(\'load\', function() {
if(typeof adsbygoogle.loaded === \"undefined\" && typeof ga !== \"undefined\") {
ga(\'send\', \'event\', \'AdSense\', \'Ads blocked\', { \"nonInteraction\": 1 });
}, false);


We’ll let you know why some high traffic sites might prefer to do this later, when we talk about “collection limits.”

How to Install the Ad Blocker Tracking Code

If you’ve installed snippets of code on your site before, you’re good to go. If not, we really recommend you add a tag management system like Google Tag Manager. Otherwise, please contact your friendly neighborhood Web developer for a quick code update.

Paste the code snippet just before the ending tag of your site template. It needs to show up on every page. That’s all you need for the code installation part.

Note: For this hack to work, your Google Analytics has to be Universal Analytics or the version containing “analytics.js.”

What Does the JavaScript Code Do?

This isn’t a coding tutorial, so we won’t bore you to death with any more technical complexity than needed. It’s just a bit of really smart Javascript. Here is what is happening step by step:

• Wait for the page to load, and then check to see if Google Analytics successfully loaded.

• If GA loaded Javascript, then it is working, so check to see if your Google AdSense loaded too.

• Send some data to your Google Analytics account to indicate if the ad was blocked or not.

• If your pages load up and your Google Analytics is doing what it’s supposed to do, you check your AdSense.

• And if AdSense doesn’t load? Then we can reasonably infer that it was prevented from loading by an ad blocker. Busted!

That’s it. Some slick code using some smart logic to reveal the users that are ad blocking and those who are not. Then it sends this information into Google Analytics for you to review.

A single line of code tells Google Analytics to store an event for us. That event tells us if we detected the ad blocked or not. That’s it.

A Quick Note on Collection Limits

As the team over at Webmaster World pointed out, sending your custom events to Google Analytics is subject to collection limits.

In short, if you have traffic that exceeds 10 million hits per site in a month, you’ll end up speaking with a Google rep. They’ll discuss upgrading you to a premium account with higher limits with you. By the way, you can also become a premium Google AdSense publisher with less than astronomical traffic. Here’s how.

What do we do with this data?

Now that our nifty piece of code is generating data, we need to visualize the data through Google Analytics. You can use another analytical platform if you prefer but this tutorial is GA focused.

Display Your Ad Blocker Stats in Google Analytics — Custom Segments

Google Analytics custom segments lets us group our data in new ways. In our case, it will be straightforward, based on two new data segments:

• Traffic with ads blocked

• Traffic without ads blocked

That lets us compare all the performance and behavior data for both segments – the ad blockers versus those seeing your ads.

Step 1 – Go to “Audience Overview” and Add a Segment


Step 2 – Create a New Segment for “Ads blocked”


Step 3 – Configure New Segment


• Enter “Ads blocked” for the segment name.

• Select “Conditions” under “Advanced” (left column).

• From the dropdown, select “Event Action” from the “Behavior” group.

• In the input field for the event action, enter “Ads blocked” again.

• Click “Save” to create your new segment.

Our new segment is going to be based on the events we created with our code snippet. Every time it detects that an ad is blocked, it saves it to Google Analytics. We’re now using those events to create a new segment.

Step 4 – Repeat for “Ads Not Blocked”

Now we want to repeat steps 1 through 3. This time we’ll create a new segment in the same way for “Ads not blocked.”

When we’re finished, these segments give us great insights into the difference between our ad blocking users and regulars users.


Once you have this setup for both Ads Blocked and Ads Not Blocked events, you can compare them against other data types. We’ll looking at both ad blocked and non-ad blocked events, compared with all user sessions.

But that is just one method: segmenting by detecting events. We can also enhance our analytics by adding custom dimensions.

Why Use a Custom Dimension?

Using a custom dimension is our second strategy for adding ad blocker status into our Google Analytics data.

A dimension is simply an attribute of a Web visitor. A simple example would be demographic data like what city they are located in. Every hit to the site will have that same dimension. They aren’t moving to a new city between every page view… unless they’re connecting from their private jet!

Just like the type of Web browser they are using is a dimension, whether they are running an ad blocker or not also makes a great custom dimension.

So we’ll show you how to create this new custom dimension and add it to your GA tracking code.

Creating Your New Ad Blocking Custom Dimension

So our goal now is to setup “Ad Blocker Status” as a custom dimension. We do this from our main Google Analytics admin page.

Step 1 – Click on the “Admin” Tab at the Top of the Page


If you have multiple sites, make sure you click on “All Website Data


Step 2 – From the Settings, Choose “Custom Definitions”


Step 3 – Choose “New Custom Dimension”


Step 4 – Give the Dimension the Name “Ad Blocker Status” and Select “User” for Scope. Click the “Create” button to proceed to the final step.


Step 5 – Review the Examples and Click “Done”

Well, you can take a look at the code. However, the most important step is for you to click “Done.” We are going to provide you with the modified Google Analytics tracking code in the next step.


Step 6 – Now We’ll Replace the Previous Code Snippet on Your Site

In the previous code snippet we provided you, we were setting a custom event only. Now we are working on adding dimension data.

Here is the modified snippet you can use to replace the previous version in your site template. Again, if you are not comfortable editing code within your web template, then you will need to get your web developer to assist you.

The New Snippet for Adding Dimension Tracking

The new code:

if (typeof adsbygoogle !== \"undefined\") {
window.addEventListener(\'load\', function () {
if (typeof ga !== \"undefined\") {
if (typeof adsbygoogle.loaded === \"undefined\") {
ga(\'set\', \'dimension1\', \'Ads Blocked\')
ga(\'send\', \'event\', \'AdSense\', \'Ads blocked\', {\"nonInteraction\": 1});
} else {
ga(\'set\', \'dimension1\', \'Ads Displaying\');
ga(\'send\', \'event\', \'AdSense\', \'Ads not blocked\', {\"nonInteraction\": 1});
}, false);


This snippet not only sends the ad blocker event data, it also adds our new dimension.

Looking at Ad Blocker Status As a Secondary Dimension

When we create new custom dimensions, they become accessible in our Google Analytics reports as a secondary dimension.


You can select “Ad Blocker Status” from the “Secondary Dimension” dropdown menu. It’s in the “Custom Dimensions” section.

Then you can view your analytic data with the ad blocker status included in the report. C’est tout!

So How Many of Your Visitors Are Blocking Your Ads?

We’ve given you two different ways to detect and track your users who are ad blocking. It’s important for you to be aware of how much of your traffic never gets to see any ads.

You can also examine the data to see how not having ads changes the user experience. For instance, do users that see the site without ads stay on your site longer before bouncing?

Then you can get creative. If a large percentage of your users are using ad blockers, that’s a lot of revenue you may be losing. By any chance, is there another way to monetize your traffic?

These are the kinds of decisions we get to start thinking about once we get our hands on the data. But we can’t do it flying blind. We absolutely need to know how many of our users are being mischievous with their ad blockers.

Share with us: If you configure Google Analytics to discover how many of your users are ad blocking, please post a comment here so that we can compare. If it’s unusually high or low, we may be able to pinpoint a critical factor influencing it. That’s the power of data!


Eyal Katz Head of Marketing Operations at AdNgin. AdNgin is a testing platform that increases ad revenue for publishers through continuous testing. Before coming to AdNgin, Eyal was a marketing professional focused on SAAS business models. When he’s not working, which is rare, I sail and hang out with my son, Jonathan, and wife, Meital.