landscape
Display Ad Server
Serve ads in standard fixed-size units
api
Native Ad Server
Build native ads into your web page or app
ondemand_video
VAST Video Server
Serve MP4 video ads as pre-rolls
Display Ad Server
Native Ad Server
VAST Video Ad Server
content_pasteRelease Notes
error_outlineNetwork Status
Terms of Service
Security Policy
Privacy/GDPR
roofingProductsarrow_drop_downFeaturesPricing
DocsSupport
menu
Ad Tags
auto_storiesMacros for Ad Serving
auto_storiesAMP HTML Ads
Best Practices
auto_storiesEvaluating 3P Ad Tags for Speed
Campaign Setup
auto_storiesFlight Dates, Quantity & Pacing
auto_storiesCampaign Tiers
Getting Started
auto_storiesGetting Started with AdGlare
auto_storiesAdGlare Glossary
Good To Know
auto_storiesAdblock Detection Script
auto_storiesRevive vs AdGlare
auto_storiesThe Importance of Async Ad Tags
auto_storiesAd Server Pricing
auto_storiesVideo Ad Server with VAST Support
License & Billing
auto_storiesCDN Bandwidth & Fees
auto_storiesDownload Invoice PDFs
auto_storiesCancel License
auto_storiesReplace Credit Card
auto_storiesUpgrade Plan
Native Ads
auto_storiesNative Ads API
Reports
auto_storiesConversion Tracking
auto_storiesMetrics & Dimensions
auto_storiesCustom Formulas
auto_storiesExporting Data
Targeting
auto_storiesFrequency Capping (GDPR)
auto_storiesKeyword Targeting
auto_storiesKey/Value Targeting
auto_storiesGeotargeting Locations
auto_storiesBrowser/OS/Device Targeting
Tutorials
auto_storiesWhite Labeled Ad Serving
auto_storiesBot Filtering for Ads
auto_storiesLazy-Loading Ads
auto_storiesKeeping Ads On The Screen
auto_storiesAdding a 3rd Party Tag
User-Interface
auto_storiesMove to different Folder

Adblock Detection Script

menu_book Knowledge Base chevron_right Good To Know
AdGlare Ad Server

Are you a publisher? Do you know what percentage of your visitors are using an ad blocker? If you don't, you may be loosing out on opportunities more than you think here in 2022. To find out, you need an Adblock Detection Script, which you can download here below.

You may have seen these "Adblock Detected" warning messages, asking users to disable their ad blocker in order to continue. Some publishers even completely deny access with an ad blocker enabled.

And that makes sense. Blog posts and articles are free of charge because we're monetizing this content by showing ads. From an economical perspective, a user with an ad blocker is like a scavenger: they eat away bandwidth and resources without any respect for those who've spend time and money writing the content.

Ad Block Detection Script
Image: an internet user with an ad blocker enabled.

Let's take a look at two options to combat this problem:

Option #1: Detect the presence of an Ad Blocker

Ad block detectors traditionally work by trying to load an external file that is likely to be blocked. For example:

https://www.adserver.com/ad.js
If either "adserver.com" or "ad.js" is on the block list, the file will not load. This can be detected, and thus suggests that an ad blocker is installed.

There's a second method to detect ad blockers: by using a CSS bait. It works by creating a DIV with a class name that is likely to be hidden by ad blockers. If we then verify if that DIV was indeed hidden, an ad blocker must have been active.

There are a few advantages using this method over more sophisticated alternatives:

  • It uses class names as a bait: no HTTP requests slowing down pages.
  • Ad block detection is incredibly fast.
  • Only a few lines of code - it's very small (782 bytes).
  • Simple function returning true/false.

Here's the Adblock Detector Code

Copy/paste this code to a test page to see how it works in your browser. You will see a message box returning true or false indicating if you have an ad blocker installed or not.

<script> /* Author: AdGlare Ad Server (https://www.adglare.com) */ function hasAdblock() { var a = document.createElement('div'); a.innerHTML = '&nbsp;'; a.className = 'ads ad adsbox doubleclick ad-placement carbon-ads adglare'; a.style = 'width: 1px !important; height: 1px !important; position: absolute !important; left: -5000px !important; top: -5000px !important;'; var r = false; try { document.body.appendChild(a); var e = document.getElementsByClassName('adsbox')[0]; if(e.offsetHeight === 0 || e.clientHeight === 0) r = true; if(window.getComputedStyle !== undefined) { var tmp = window.getComputedStyle(e, null); if(tmp && (tmp.getPropertyValue('display') == 'none' || tmp.getPropertyValue('visibility') == 'hidden')) r = true; } document.body.removeChild(a); } catch (e) {} return r; } alert('Has AdBlock: ' + hasAdblock()); </script>

Download from GitHub

You can find this code also on our GitHub page: https://github.com/adglare/adblock-detection-script.

Option #2: use a White Label Ad Server

By white-labeling the ad serving domain, ads are served from the domain on which the main content is hosted. Ad blockers inherently don't block this domain, as otherwise the main content would be blocked too.

To get around ad blockers, publishers need a white label ad server. Creatives can be uploaded to the CDN, which points via a CNAME DNS record back to the publisher's domain. Although it requires access to the domain's DNS records, it's relatively easy to set up.

But that's not all. Let's face the facts. People are using ad blockers mainly because:

  • ads are annoying or intrusive
  • ads may contain viruses
  • they don't want loud auto-playing videos

Here at AdGlare, we've developed tools to let you as a publisher see which ads may have a high annoyance factor. For example, you can see the total payload size in bytes, an audio wave of the video's music and a Quality Score (0 - 100). You'll also be suggested to enable auto-play only with sound disabled.

Circumventing AdBlock - AdGlare
Tools in AdGlare that help you to determine the 'annoyance' of an ad.

In Summary

As a publisher, you should be aware of AdBlock usage of your visitors. If only a small portion of your traffic cannot be monetized due to ad blockers, you can consider denying access to those visitors. If ad block usage is relatively high, a white label ad server is a great and simple way to get around it.

External Resources

Share This
Article!

emoji_peopleMore about AdGlare

Since 2013, AdGlare powers the ad serving stack of hundreds of brands and publishers worldwide. With ideas and suggestions coming from Publishers, AdOps and Marketeers like you, we're proud to offer one of the most up-to-date ad servers in the market. We adhere to IAB's LEAN Ads Program and Google's Coalition for Better Ads.

Are you a publisher or brand? Reach out to see how we can help you.