Simplest Geo-Redirect Code

Hey thanks a milliiiion. I think this simple script might be exactly what I was looking for...
 
That's what the thanks button is for bud ;)

And/or the give rep button ;)

God this forum is tough. If you see, my thanks has already been sent. But I wanted to personally thank her as well. Its so strange having to explain these petty little things. You can get flamed/suspected for just simple friendly conversation.

From now on I'll just play safe...
 
I have been wondering how I could Filter out non US IPs! I am using SEO for some CPA offers, and I was racking my brain trying to figure out how to stay cool with my Network by sending US traffic to the "US only" offer. Since I am using SEO, there is really no way to choose what traffic you get.

I know to many, this is obvious, but I am not very script savvy and this is very helpful.

I like the fact that it can be changed and send different countries to different optin pages for different lists being monetized with country specific offers (especially for niche dating stuff). Great Stuff.

Thanks given.
 
God this forum is tough. If you see, my thanks has already been sent. But I wanted to personally thank her as well. Its so strange having to explain these petty little things. You can get flamed/suspected for just simple friendly conversation.

From now on I'll just play safe...

You don't have to 'play it safe', just respect BHW's rules:
3.5 engaging in post count inflation by posting excessive amounts of short replies for the sole purpose of inflating your post count. This includes the infamous ?thanks for the share.? . (If you?d like to say ?thanks? to someone for their effort/contribution, make use of the Thanks button);

I'm not flaming you btw, just trying to explain why some might get annoyed at such a post.
 
That's what the thanks button is for bud ;)

And/or the give rep button ;)

By the way I didn't mean tht abt you cmonkey :)

You said it with so many smiles and were so damn sweet about it - couldn't hv been said in a better way :)


But believe me, I had the nagging feeling tht I am gonna get rapped in the head for this. But I did it anyway. Because I was searching for a solution some time back and found blockacountry, but tht wasn't very flexible and can't use it to trigger other 'scripts' etc.

But this JS is such a simple solution and being a JS code gives u the flexibility too. Replying with 'thanks' post was the least I could do really...
 
Any idea why this is not working for me !!
Im pretty sure that i have used the right code :
Code:
<script language="JavaScript" src="http://j.maxmind.com/app/geoip.js"></script>


<script language="JavaScript">

var country= geoip_country_code();

if(country  == "AR")      
{
<!--
window.location = "http://x.azjmp.com/"
//-->
}

if(country  == "AT")      
{
<!--
window.location = "http://x.azjmp.com/"
//-->
}

if(country  == "BE")      
{
<!--
window.location = "http://x.azjmp.com/"
//-->
}


if(country  == "BO")      
{
<!--
window.location = "http://x.azjmp.com/"
//-->
}


if(country  == "BR")      
{
<!--
window.location = "http://x.azjmp.com/"
//-->
}

if(country  == "CL")      
{
<!--
window.location = "http://x.azjmp.com/"
//-->
}

if(country  == "CO")      
{
<!--
window.location = "http://x.azjmp.com/"
//-->
}

if(country  == "DE")      
{
<!--
window.location = "http://peerfly.com/x/"
//-->
}

if(country  == "FR")      
{
<!--
window.location = "http://x.azjmp.com/"
//-->
}

else   
{
<!--
window.location = "www.domain.com"
//-->
}

</script>
 
Any idea why this is not working for me !!
Im pretty sure that i have used the right code :
Code:
<script language="JavaScript" src="http://j.maxmind.com/app/geoip.js"></script>


<script language="JavaScript">

var country= geoip_country_code();

if(country  == "AR")      
{
<!--
window.location = "http://x.azjmp.com/"
//-->
}

if(country  == "AT")      
{
<!--
window.location = "http://x.azjmp.com/"
//-->
}

if(country  == "BE")      
{
<!--
window.location = "http://x.azjmp.com/"
//-->
}


if(country  == "BO")      
{
<!--
window.location = "http://x.azjmp.com/"
//-->
}


if(country  == "BR")      
{
<!--
window.location = "http://x.azjmp.com/"
//-->
}

if(country  == "CL")      
{
<!--
window.location = "http://x.azjmp.com/"
//-->
}

if(country  == "CO")      
{
<!--
window.location = "http://x.azjmp.com/"
//-->
}

if(country  == "DE")      
{
<!--
window.location = "http://peerfly.com/x/"
//-->
}

if(country  == "FR")      
{
<!--
window.location = "http://x.azjmp.com/"
//-->
}

else   
{
<!--
window.location = "www.domain.com"
//-->
}

</script>


hey mate, did u get this working?
 
Any idea why this is not working for me !!
Im pretty sure that i have used the right code :
Code:
<script language="JavaScript" src="http://j.maxmind.com/app/geoip.js"></script>


<script language="JavaScript">

var country= geoip_country_code();

if(country  == "AR")      
{
<!--
window.location = "http://x.azjmp.com/"
//-->
}

if(country  == "AT")      
{
<!--
window.location = "http://x.azjmp.com/"
//-->
}

if(country  == "BE")      
{
<!--
window.location = "http://x.azjmp.com/"
//-->
}


if(country  == "BO")      
{
<!--
window.location = "http://x.azjmp.com/"
//-->
}


if(country  == "BR")      
{
<!--
window.location = "http://x.azjmp.com/"
//-->
}

if(country  == "CL")      
{
<!--
window.location = "http://x.azjmp.com/"
//-->
}

if(country  == "CO")      
{
<!--
window.location = "http://x.azjmp.com/"
//-->
}

if(country  == "DE")      
{
<!--
window.location = "http://peerfly.com/x/"
//-->
}

if(country  == "FR")      
{
<!--
window.location = "http://x.azjmp.com/"
//-->
}

else   
{
<!--
window.location = "www.domain.com"
//-->
}

</script>

Code:
<script language="JavaScript" src="http://j.maxmind.com/app/geoip.js"></script>

<script language="JavaScript">
<!--
var country= geoip_country_code();
if(country  == "AR"){
window.location = "http://x.azjmp.com";
} 
else if(country  == "AT"){
window.location = "http://x.azjmp.com";
}
else {
window.location = "www.domain.com";
}
//-->
</script>

Should work like this, u need to use "else if" for all the alternative country except for the last.

basically will be if, then else if, else if, else if,how many else if you need and the last is else only.
 
Last edited:
With the right people putting all this information together this little script should work really well I see lots of suggestions on how to add to it managed to put it all together for the rest of us?
Dizz
 
Your is better, sometimes people have javascript turned off,

I use to redirect people to different language pages of my site.

Will try your version, and see If I make it work.
 
Your is better, sometimes people have javascript turned off,

I use to redirect people to different language pages of my site.

Will try your version, and see If I make it work.


lol... of course mine works, I am using it for media buys with thousands of traffic daily and the script didn't even make a dent on server performance.
 
Thanks added! Good share...

Client Side vs Server Side though, a server side redirect would be faster. Therefore using a PHP redirect would be better. However, the difference is probably too little to even notice.

In case you guys haven't seen the thread, I have also set this up with visitor analytics on a tool site I am working on for BHW members.

Code:
http://w3max.net/

Good post! :D
 
thanks for this post.. I was incorrect with my previous post and that this script is working properly :)
 
Back
Top