Search code examples
javascripthtmlbrowseradblock

Dispalying ads on browsers protected by Adblock


I understand that people don't want to see ads but as a developer I would like to make money from ads on my site. How to add an ads to my site so Adblock will not block my content ?


Solution

  • I think it is important to realize that this is a game of escalation. If someone finds a way to get around AdBlock, then the developers maintaining it will mobilize resources to prevent that work around. In the end, you will end up spending more time trying to beat AdBlock than can be justified by the potential ad revenue that you are missing out.

    This also does not take into account that, by bypassing AdBlock, you will annoy your users, and risk losing them instead.

    Another option is to merely detect if the user has AdBlock. You could then choose to do one of the following:

    1. Point out to the user that the site operates off ad revenue, and politely ask them to disable AdBlock. This is probably the best approach unless you have highly desirable content, in which case you might want to try another monetization model.

    2. Disallow access to your site (also called gated content) until the user disables AdBlock. Notably Forbes uses this particular strategy.

    You can use a library like BlockAdBlock (note that, despite the name, this does not in any way work around AdBlock) to detect ad blockers like this:

    // This is needed because AdBlock might block BlockAdBlock
    if(typeof blockAdBlock === 'undefined') {
        adBlockDetected();
    } else {
        blockAdBlock.onDetected(adBlockDetected);
    }
    
    // Function to be called if AdBlock was detected
    function adBlockDetected() {
        // Display a plea to the user, or
        // gate the content
    }