What is the best way to detect ad blocker

Ask a question
2

I have a website that displays google ads. I was wandering how it is possible to detect the number of visits with ad blocker and display a message.

offer bounty
add comment

2 Answers

1

There is a fairly simple solution to this if you are open to using jquery. Also used PHP in here, but other languages are options too.Then simply store in a database table.

This function detects the height of the AD. If its 0, its clearly blocked. This functions works fairly well, can be tested here:
https://thepcspy.com/blockadblock/

function DetectAd() {
    if ($('.myAdIDForExample').height() == 0) {
        var x="<?php updateAdBlockAmount(); ?>";     //This calls my PHP function, seen below
    }else{
     var x="<?php updateAdNotBlockAmount(); ?>";     //This calls my PHP function, seen below
    }
    }
}

//Called on page load

$(document).ready(function(){
    DetectAd();
});

//PHP function

    function updateAdBlockAmount{
    Here you simply add another one to the blocked value in your table
    }
function updateAdNotBlockAmount{
Here you simply add another one to the NotBlocked value in your table
}

SQL table:
Blocked, Notblocked

add comment
0

I have come up with an idea of how to estimate. It is not the best solutions but I compare the page views in google analytics and google ad sense. So the ratio is what I am looking for. The website is w3docs.com and it shows that 51% of users (developers) use ad blockers.

add comment

Your Answer