Reporting on AdBlock usage with Google Analytics

Ad blocking is a really hot topic these days. Arguably there are two completely opposite stories to follow up on yet we are not dealing with that this time. This post explains how to report on ad blocking occurrence on the site and how it affects your ‘potential’ earnings as a publisher.

There are 3 main steps to this process:

  1. Detect ad blockers and send an event to Google Analytics (we will use it later on in a segment)
  2. Make the number of page ad slots available – ideally using dataLayer (if using GTM)
  3. Create the Custom metric(s) in Google Analytics interface and create the custom reports / dashboards

1. Detect AdBlockers

There are already numerous ways to detect clients / users with ad blocking apps activated so I will only list a few:

You will notice that almost all detection kits use a ‘dummy’ / ‘fake’ ad related file which will hopefully trigger an ad blocking app and this should fire a GA event. You can of course adapt it to detect your real ads being blocked without the need to add the fake script.

The logic

Using any of the for mentioned scripts fire a Google Analytics event e.g. in case you are using GTM push the info via dataLayer:

window.dataLayer = window.dataLayer || [];
'event' : 'trackEvent',
'eventCategory': 'Adblock',
'eventAction': 'Active'

Create a Google Analytics Event template tag using these values which is triggered on the custom event trackEvent and you’re almost done (variables and triggers should be created as well):


2. Make the number of page ad slots available

Again if using GTM just add the information to dataLayer which will represent the number of ad slots available on a single page. The idea is to simply use getElementsByClassName() which will return an object which has a property length – use this logic to obtain the number  of ad slots available on a specific page (the value which we are looking for is length +1 as the indexing starts at 0).

Easy as:

var adSlotIndex = document.getElementsByClassName('elementClassWhichContainsAnAd').length;

One thing worth noting is that you will probably want to send this info after DOM is ready so choose how to send this custom metric carefully – options are to send it with a pageview (so PV tracking should be DOM ready) or use an event for more flexibility just make sure non interaction is set to true.

In addition you can send another custom metric which will be currency type which will be calculated as total Ad Slots On Page * Average Revenue Per Impression – reporting with currency gives more weight to the whole concept.


3. GA prerequisites and building the dashboard

First take care of the segment – Session level segment which will be Event Category == AdBlock and Event Action == Active. This will allow reporting on sessions where AdBlock was active – in specific number of ad impressions or better say ads that were supposed to be delivered you could not be as they were … blocked. This segment can be applied to standard / custom reports, dashboards and used in API exports.

Secondly create the custom metric(s) on GA property level.

And now it is all up to you to show the data best way you can – the way it will make you do something to battle this revenue consuming trend.


Some reports details to consider: browser, browser version, geography based dimensions, content grouping (LP or page – to determine where this revenue source is most sensitive) – you will probably find more useful dimensions.

Hope this helps in determining how much money you loose from ad blockers:)

Happy tracking!

Author bio

Zorin Radovančević

October 2, 2015 Google Analytics

Senior Web Analytics implementation and planning specialist - all things related to Google Analytics, Google Tag Manager and Yandex Metrica.


Leave a Reply

Your email address will not be published. Required fields are marked *