Have you ever wanted to know exactly how many of those who visit your WordPress site are blocking your ads? If so, you're in luck. This guide will show you how to score new sessions with visiteurs using AdBlockers with a Google custom event Analytics. Next, we will show you how to segment users with AdBlockers via advanced segment in Google Analytics.

This tutorial is for advanced users, who know how to add code snippets to their website. Of course, you should always consider backing up your website.

How to track AdBlock users with Google Analytics (without Google Tag Manager)

You will probably need to know how to add Google analytics on WordPress.

1 - Add the following code immediately after your Google tracking code Analytics in the “header.php” file of your theme:

var adBlockEnabled = false; let testAd = document. createElement('div'); testAd.innerHTML = ' '; testAd.className = 'adsbox'; document.body.appendChild(testAd); window.setTimeout(function() { if (testAd.offsetHeight === 0) { ga('send', { hitType: 'event', eventCategory: 'adBlocker', eventAction: 'detected' }); } testAd.remove (); }, 100); "; } $_SESSION['exists'] = true; ?>

2 - If you experience session-related errors with the code above, use the following code instead:

 var adBlockEnabled = false;
 var testAd = document.createElement('div');
 testAd.innerHTML = ' ';
 testAd.className = 'adsbox';
 document.body.appendChild(testAd);
 window.setTimeout(function() {
 if (testAd.offsetHeight === 0) {
 ga('send', {
 hitType: 'event',
 eventCategory: 'adBlocker',
 eventAction: 'detected'
 });
 }
 testAd.remove();
 }, 100);

3 - Install and enable the following AdBlocker advanced segments in Google Analytics:

4 - View the results in Google Analytics to see how many visiteurs of your Website block your ads as well as how they use your website compared to those who don't block them.

How to track AdBlock users with Google Tag Manager

You will probably need to read our tutorial on the integration of Google Tag Manager on WordPress.

1 - Add the following code just after your Google Tag Manager container code in the "header.php" file of your theme:

var adBlockEnabled = false; let testAd = document. createElement('div'); testAd.innerHTML = ' '; testAd.className = 'adsbox'; document.body.appendChild(testAd); window.setTimeout(function() { if (testAd.offsetHeight === 0) { dataLayer.push({'event': 'adBlockerDetected'}); } testAd.remove(); }, 100); "; } $_SESSION['exists'] = true; ?>

2 - If you encounter session related errors with the above code, use the following code instead:

 var adBlockEnabled = false;
 var testAd = document.createElement('div');
 testAd.innerHTML = ' ';
 testAd.className = 'adsbox';
 document.body.appendChild(testAd);
 window.setTimeout(function() {
 if (testAd.offsetHeight === 0) {
 dataLayer.push({'event': 'adBlockerDetected'});
 }
 testAd.remove();
 }, 100);

3 - In the Google Tag Manager container of your site, create a new tag " Universal Analytics Called "adBlocker Detected" with the following parameters:

  • Tracking ID: [insert your Google Analytics ID here]
  • Track type: event
  • Category: adBlocker
  • Action: detected
  • Non-Interaction Hit: True

Google tag manager creation tag

4 - Then add a new trigger for this tag called “AdBlocker Detected” with the following parameters:

  • Trigger type: personalized event
  • Event name : adBlockerDetected
  • This activation triggers: All custom events

Trigger configuration

5 - Publish your updated Google Tag Manager container

6 - Install and enable the following AdBlocker advanced segments in Google Analytics:

View the results in Google Analytics to see how many visiteurs of your website block your ads as well and those that don't.