How Can Publishers Detect if Someone is Using an Ad Blocker?

Contents

Our Newsletter

Get AdTech & MarTech resources sent straight to your inbox

We respect your privacy. Learn more here.

The tug of war between publishers and those who resist display ads has been going on for some time now and is far from over. There is no way for users to make ad blockers completely invisible to sites or services that show anti-ad-blocking messages. Conversely, there is no way for publishers to make their websites completely and consistently immune to ad blockers.

The rise of ad-blocking software means publishers have to come up with new ways to make up the lost revenue, whether by using various custom-made ad re-insertion software or by putting up paywalls (like the one shown below from The Economist.)

While ad-blocking software can’t be detected by the websites directly, one can assume their presence by testing whether particular elements of the page have been displayed. This is half the battle; if such elements aren’t found, the publisher can display an anti-ad-block message kindly asking the visitor to either whitelist the page, highlighting the importance and benefits of not using ad-blocking software, or block access to the webpage completely (see image below).

Forbes

How Can Websites “Detect” Ad Blockers?

Websites can resort to a combination of simple methods that (at least) tell whether or not a visitor to the website is using an ad blocker. This usually involves the implementation of a “bait” script—a tiny piece of code that an ad blocker is likely to perceive as an ad.

Here’s an example of a website element that will work like bait and be hidden by AdBlock:

<div class="banner_ad">...</div>

The part that would trigger every ad blocker in the example above is the class name “banner_ad”, easily found among many other similarly named ad-related elements in most ad-blocker blacklists.

Incidentally, it is quite funny that the very same list AdBlock uses to hide ads can be used against it. The list is a double-edged sword; while it allows ad blockers to detect ads and stop them from being displayed, it is also relatively easy for publishers to identify which elements of their website are being blocked. What could those elements be?

The list includes various internal and external references to JavaScript files, CSS stylesheets, and images. The ad blocker compares the names of referenced scripts and files against the list, and if there are any matches, those files will be ignored. At the same time, such lists provide ample examples of possible baits for ad blockers. Have a look at EasyList yourself to get an idea of what ad blockers consider suspicious.

Anti-Ad-Blocking Scripts

An effective ad-block-detection script takes just a couple lines of code and is relatively easy to implement. There are a few providers that spare publishers the hassle of actually having to come up with their own script.

We Can Help You Build an AdTech Platform

Our AdTech development teams can work with you to design, build, and maintain a custom-built AdTech platform for any programmatic advertising channel.

Detectadblock

One of the easiest ways to detect ad-block is by using bait. An example of a common file name that will invariably trigger every ad-blocking script is “ads.js”. Knowing this, detectadblock.com proposes a method that requires a piece of JavaScript code to be saved, and creates a hidden section (div) to a file called “ads.js” and places it in the root directory of your website.

var e=document.createElement('div');

e.id='RZfrHsidDwbG';

e.style.display='none';

document.body.appendChild(e);

Publishers place the following JavaScript within their website’s HTML source code just above the tag. Its purpose is to check if the hidden div created within “ads.js” exists (ads are allowed) or not (ads are blocked). Simple as that!

<script src="/ads.js" type="text/javascript"></script>

<script type="text/javascript"><br />

if(document.getElementById('RZfrHsidDwbG')){<br />

  alert('Blocking Ads: No');<br />

} else {<br />

  alert('Blocking Ads: Yes');<br />

}<br />

</script>

IAB Script

The Interactive Advertising Bureau (IAB), an advertising-business organization that develops industry standards, runs its own tech lab and has proposed its own ad-block-detection script that creates a set of “bait” DIVs that are likely to be hidden by browser-based ad-blocking tools.

The script is really simple to set up, and the IAB runs its own Github page where you can find details about its inner workings.

F**k AdBlock

F**kAdBlock, also known as BlockAdBlock if you’re after a more G-rated name, is a community-developed anti-ad-blocking script. Similar to the aforementioned methods, it’s very simple and effective. Go to its website to see the code and example implementation.

The bait used by BlockAdBlock looks like this:

baitClass: 'pub_300x250 pub_300x250m pub_728x90 text-ad textAd text_ad text_ads text-ads text-ad-links'

This means it will trigger ad-blocking software by referencing typical names and popular IAB-recommended ad-image sizes: 300x250px, 300x250px, and the skyscraper 728x90px. All these strings are referenced in Easylist. The script then detects whether the elements were displayed on the page.

Alternative Methods

Detection of ad-blocking scripts and displaying information about the more ethical ways to enjoy a website’s content is just one of the possible ways to combat ad-blocking enthusiasts.

Ad Reinsertion

Another way publishers can take advantage is ad reinsertion, an emerging method that is arguably the least ethical and user-friendly way to fight ad blockers. While this technique does effectively stop ads from being blocked (at least for some time), its actual short-term and long-term implications (the lack of respect for the “please do not advertise to me” message) are unknown and have yet to be studied. Also, ad reinsertion is a constant cat-and-mouse game that may involve a lot of effort on the publisher’s side but bring little benefit at the end of the day.

Native Ads

Another good idea to effectively circumvent ad-blocking software is the use of native ads. These are inherently more difficult to detect, as the ad content is implemented in such a way to largely resemble the original content on the website. In-feed ads match the original editorial feeds in form and function, making them difficult to detect.

This is a very effective way to monetize content, and is used by some of the biggest players in the industry, including FacebookLinkedInTumblrTwitter, and Instagram. Major news media—including TimeForbesThe Wall Street Journal, and the The New York Times, quickly sensed potential and jumped on the native bandwagon.

Ad Blocking From the Publisher’s Perspective

An increasing number of internet users are taking advantage of ad blockers. PageFair, an international authority on ad blocking, in its 2017 report on ad blocking and online privacy, estimated that about 11% of the internet users are blocking ads on the web. The usage of ad block grew 30% in 2016. Also, a staggering 74% of American ad block users say they don’t even enter sites displaying ad-block walls. These statistics are hardly optimistic, and don’t bode well for the future of AdTech or “free” Internet in general.

The situation makes it increasingly important for advertisers to be able to identify when someone is using an ad blocker and to react. It can involve either restricting access to the website completely (like Forbes) or display a kindly reminder informing visitors that ads keep them afloat, and continue to provide content without a paywall, such as the one below from the Guardian.

We discussed the seven tactics recommended by IAB to combat ad blockers in one of our previous posts.

Summary

In this post, we’ve listed just a couple of ready-made, free scripts that publishers can use to detect ad blockers, but a simple Google search will certainly return dozens of similar examples. While detecting ad blockers may prove useful, we believe there is little benefit to advertising to people who explicitly don’t want to be advertised to.

Advertisers must not only try to respect the user’s wishes, but also understand the reasoning behind a decision to start using ad blockers in the first place. In most cases, the online advertising industry itself is to blame—intrusive and annoying ads, “you’ve won an iPhone” scam pop-ups, malware-infested ad networks, and blatant disregard for users privacy were the main phenomena that sparked the ad-blocking revolution.

After all, the emergence of ad-blocking software may be a prod for advertisers to better target their ads and make them appealing to users through content personalization, respect for privacy, and a delightful user experience.

We Can Help You Build an AdTech Platform

Our AdTech development teams can work with you to design, build, and maintain a custom-built AdTech platform for any programmatic advertising channel.

Reading recommendation

Read our online book

The AdTech Book by Clearcode

Learn about the platforms, processes, and players that make up the digital advertising industry.

Mike Sweeney

Head of Marketing

“The AdTech Book is the result
of our many years of experience in designing and developing advertising and marketing technologies for clients.”

Find out how we can help you with your project

Schedule a call with us today and find out how we can help you with your AdTech or MarTech development project.