How to Detect and Block Ad Blockers

This tutorial explains how to detect if your reader is using an ad blocker. Ad blocking software (and extensions) are used to stop annoying advertisements from being displayed on websites.

Fermare Ad Blocker
Fermare Ad Blocker

Ad blocking creates a user-friendly experience for readers without advertisements but causes a significant percentage of revenue loss. Revenue loss for publishers due to the use of ad blocking software is close to 15-25% of their earnings. According to research conducted by Adobe, ad blocking is responsible for an estimated loss of around $22 billion in online advertising.

There are many ad blockers on the market. The most popular ones are AdBlock Plus, AdBlock, AdGuard, Stands Fair Adblocker, etc. To detect them, we need a generic solution that should not be specific to any particular ad-blocking software or extension and should work regardless of the browser used by the user. The following solution is a Javascript-based method to find out if ad blocking is enabled at the user level.

 

window.onload = function() {
    setTimeout(function() {
        var ad = document.querySelector("ins.adsbygoogle");
		var modal = document.getElementById("myModal");

        if (ad && ad.innerHTML.replace(/s/g, "").length == 0) {
  			modal.style.display = "block";
        }

    }, 2000);
};

If you are using Blogger or any other blogging platform, you can wrap the CSS and Javascript code provided above in tags as follows.

<style type="text/css">
YOUR CSS CODE
</style> 
<script type="text/javascript">
//<![CDATA[ 
YOUR JAVASCRIPT CODE
//]]>
</script> 
Pubblicato in

Se vuoi rimanere aggiornato su How to Detect and Block Ad Blockers iscriviti alla nostra newsletter settimanale

Be the first to comment

Leave a Reply

Your email address will not be published.


*