Web Design that taps into the haromny and vision of your dreams.

How to Track Ad Blockers Traffic in Google Analytics

By on in Internet

421 words, estimated reading time 2 minutes.

Ad Blockers are becoming ever increasingly popular among web visitors. While they are mainly installed to reduce obnoxious or obtrusive adverts, they are indiscriminate and often block subtle ads which hurt web publishers. This guide will show you how to log ad blockers blocking Adsense traffic in Google Analytics.

Ad blocking is a huge problem for both ad publishers and content writers. Content writers usually offset the cost of server hosting and time to create content with the revenue from advertisements. Ad blockers seriously impact this revenue to the point where some writers cannot afford to keep services running or content updated. Personally, my income from Adsense is a third of what it was 5 years ago. While it cannot be all attributed to ad blockers, they certainly do not help.

There is a simple trick which you can use to track ad blockers and detect if Adsense codes have been blocked. This method relies on a few JavaScript variables which Adsense uses. If Adsense is blocked, then these variables are not set. We can test from this and send an event to Analytics for logging. Once you have some data on the percentages of ad blocked visitors you can take steps to mitigate the problem.

Of course, if the Ad Blocker is also blocking Analytics this method won't work, but you could adapt it to log elsewhere. You can also adapt the code to work on other ad publishing platforms.

For these examples, you will need a Google Analytics and a Google Adsense account.

Ad Blocker Detection Code

The code is quite simple and can be copied and pasted into your website without changes. This is usually in the footer of the page, after your Analytics tracking script.

if(typeof adsbygoogle !== "undefined") 
if(typeof ga !== "undefined") 
  if(typeof adsbygoogle.loaded === "undefined") 
ga('send', 'event', { eventCategory: 'Income', eventAction: 'Adsense', eventLabel: 'Adsense Blocked', eventValue: 1});
ga('send', 'event', { eventCategory: 'Income', eventAction: 'Adsense', eventLabel: 'Adsense Not Blocked', eventValue: 1});

With this script logging an event to Analytics with the title "Ads blocked" or "Ads not blocked" you can then see in Google Analytics reports the proportion of page views which are ad blocked and how many are not blocked.

This script will wait until the page has finished loading then check for the adsbygoogle variable. It then basically checks the existence of the adsense and analytics codes and fires off an event depending on if the adsbygoogle is loaded or not.

Track Ad Blockers in Google Analytics

Now that the track ad blockers script has been added to the page, we need to wait a few days for the tracking data to start coming through. Once it does, you can view the events from the Behaviour > Events screen in Analytics reporting.

Track Visitors who block Adsense in Analytics
Track Visitors who block Adsense in Analytics

Last updated on: Saturday 26th August 2017



Have a question or suggestion? Please leave a comment to start the discussion.


Leave a Reply

Please keep in mind that all comments are moderated according to our privacy policy, and all links are nofollow. Do NOT use keywords in the name field. Let's have a personal and meaningful conversation.

Your email address will not be published.