- Are my ads not loading properly?
- Are my ads underperforming?
- How many of my visitors never actually see them?
- Who's blocking my ads?
"It is a capital mistake to theorize before one has data" - Arthur Conan Doyle
Uncloaking the Ad Blocker Data
Ad Blockers are definitely not as invisible as they might like to think. Of course, that's not really their primary goal anyway. We'll tell you, step by step, how to copy-paste a little piece of JavaScript code to better understand your ad blocking traffic.
We're going to give you detailed configuration instructions. We'll also explain how to understand your new Google Analytics data. So what's the end result?
- You'll know what percentage of your visitors are using ad blockers
- You'll be able to determine the impact it has on your Ad revenue
First Things First - Your Prerequisites
To use this strategy, your site must have both Google Analytics and Google AdSense installed.
We use these as the key elements of the detection hack, which by the way is by courtesy of the great contributors at Webmaster World. They detect when AdSense isn't running as expected, which indicates that an ad blocker is in place. So that means ads from any network are most likely getting blocked too. All of your ads are gone... just like that.
FYI - For the purposes of our strategy, we're ignoring users who are disabling JavaScript entirely. This is a very small segment of your traffic. And they are very hard to track. They are likely highly techie/experienced users who are willing to accept a degraded presentation across the entire web.
Here's the TL;DR
You need this JavaScript snippet:
<script>
if(typeof adsbygoogle!== "undefined") {
window.addEventListener('load', function() {
if(typeof ga!== "undefined") {
if(typeof adsbygoogle.loaded === "undefined") {
ga('send', 'event', 'AdSense', 'Ads blocked', { "nonInteraction": 1 });
} else {
ga('send', 'event', 'AdSense', 'Ads not blocked', { "nonInteraction": 1 });
}
}
}, false);
}
</script>
If you want to track only "Ads blocked" events, you can use this modified version:
<script>
if(typeof adsbygoogle!== "undefined") {
window.addEventListener('load', function() {
if(typeof adsbygoogle.loaded === "undefined" && typeof ga!== "undefined") {
ga('send', 'event', 'AdSense', 'Ads blocked', { "nonInteraction": 1 });
}
}, false);
}
</script>
Now that you've pasted the above, let's go over to Google Analytics and get down to business:
- Create a Custom Segment
- Create New Segment for "Ads blocked"
- Configure new segment to grab data for the event created in the above JavaScript.
- Repeat for "Ads not blocked"
- Extra credit: Create a custom dimension
If you've installed snippets of code on your site before, you're good to go. If not, we really recommend you add a tag management system like Google Tag Manager. Otherwise, please contact your friendly neighborhood web developer for a quick code update.
Paste the code snippet just before the ending </body> tag of your site template. It needs to show up on every page. That's all you need for the code installation part.
Note: For this hack to work, your Google Analytics has to be Universal Analytics or the version containing "analytics.js."
What does the JavaScript code do?
This isn't a coding tutorial, so we won't bore you to death with any more technical complexity than needed. It's just a bit of really smart JavaScript. Here is what is happening step by step:
- Wait for the page to load, and then check to see if Google Analytics successfully loaded.
- If GA loaded JavaScript, then it is working, so check to see if your Google AdSense loaded too.
- Send some data to your Google Analytics account to indicate whether the ad was blocked or not.
And if AdSense doesn't load? Then we can reasonably infer that it was prevented from loading by an ad blocker. Busted!
That's it. Some slick code using some smart logic to segment the users that are ad blocking and those who are not. Then it sends this information into Google Analytics for your to review.
A single line of code tells Google Analytics to store an event for us. That event tells us whether we detected the ad blocked or not. That's it.
No comments:
Post a Comment