How to Track Ad Blockers with Google Analytics 4 (GA4)
Mar 06, 2024 | Author: Info Publytics
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.
Recent Posts
-
Google Analytics GA4 Data Missing or Delayed Since 13 November 2024?
Nov 18, 2024 | Author: Info Publytics
-
15th of October, 2024. Google Analytics Down: What's Happening?
Oct 15, 2024 | Author: Info Publytics
-
The Most Efficient Way of Analyzing Multiple Websites in Your Network
Sep 30, 2024 | Author: Info Publytics
-
Why Your Website Posts Aren’t Getting Views (And How to Fix It)
Aug 29, 2024 | Author: Info Publytics
-
Publytics: Discover Why Real-Time Data is The Key to Improve Your Website Analytics
Jul 17, 2024 | Author: Info Publytics
- Try it for free
Are you looking for a complete tool to measure your website's progresses? Get deep into Publytics with our 14 Days of free trial!