Subscribe to our social networks

arrow icon All Post

How to Track Ad Blockers with Google Analytics 4 (GA4)

Mar 06, 2024 | Author: Info Publytics

How to Track Ad Blockers with Google Analytics 4 (GA4)

In the age of ad blockers, it’s crucial for website owners and marketers to understand how often their ads are being blocked. Google Analytics 4 offers a way to track this. Here’s a guide to setting up ad blocker tracking in GA4.

Ad blockers are a type of software designed to prevent advertisements from appearing on web pages you visit. They work by filtering out content identified as ads and can be installed as browser extensions or part of other software packages.

The most common ones are uBlock Origin, AdBlock Plus and Nord VPN Threat Protection.

Here’s a brief overview of how they function:

  • 1. Detection: Ad blockers scan websites for elements that match known ad formats.
  • 2. Blocking: Once detected, these elements are prevented from loading, thus stopping ads from being displayed.
  • 3. Protection: By blocking ads, they also help protect against malvertising—ads that may contain malicious code.

Now that we know what an ad blocker is, let's discover how to track them:

Step 1: Understand the Basics

Ad blockers work by preventing ad scripts from loading on a webpage. To track this, you’ll need to detect when an ad script fails to load.

Step 2: Create a Bait Script

Develop a simple JavaScript file named advertisement.js with a single line of code:

window['noBlocker'] = true;

Upload this to your server, ideally in a common directory like /wp-content/ for WordPress sites.

Step 3: Set Up Google Tag Manager

Create a Custom JavaScript Variable in GTM named {{JS - noBlocker}} with the following function:

function () {

  return window['noBlocker'] ? undefined : 'true';

}

This will return ‘true’ if advertisement.js is blocked.

Step 4: Configure Custom Dimension in GA4

Create a new Custom Dimension in GA4 with a session scope. Note the index number assigned by GA4.

Step 5: Modify Your Page View Tag

In your generic Page View Tag in GTM, add a new Custom Dimension row with the index number from GA4 and set its value to the {{JS - noBlocker}} variable.

Step 6: Analyze the Data

In GA4, go to ‘Reports’ > ‘Engagement’ > ‘Events’ to view the events. Filter for the custom dimension you set up to see sessions with ad blockers.

 

By following these steps, you can start tracking ad blocker usage on your site with GA4. This data is invaluable for understanding the true reach of your ads and making informed decisions about your advertising strategy.

 


Posted: 1 month ago
Author: Info Publytics

Recent Posts

bg img

    Are you looking for a complete tool to measure your website's progresses? Get deep into Publytics with our 14 Days of free trial!

  • Try it for free