$4.96

What is the best way to detect ad blocker

Ask a question+
2

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

Vazgen Manukyan 610
add comment

2 Answers

1

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

This function detects the height of the AD. If it’s 0, it’s clearly blocked. This function 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

Lainrawr 305
add comment
0

I have come up with an idea of how to estimate. It is not the best solution, 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.

Arthur Dilanyan 530
add comment

Your Answer