Test AdBlocker – Is the AdBlocker active? (+ Adblocker Detection Script)

You want to know if your AdBlocker works or if the visitors of your website have activated an AdBlocker? Then you’ve come to the right place!

AdBlockers are browser extensions that block banner ads and pop-ups. For visitors, this is very pleasant, but for website operators who want to generate revenue, it is of course very annoying. Many sites therefore block their content for users of AdBlockers often completely. A German example is bild.de.

Test AdBlocker

If you want to know whether your AdBlocker is working, you just have to look into the following window. If there is a big red area with the step “Adblock detected!” your AdBlocker is working. However, if there is a green area with “Adblock disabled”, your ad blocker is not active or does not block ads correctly.

Improve user experience and earn money at the same time?

AdBlocker Detection Script (with JavaScript)

How to detect Adblocker? I also provide you with the script to check if a visitor is using an AdBlocker. Whether you then deny the user access completely or simply give him a nice hint is up to you.

The principle is quite simple: it tries to load a standard JavaScript file from Google. If this succeeds, no AdBlocker is active, if it does not succeed, an AdBlocker is active. This works because AdBlockers block the connection to exactly this script.

fetch('https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js').then(() => {
  document.getElementsByClassName('message')[0].innerHTML = 'Adblock disabled! :)';
  document.getElementsByClassName('message')[0].classList.add('no-ab');
}) .catch(() => {
  document.getElementsByClassName('message')[0].innerHTML = 'Adblock detected!';
  document.getElementsByClassName('message')[0].classList.add('ab');
});

Conclusion

When using this script, you should think carefully about 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 disable the AdBlocker.

Related Posts
Join the Conversation

3 Comments

  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
removeFormat
createLink unlink
code

This can also interest you