skip to Main Content

Adblock is a simple browser plug-in that allow you not to see ads when you’re browsing webpages and is used by large number of people. For detailed information about Adblock, please visit getadblock.com.

In this article we will see how to leverage the Google Tag Manager to measure Adblock users from our site in Google Analytics.

We need to write custom JavaScript code to find out if user uses Adblock in the browser which  comes fromGoogle Tag Manager. We can call this custom Javascript as a new variable on the GTM and name it Adblock. The code we use:

function AdBlockEnabled() {
  var ad = document.createElement('ins');
  ad.className = 'AdSense';
  ad.style.display = 'block';
  ad.style.position = 'absolute';
  ad.style.top = '-1px';
  ad.style.height = '1px';
  document.body.appendChild(ad);
  var isAdBlockEnabled = !ad.clientHeight;
  document.body.removeChild(ad);
  return isAdBlockEnabled;
}

I got this code from: http://www.kaushik.net/avinash/adblock-tracking-google-analytics-code-metrics-reports/

This means that if the code returns “True”, the user uses Adblock, if it returns “false”, user does not use Adblock. You need to create this code via GTM as a custom variable as follows:

After you create it and run it in the GTM Preview mode, if you have Adblock plugin, the result will be as follows.

I’ve added the variable named “AdBlocker” here as a lookup table. The main thing we need to look for is the Adblock variable to be “true”.

We have been able to isolate whether the user is using Adblock with GTM. Now, how do we transfer this to Analytics?

In fact, the answer is very simple: Custom Dimensions!

You can set up as mentioned in our previous article, Custom Dimensions. First, you need to create the Adblock custom dimension through Google Analytics.

Then you have to send the value that is formed by selecting the custom dimension {{Adblock}} within the Google Analytics Page View tag that we send over GTM.

After setting this up, we can choose Adblock as the custom dimension in the segment. 0-value means not-using-Adblock, 1-value can be interpreted as those that use Adblock

Berkan Bagci

I am an online marketer who focused on web analytics for years. I did lots of GTM and GA setups for big websites in Turkey. Also I made a success story with Google Optimize and it has released on Jan 2018.

This Post Has 4 Comments

  1. I can’t manage to send the data from the variable over to Analytics with Custom Dimensions. The article doesn’t explain this part at all..

    Could you go into full detail on this part please?

  2. Wouldn’t adblockers affect GTM loading as well? Like ghostery or uBlock.
    Then this method you mentioned would only work for more permissive blockers like Adblock, right?

Leave a Reply

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

Back To Top