Need Help with Geo-Target Banner Rotator

supaH

Junior Member
Joined
Nov 22, 2011
Messages
123
Reaction score
23
I've looked and searched everywhere and I just can't fine a working script like this.

What I need is a banner rotator that shows certain banners for specific countries.

Example:
Code:
if (country = "US"
{
  <img src="show US Banner"/>
} 
else if (country = "UK") 
{
 <img src="show UK Banner/">
}

etc etc
Using this: http://j.maxmind.com/app/geoip.js
To get users country code.

I've used and know how to do if/else scripts for java&html but I just don't understand how to find then use the visitors country in the if statement.

This script is for CPA offers, so its important to show the right offer to the right country.

If anyone can help me that would be awesome, I've been Googling this every which way I can think of and I just can't get it.
 
You simply access the global functions that are created when you include the geoip javascript file:
Code:
var country = geoip_country_code();
if(country==='US'){
  // do something...
}
else if(country==='UK'){
  // do something else...
}

Note: I think this implementation of Maxmind's JavaScript GeoIP API was supposed to be disabled at the beginning of the month. A new js api which requires registration and costs a lot more for larger volumes will be replacing it. You might want to look at their new one or setup your own as this probably won't be very stable.
 
Funny I was just looking for this today.
Ever considered just using OpenX or Adzerk? Waaaay better, with alot more monetizing possibilities.
 
I've managed to come up with something that actually worked. For those wondering, here is the working code I now have.
Code:
<html>
<head>
<script language="javascript" src="http://j.maxmind.com/app/country.js"></script>
</head>

<body>
<div id="banner"></div> // Place this div where you want the banners to show
</body>

<script type="text/javascript">
var country = geoip_country_code();
if(country==='US'){
  document.getElementById('banner').innerHTML = '<a href="http://redirecturl" target="_blank"><img src="https://.gif" /></a>';
}
else if(country==='CA'){
   document.getElementById('banner').innerHTML = '<a href="hhttp://redirecturl" target="_blank"><img src="https://.jpg" /></a>';
}
else if(country==='UK'){
   document.getElementById('banner').innerHTML = '<a href="http://redirecturl" target="_blank"><img src="https://.gif" /></a>';
}
else // if none of the countries above
{
// Don't show a banner
}
</script>
</html>

I did some basic commenting on the script as well. As for using the maxmind.com javascript function, I will be on lookout for a replacement as they are probably going to disable it eventually.
 
do a search for geo targetting in here.. just before few days i posted a php code solution that helped another member in here.
 
do a search for geo targetting in here.. just before few days i posted a php code solution that helped another member in here.

Ya I did search but it just gave a ton of things not relevant to what I was looking for. Also I'm much more comfortable using Javascript & Html than php.
 
Why don't you join Adzerk, Epom or some other ad server? It's really easier, and afterall you'll get more profit with other targeting features. For example, Epom has awesome "custom targeting" feature, and if we're talking about geo targeting only - they can target even small towns! and it's free for 60 days.
 
I've managed to come up with something that actually worked. For those wondering, here is the working code I now have.
Code:
<html>
<head>
<script language="javascript" src="http://j.maxmind.com/app/country.js"></script>
</head>

<body>
<div id="banner"></div> // Place this div where you want the banners to show
</body>

<script type="text/javascript">
var country = geoip_country_code();
if(country==='US'){
  document.getElementById('banner').innerHTML = '<a  href="http://redirecturl" target="_blank"><img src="https://.gif"  /></a>';
}
else if(country==='CA'){
   document.getElementById('banner').innerHTML = '<a  href="hhttp://redirecturl" target="_blank"><img src="https://.jpg"  /></a>';
}
else if(country==='UK'){
   document.getElementById('banner').innerHTML = '<a  href="http://redirecturl" target="_blank"><img src="https://.gif"  /></a>';
}
else // if none of the countries above
{
// Don't show a banner
}
</script>
</html>

I did some basic commenting on the script as well. As for using the maxmind.com javascript function, I will be on lookout for a replacement as they are probably going to disable it eventually.


is this still work sir?
 
Back
Top