The Most Active and Friendliest
Affiliate Marketing Community Online!

“Propeller”/  Direct Affiliate

How to insert geo location banner?

M

maurosicard

Guest
Hello friends,

I want to insert some different banners in a WordPress site, but I want to be different banners depending on the country.

Is there a way to do this? ,

Thank you very much
 
Maybe there are some plugins that will do it much better than this, but I'll give you a code which should work.
Put this on the header of your page(inside the <head> tag):
<script src="http://j.maxmind.com/app/geoip.js"></script>

Put this exactly where the banner should be placed:
<script>
var banner={};
banner['default']='<a href="banner link when you click on it"><img src="default banner source" /></a>';
//banner['default'] is the banner for the visitors who are from countries that are not in the banner list below

banner['US']='<a href="banner link when you click on it"><img src="US banner source" /></a>';
banner['FR']='<a href="banner link when you click on it"><img src="FR banner source" /></a>';
//....use the same pattern for the countries you need

var country_code=geoip_country_code();

if(banner[country_code]!=null)
document.write(banner[country_code]);
else
document.write(banner['default']);

</script>
 
Last edited:
MI
Back