Adblock Detector – Detect visitors with Adblocker

You advertise on your website but don’t generate any or low revenue? With this Adblock Detection script you (or your administrator) can recognize an adblocker and react accordingly.

Adblockers are browser extensions that block banner ads and pop-ups. For the visitor this is very pleasant, but for website operators the revenue is very annoying. Many sites therefore block their content completely for users of adblockers. A German example is

Here I provide you with a script that you can use to see if a visitor is using an adblocker. Whether you give the user access completely or just give him a nice hint is up to you.

The principle

The script is structured in such a way that we simulate an ad banner to the browser and then check whether our fake ad banner has been removed or is still visible.

Improve user experience and earn money at the same time?

Furthermore a timeout is built in, so that the page is loaded ready. Alternatively you can use the JavaScript DOMContentLoaded Event.

setTimeout(function() {

  var adblockEnabled = false;
  // add test element and get its styles
  document.body.innerHTML += '<div class="adsbygoogle" id="ad-detector"></div>';
  var adElement = document.getElementById('ad-detector');
  var adElementStyle = getComputedStyle(adElement, null);

  if(adElementStyle.display === 'none') {	// Adblock enabled
    document.getElementsByClassName('message')[0].innerHTML = 'Adblock detected!';
  } else {	// Adblock disabled
    document.getElementsByClassName('message')[0].innerHTML = 'Adblock disabled! :)';

}, 1500);

You can use the marked lines in my demo version to perform your own actions. Complete hiding of the content or a nice hint are common possibilities here.


When using this script, you should consider whether you want to hide the content directly or just give the user a nice hint. In any case, it makes sense to include instructions or at least a link to temporarily deactivate the adblocker.

I hope the contribution has helped you and I would be happy about a repeated visit on this side! 🙂

Related Posts
Join the Conversation


  1. Ahmet says:

    Thanks You!

    1. Lorenz says:

      I’d be glad to!

Your email address will not be published.

bold italic underline strikeThrough
insertOrderedList insertUnorderedList outdent indent
createLink unlink

This can also interest you