My web site is based on PHP-MySQL. I have adsense ads in my site. I would like to hide adsense ads for the visitors of a specific country (Example: Nepal). So when the visitors of Nepal visit my site they will not see adsense ads on my site. Other visitors from other countries will see the ads normally. Is it possible? Please tell me the ways. Thank you.
You could always have a php script that checks IP address against a list of known IP addresses (from the specific countries) and store the result.. then just put the ads in a if statement to allow or block depending on IP.. just a quick and random thought
I see this threat is a little bit old but maybe someone have solution in 2016 Is there something wth htaccess ? How to hide Adsense ads for specific countries?
Here are a couple examples using .htaccess and php: http://stackoverflow.com/questions/9838344/how-to-redirect-domain-according-to-country-ip-address You can point your iframes or javascript code to your php script and it will sort out your traffic.
You can simply redirect the users from the undesired countries to a blank page or alternative ads. I don't really understand how it is unrelated.
Users JP and ogah have already given the answer, just use an IP location database and some if statements to block ads for certain countries. I actually use statements like this quite often to display optimized ads based on location
Thanks JP for this answer.Can you please just tell me do you have that script to i can implement in root folder or what is the best way to make that to work. I need a step by step guide how to do that because i am not familiar with those kind of things. Thanks
http://www.geoplugin.com/webservices/php You can use a free service. require_once('geoplugin.class.php'); $geoplugin = new geoPlugin(); // If we wanted to change the base currency, we would uncomment the following line // $geoplugin->currency = 'EUR'; $geoplugin->locate(); if ($geoplugin->countryCode == 'US' ) { //some adcode display } PHP: Repeat for whatever other countries you may have. You could also use a switch statement
If your template can handle PHP then by all means download the php class and dump it in your template.
Ok i have download php class and contain two files geoplugin.class.php and index.php Now in which file i can put some country code to hide adsense? Can you send me one example here for France code in example for test? To i can see how to do that. Thanks