How to Track Ad Block Users Via Google Analytics

Reading time: 4 minutes

The number of users with ad blockers has steadily decreased over the past decade. Currently, there are more than 76 million users in the US alone that have installed ad blockers to their browsers — costing the ad tech[4] industry upwards of $16 billion in losses. 

There are plenty of reasons why a user would install an ad blocker. Let’s be honest, A LOT of users hate dealing with ads while they browse through different websites. Most ads tend to be intrusive, not to mention, they often slow down the page, making it very frustrating for anyone to get through the content. Of course, there are also privacy concerns and malware to avoid. 

The point is, installing ad blockers has become a growing trend. 

Ad blockers don’t just target ads either. They also target other website trackers to prevent publishers from tracking the users across multiple sites and even services by preventing the trackers from loading. It’s a real issue for digital publishers as it gets in the way of how they measure the efficiency of their online advertising campaigns while undercutting their profits. 

Fortunately, Google Analytics[1] can give publishers insight into whether their visitors are using ad blockers which helps solve the issue almost entirely. (It’ll help you measure your ad campaigns more effectively but it won’t change the fact that people are still using ad blockers). 

There are actually two ways you can go about tracking ad-block users with Google Analytics, and we’re going to explain both of them.

Read on to learn more.

The First Way

The first method of tracking ad blockers involves using JavaScript coding and using a custom dimension within Google Analytics. 

Here are the steps:

Step #1: Use JavaScript code in the website’s header

The JavaScript code listed out below should be put directly into your website’s header to assess whether a visitor[5] has an ad blocker installed:



(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),



// Creates an adblock detection plugin.

ga(‘provide’, ‘adblockTracker’, function(tracker, opts) {

var ad = document.createElement(‘ins’);

ad.className = ‘AdSense’; //Name of ad partner you’re working with. = ‘block’; = ‘absolute’; = ‘-1px’; = ‘1px’;


tracker.set(‘dimension’ + opts.dimensionIndex, !ad.clientHeight);



ga(‘create’, ‘UA-XXXXX-Y’, ‘auto’); //Replace UA-XXXXX-Y with your tracking ID.

ga(‘require’, ‘adblockTracker’, {dimensionIndex: 1});

ga(‘send’, ‘pageview[6]’);


Step #2: Create a custom dimension in Google Analytics

By setting up the custom dimension, you’ll be able to utilize the data captured by the code snipped from above right on the Analytics dashboard. 

Here’s how to do it:

  • Enter into the Admin setting then click Custom Definitions > Custom Dimensions
  • Click on + NEW CUSTOM DIMENSION and name it manually

Once you’ve created the custom dimension, you’ll want to analyze your ad-blocking visitors, which means you’ll have to use the advanced segments features

A quick note about advanced segments — they’re more selective compared to typical dashboard filters, which traditionally subtract specified traffic sources from your total traffic amount. Therefore, you’ll need to create a new segment[7] to narrow down the analytics reporting based on the ad-blocking traffic. 

Here’s how to do this:

  • Click on Home > Audience > Overview
  • Now, click on +Add Segment > +New Segment and then click on Advanced > Conditions on the left-hand sidebar
  • Select Blocked Ads from the drop-down menu under Ad Content
  • Now, select exact matches from the subsequent drop-down menu and enter the number 1, and save your new settings

If you want to take things a step further to compare ad-blocking user behavior, you can also create custom reports in Google Analytics:

  • Go to Home > Acquisitions > All traffic > Source/Medium
  • From there, click +Add Segment and select Blocked Ads
  • Lastly, click on Apply to generate your report

The Second Way

The second method involves adding a DIV code to your web pages. 

Here are the steps:

Step #1: Add a DIV code to your web pages

In the CSS of your website, add the following JavaSCript code

var test = document.createElement(‘div’);

test.innerHTML = ‘&amp[2];nbsp;’;

test.className = ‘adsbox’;


window.setTimeout(function() {

    if (test.offsetHeight === 0) {




}, 400);

By implementing the condition test.offsetHeight, you’ll learn if the user has installed an ad blocker. Additionally, the CSS class adsbox will signal to the ad blocker to hide for a certain amount of time so you can encourage the users to disable their ad blockers. This is actually the preferred technique among publishers. 

Step #2: Record the ad blockers via Google Analytics

Not all users will respond to you asking them to disable their ad blockers. So, your next step is taking over data visualization.

Add the following code to the JS code listed in step one to collect data on ad blocking[3] users’ navigation:

ga(‘send’, ‘event’, ‘Ads Setting’, ‘Adblock’, ‘Enabled’);

The above code is for Universal Analytics users. If you’ve old version of GA (classic GA), copy the following code:

_gaq.push([‘_trackEvent’, ‘Ad Setting’, ‘AdBlock’, ‘Enabled’);

Now, your complete code should look like this:

var test = document.createElement(‘div’);

test.innerHTML = ‘&nbsp;’;

test.className = ‘adsbox’;


window.setTimeout(function() {

    if (test.offsetHeight === 0) {


        ga(‘send’, ‘event’, ‘Ad Setting’, ‘Adblock’, ‘Enabled’);



}, 400);

Step #3: Set up custom events in Google Analytics

To reflect the data you’ll be collecting in Google Analytics, you’ll need to create Events

Here’s how it’s done:

  • Click on Admin > Goals > +New Goal
  • Click on Custom and name the goal
  • Select type: Event
  • In Goal Details, fill in the information for Category, Action,  and Label. Be sure to use the same values that you entered in the function ga ()
  • Now go to Home > Realtime > Events. Under the active Users’ section, you should see the total number of users that are using ad blockers

When you measure your ad-block traffic, you’re measuring the effects the use of ad blockers is having directly on your ad revenue. It’ll also help you figure out how you can improve your content and the ads delivered to recover that ad blocked revenue.

1. Google Analytics. This is Google’s traffic tracking and analytics tool that gives publishers insight into traffic origins, popular pages on their website and much more.
2. Accelerated Mobile Pages [AMP] ( amp ) Accelerated Mobile Pages is a project supported by Google to provide web publishers with a way to serve web page very quickly for mobile devices.
3. ad blocking. Ad blocking is the process of using software that blocks ads from displaying. Ad blocking software is available for most browsers and internet-enabled devices on either desktop or mobile.
4. ad tech. Advertising Technology, or ad tech, refers to software built for the advertising industry that helps improve media effectiveness and increase operational efficiencies. Ad tech can refer to a number of platforms, including demand-side platforms (DSPs), data management platforms (DMPs), supply-side platforms (SSPs) and ad exchanges.
5. visitor. A user who revisits a webpage, regardless of frequency.

Recent Articles

Related Articles

Leave A Reply

Please enter your comment!
Please enter your name here

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Stay connected

Don't miss out on the latest news, events and special announcements.

By submitting this form, you agree that you've read and accept our Privacy Policy as well as to receive communications from You may unsubscribe at any time.