How to track ad blocker usage with Google Tag Manager

Author:

Ad blockers are increasingly common tools that allow users to block unwanted advertisements from appearing while browsing the internet. While these tools provide benefits for users, they pose challenges for marketers and website owners who rely on advertising revenue and data collection. Understanding how many visitors to your site are using ad blockers can help you adjust your strategies for content delivery, marketing, and monetization.

One of the most effective ways to track ad blocker usage on your website is through Google Tag Manager (GTM), a tag management system that allows you to add, manage, and deploy marketing tags on your website without modifying the code directly. In this article, we’ll discuss how to track ad blocker usage with Google Tag Manager by utilizing custom events and trigger mechanisms.

1. Understanding the Basics: Ad Blocker Detection

Before diving into the setup process, it’s important to understand the core principles behind ad blocker detection. Ad blockers work by preventing specific content (typically ads) from loading on a webpage. Many ad blockers rely on blocking requests for known ad-serving domains or blocking specific HTML elements like iframe or script tags that contain ads.

Detecting ad blockers typically involves looking for blocked resources or failures in loading ads. For example, if an ad fails to load, this could indicate that an ad blocker is in use.

2. Why Track Ad Blocker Usage?

There are several reasons why tracking ad blocker usage is crucial:

  • Revenue Impact: Ad blockers can prevent your ads from being displayed to visitors, thus reducing ad revenue. Understanding how many of your users are using ad blockers can help you identify revenue gaps.
  • User Behavior: If a significant number of users are blocking ads, this could indicate a problem with the way your ads are being served. You might want to optimize your ad experience or consider alternate monetization strategies.
  • Content Strategy: Knowing that visitors are blocking ads allows you to deliver different types of content or offers to these users. For instance, you might promote an ad-free subscription model to users who block ads.

3. Setting Up Google Tag Manager for Ad Blocker Detection

To track ad blocker usage using Google Tag Manager, we’ll focus on two primary strategies:

  1. Detecting the presence of an ad element that would normally be blocked by ad blockers.
  2. Implementing a fallback mechanism to detect if the ad element did not load or was blocked.

Let’s walk through the steps for both approaches:

Step 1: Create a Custom HTML Tag in GTM to Detect Ads

Google Tag Manager allows you to add custom HTML tags, which can be used to detect blocked ad elements. For this example, we’ll add an invisible ad container to your webpage and check if it loads successfully.

  1. Log into Google Tag Manager: Go to your Google Tag Manager account and select the container for the website you want to track.
  2. Add a Custom HTML Tag:
    • In the GTM dashboard, go to the Tags section and click New.
    • Choose Custom HTML as the tag type.
    • Insert the following script into the HTML box:
    html
    <script>
    var adBlockTest = document.createElement('div');
    adBlockTest.innerHTML = '&nbsp;';
    adBlockTest.className = 'adsbox';
    document.body.appendChild(adBlockTest);

    if (adBlockTest.offsetHeight === 0) {
    window.dataLayer = window.dataLayer || [];
    window.dataLayer.push({
    'event': 'adBlockDetected'
    });
    }

    adBlockTest.remove();
    </script>

    This script creates an element on the page that has the class adsbox. Ad blockers commonly block such elements or prevent them from rendering, so by checking the offsetHeight property, you can determine if the ad element has been blocked.

  3. Save the Tag: After inserting the script, save the tag.

Step 2: Create a Trigger for the Ad Blocker Detection Event

The next step is to create a trigger that will fire the custom HTML tag. We want this tag to fire when the page loads.

  1. Create a Trigger:
    • In GTM, go to Triggers and click New.
    • Choose Page View as the trigger type.
    • Select All Pages to fire the trigger on every page, or choose specific pages if you want to track ad blockers on only certain pages.
  2. Save the Trigger: After configuring the trigger, save it and associate it with the custom HTML tag.

Step 3: Push Ad Blocker Detection Data to the Data Layer

In the previous step, we included a script that pushes an event to the data layer when ad blockers are detected. The event name is 'adBlockDetected'. Now, we need to listen for this event within GTM to track it.

  1. Create a New Variable:
    • Go to Variables in GTM and click New.
    • Choose Data Layer Variable as the variable type.
    • In the Data Layer Variable Name field, enter event.
    • Set the variable to pull the event name from the data layer.
  2. Save the Variable: After configuring the variable, save it.

Step 4: Create a Trigger to Fire on Ad Blocker Detection

To track the event when ad blockers are detected, we need to create another trigger that will fire when the adBlockDetected event is pushed to the data layer.

  1. Create a Custom Event Trigger:
    • In GTM, go to Triggers and click New.
    • Choose Custom Event as the trigger type.
    • In the Event Name field, enter 'adBlockDetected'.
    • Set the trigger to fire on all custom event matches.
  2. Associate the Trigger with the Tag: Create a new tag (or use an existing one) that sends data to Google Analytics or another analytics platform when the event fires. This could be a Google Analytics event tag that tracks the occurrence of ad blocker usage.

Step 5: Publish and Test

After completing the setup, test the implementation to ensure everything is working correctly. Use the Preview Mode in Google Tag Manager to confirm that the ad blocker detection script fires properly and the event is pushed to the data layer. You can also use browser tools like Developer Tools or AdBlocker Plus to verify that the tag behaves as expected when ad blockers are active.

Once confirmed, publish the changes in GTM.

4. Analyzing the Data

Once the data collection is live, you can track ad blocker usage in your analytics platform. If you’re using Google Analytics, you can monitor custom events triggered by the adBlockDetected event. This will give you insights into the number of users who are blocking ads on your website.

To gain actionable insights from the data, you can:

  • Compare the number of ad-blocking users across different pages or traffic sources.
  • Look for patterns that could indicate a larger issue, such as specific ads being blocked or higher rates of ad blocking among certain demographics.
  • Consider testing alternative monetization models, such as offering ad-free subscriptions or adjusting the way ads are served.

Conclusion

Tracking ad blocker usage with Google Tag Manager is a practical way for website owners and marketers to understand how many of their visitors are blocking ads. By using custom HTML tags and data layer events, you can accurately track the presence of ad blockers and take appropriate actions to optimize your monetization strategies. Understanding this data can help you adjust your advertising, content, and user experience strategies to ensure you’re meeting the needs of all your visitors, whether they use ad blockers or not.