Do you want to disallow some IP to see adsense ads in your website? For instance do you want your adsense ads not to be shown in your own computer (IP) or IP address of spammers?
You can do this by simply using a PHP code. Continue reading to find more.

So the basic idea is to ban or disallow some IP address from shopping adsense ads in your website.
So after you implement the idea or code given below the IP address you list in the code will not be able to see adsense ads in your website.

This Idea is very useful if you want to block spammers and bots or your own computer from displaying adsense ads in your website.

Basically this code will first check the IP address of the client computer and if the IP matches any of the IP listed in the code then the adsense ads will not be shown in the computer or browser else the client will be able to see the adsense ads.

So here is the code for the job:



<?php
$visitorIP = $_SERVER['REMOTE_ADDR'];
$blockedips = array('123.45.67.89', '123.45.67.89');
if (!in_array($visitorIP,$blockedips)) {
?>

Write your adsense code here.

<?php
}
?>

So all you have to do is replace the IPs listed in the code as 123.45.67.89 with the IP you want to block if you want to block more or less than two IPs then you can add or delete IP in the same format separated by comma , and replace “Write your adsense code here” with your adsense code.

You are done now!
So now the IP listed in the array will not see ads in your website when they will open your website.



Popular Searches: