Categories
Web Development

Track Ad Blocking Software with Google Tag Manager

Ad blocking plugins can easily cut into any website’s revenue. Not sure if it’s happening to yours? You can use this simple method to find out just how much your traffic is being affected by AdBlockers.

Ad blocking plugins can easily cut into any website’s revenue. Not sure if it’s happening to yours? You can use this simple method to find out just how much your traffic is being affected by AdBlockers.

For the purposes of this illustration, I will assume you’ve already set up Google Tag Manager and Google Analytics. If not, go there first, and get it set up. This tutorial also assumes that you are using jQuery.

Set Up an AdBlocker Tracking Variable

Once you’re inside Google Tag Manager, click on the menu item labeled Variables. Under User-Defined Variables, choose New. Under Choose Type, select Custom Javascript. Then configure the script like this:

function () {
  $(document.body).append('<div id="adsense" style="position:absolute; left:-999999px;">Advertisement</div>');
  var eventValue = 'Blocked';
  if ($("#adsense").height()) {
    eventValue = 'Unblocked';
  }
  return eventValue;
}

Track the Result With a New Tag

Now we have to report this new variable to Google Analytics. Click on the menu item labeled Tags. Set up a new tag like this:

Publish Your Changes

None of this will work until you publish your changes in the Google Tag Manager.

Follow Along in Google Analytics

All you need to do now is watch your Google Analytics in real time as you visit your web site. From Google Analytics, visit Real Time >  Events. Click on Events (last 30 minutes). You will see AdBlockStatus start to appear here. Clicking on AdBlockStatus here will show you how many people are blocking your ads, along with a percentage.

By Tim Bunch

Tim Bunch is a Web Developer from Rockaway Beach, Oregon. As a web standards fanatic, he passionately pursues best practices. He also actively engages people on a wide range of topics in a variety of social media networks. Tim is also an avid Wordpress developer, music maker, coffee drinker, and child raiser. @timbunch

2 replies on “Track Ad Blocking Software with Google Tag Manager”

Leave a Reply