How to Track Ad Block with Google Analytics

How to Track Ad Block with Google Analytics

Did you know that up to 5% of website visitors are now using some form of Ad block software? When you consider the in-your-face marketing tactics of many websites, you can’t blame those who want to avoid adverts at all costs.

A growing number of users are now looking to platforms such as AdBlock Plus to remove the ‘clutter’ from day-to-day browsing. This is bad news for those websites which rely heavily on this form of marketing. Fortunately, webmasters can utilise the power of Google Analytics to track those visitors which have ad block software installed. It could uncover some alarming statistics and encourage the uptake of other marketing strategies to account for this loss of revenue.

Take a look at this straightforward approach to tracking all those ad block users.

Add the code

The following code defines a plugin which tracks ad blocking software via the custom dimension index. If you already have analytics.js set up, simply update this code on your site manually:

(function(i,s,o,g,r,a,m){i[‘GoogleAnalyticsObject’]=r,i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,’script’,‘https://www.google-analytics.com/analytics.js’,‘ga’);
// Creates an adblock detention plugin.
Ga(‘provide’, ‘adblockTracker,’ function(tracker, opts) {
Var ad = document,createElement(‘ins’);
ad.className = ‘AdSense’;
ad.style.display = ‘block’ ;
ad.style.position = ‘absolute’ ;
ad.style.top = ‘-1px’ ;
ad.style.height = ‘1px’ ;
document.body.appendChild(ad);
tracker.set(‘dimentsion’ + opts.dimentsionIndex, !ad.clientHeight);
document.body.removeChild(ad);
});
// TODO: Replace UA-XXXXX-Y with you tracking ID.
// and replace ZZ with the index of the custom dimension you created.
ga(‘create’, ‘UA-XXXXX-Y’, ‘auto’);
ga(‘require’, ‘adblockTracker’, {dimensionIndex: ZZ});
ga(‘send’, ‘pageview’);

As you can see, the two pieces of text shown in red need to be replaced with your unique information.

Configuring Google Analytics

Once you’ve added the code, the next step is to set up the Google Analytics front end elements which includes custom dimensions and segments. In order to configure the former, you’ll need Admin privileges.

After clicking on the Admin link in the top navigation pane, you’ll find the tab PROPERTY, and a link for ‘Custom Definitions’. Click on this and you’ll be given the option to ‘+ New Custom Dimension’. Name this new dimension ‘Ads Blocked’, set the scope to ‘Hit’, check the box to ‘Active’ and hit ‘Save’.

Next you’ll need to setup an advanced segment. Don’t panic, it’s easier than it sounds.

Simply go into any report in Google Analytics. Here you’ll find the link ‘+ Add Segment’ which is above the main graph. Click on this and the create segment window will pop up. On the left hand side, choose ‘Advanced’ then click on ‘Conditions’.

Using the search box in the top right, now type in ‘Ads Blocked’ or whatever you chose to name your custom dimension. This will now show up and you can click to add this as a filter. Finally, change the ‘Contains’ box to ‘Exactly Matches’ and in the box on the right hand side, add the number 1.

Voila, you can track users who are blocking ads. Simply choose the Ads Blocked advanced segment once logged into Analytics and you’ll discover how many users are using ad block software. Other insightful information include the total number of ads blocked as well as geographical data by country.

Author Liam Firth

More posts by Liam Firth