!!! POST UPDATED 2016-09-28 – With new screenshots adapted for the newest version of Google Tag Manager !!! 

More and more people are using some kind of Adblock in order to minimize the amount of ads they see online. According to a recent studie released by Pagefair shows that there are now 198 million active adblock users in the world.

The same study shows that ad blocking grew with 41% globally in the last 12 months.

I started doing some data collection based on this before summer, because people started talking a lot about it back then. I now have data enough (yea, I could blame vacation time too) to draw some conclusions based on it, but also share my implementation with you guys.

Are you interested in knowing how many of your visitors that are using any kind of adblocker while visiting your site?

Even though you maybe not are showing ads on your own site, there is a big chance that you are doing advertisement on other sites, and it is always good to know if your target audience are receiving your ads at all, or not.

What do we want to collect?

In order for us to learn this, we need to push that data into Google Analytics, so that we can refer to it while looking at other data we already collect.

Some quick research shows that one of the most common terms the adblockers are looking for is “ads”. In order to find a generic way that works for everyone, I’m going to run with an external file that I’m uploading to my domain, called ads.js.

The content of this file is very simple, it contains one row, defining a Javascript variable as below.

You can find my file, that I am using, right here: dcarlbom.com/ads.js

Using Google Tag Manager to check Adblock usage

Next step is to jump right into Google Tag Manager – of course – and begin to setup the things we need.

First of all, we are going to create a Variable that will read from the dataLayer, as shown below.

Google Tag Manager - DLV adBlockStatus

We are going to use the key adBlockStatus  inside the dataLayer and while setting it up I opted to set the Default Value to ‘inactive’.

With this in place, we assume that an Adblocker is not being used, but can override this value if it is true later on.

Custom HTML Tag to check if the ad is being loaded

Since we need to check if the supposed ad is being shown or not, we can use a simple Javascript to check if the variable we used in ads.js  is defined or not.

 

This is stored as a Custom HTML Tag that fires on All Pages, as below.

Google Tag Manager - HTML - Check AdBlocker

 

So, what’s really happening in the code above? Let’s break it down, piece by piece.

 

First of all, we are checking the current browser window for a Javascript variable called canRunAds , which we defined in the ads.js file in the beginning.

If canRunAds is not defined, hence being blocked by an active Adblocker, do this:

Push two key:value datasets into the dataLayer.

First of all, we are sending in an event named ‘adBlocker’, we are going to use this in the Trigger later or.

Next, we override the Default Value of adBlockStatus  with the value active, because we now know that an Adblocker is active.

The last part should be pretty obvious. If the first statement is not true, run the code inside else { }.

What we are doing here, is basically just pushing event: adBlocker into the dataLayer, because we want to use that inside the Trigger. This is so that GTM should know that “OK, we have now checked wether or not Adblocker is used”.

Send the data into GA

For the last part, we need to send this data into Google Analytics one way or another. We can use to send it in as an Event, or pass the data in as a Custom Dimension. I am going to show you both versions here.

In order for us to pass this on as a Custom Dimension we need to prepare Google Analytics to receive that data. So first of all we need to set it up.

Google_Analytics Custom Dimensions

Jump right into the Admin section of your Property in Google Analytics and hit Custom Definitions and then press Custom Dimension that pops up under it.

Google_Analytics

Create a new Custom Dimension and give it a proper name, such as Using Adblock. Set the scope to Sessions, because I want to know the Adblock usage on a per session basis.

Take note of the Dimension Index because you are going to need it shortly. In my case, it’s ‘4’.

Google_Analytics Custom Dimension Overview

You can of course also see it in the Custom Dimension Overview.

Enough of that, let’s get back to GTM, shall we? :)

Google Tag Manager - Event - AdBlock Status

Create a new Tag with the following properties.

  • Tag Type: Universal Analytics
  • Tracking ID: The Variable containing your UA-identifier, or the UA-XXXXXXX-X itself
  • Track Type: Event
  • Category: Adblocker
  • Action: {{DL – adBlockStatus}} (value retrieved from the dataLayer)
  • Label: {{Page Path}}
  • Non-Interaction Hit: True (we don’t want this to count as a non-bounce)

Then, navigate to More Settings and Custom Dimensions. Set the Index Value to the Custom Dimension Index inside Google Analytics (4, in my case), and the Dimension Value to {{DL – adBlockStatus}}.

Under Fire On, we are going to use the event we are pushing into the dataLayer as a trigger, like this.

Google Tag Manager - Trigger - AdBlocker

This will now not only send data into Google Analytics on what pages are being loaded with Adblockers, but also opens up for further analysis using the data as a separate dimension to combine with all other data as well.

adblock_users_-_analytics

Looking at the data we can now see that 20% of all users to this site was using an active adblocker.

But collecting the data is only the first part, the next step is to dive deeper into the data in order to make any conclusions. We can for instance see, based on sampled demographics data in GA, that the younger the audience, the more inclined are they to block ads.

AdBlock Usage in dcarlbom.com

Now, this is data we can build further upon.

How many people are using adblockers on your site?

Tell your friends...Share on Facebook17Tweet about this on TwitterShare on Google+0Share on LinkedIn8