Welcome to WebmasterWorld Guest from

Forum Moderators: martinibuster

Stop showing AdSense ads for a certain country

How not to show ads for a certain location

8:54 am on Aug 5, 2019 (gmt 0)

New User

joined:July 12, 2019
votes: 0

Hi guys!
Can anybody tell me how can I configure my website to stop showing AdSense for chinese visitors? There is a probability that someone from China may try to do harm to me.
Thank you
9:11 am on Aug 5, 2019 (gmt 0)

Senior Member

WebmasterWorld Senior Member topr8 is a WebmasterWorld Top Contributor of All Time 10+ Year Member Top Contributors Of The Month

joined:Apr 19, 2002
votes: 89

you need to have access to a geolocation database.

there are various ways of aquiring one for your own server. (both paid and free)

alternatively various companies offer a free API which you can use (usually limited in number of calls per month after which you have to pay)

use this to work out if the user is from china and then use php to not serve the adsense code on your page at the server level.
9:43 am on Aug 5, 2019 (gmt 0)

Senior Member

WebmasterWorld Senior Member Top Contributors Of The Month

joined:Nov 13, 2016
votes: 288

For PHP , you can use [php.net...]

If you can't use Geo IP db, you can more or less guess visitors from China, by looking at the reverse DNS of their IP and analysing the "accept-language" header field. But this can be too approximation and inaccurate , especially if someone is , on purpose, trying to harm you (he will be "smart" enough to send false information).

If someone is really involved in harming you, he will certainly do it also from other countries.

Join The Conversation

Moderators and Top Contributors

Hot Threads This Week

Featured Threads

Free SEO Tools

Hire Expert Members