Free Geo Redirection Script, Works with Banners and Redirects

Corrupt

BANNED
Joined
Sep 15, 2011
Messages
805
Reaction score
413
Fluff:
A member here recently asked for a geo-redirection script, which redirects the user to a different CPA offer based on his country. I was using a similar approach for displaying different banners on a site based on geolocation, so I offered to modify the script for his purpose and give it to him. I also realized that a lot of people suffer with this aspect of Internet Marketing. They either don't know how to, or ignore geo-targeting, so decided to share this simple script here.

Non-Fluff:
Geo-targeting can increase your income by monetizing the traffic not meant for your default country.
We all know that most of the CPA offers are targeted for the USA, and if even 80% of our traffic is from the USA, we'll lose out on the 20% traffic that can easily be monetized with appropriate offers. So, we use geo-targeting to display different offers from country to country.

What this script does:
It either displays different CPA offers on a webpage for different countries, or redirects the user to different offers for different countries. All the instructions on how to use it are enclosed in a readme.txt file.

Download Link:
Code:
http://www.mediafire.com/download.php?v2ufzo83vlwchvn


Virus Scan(0/43):
Code:
http://www.virustotal.com/file-scan/report.html?id=f4a7dd9b25e74dd47c75b61289b814975a7af8b7e4154d2ed7e035a8aa8387c6-1326224559
I tried ending this thread quickly before alcohol got the better of me, so forgive me for being quick.
I'll probably make a better version of this script as soon as I have the time, and share it here, right now I'm busy with lots of pending work due to exams.
If you have any questions, please post them in this thread and I will resolve them here, so it can benefit other members as well.
 
thankful.jpg


I was that member haha =) Really appreciating this, it surely does complete the project I was working on since.. since. I will check it out in a few moments, will let you know if I managed it correctly or not :)

Repped + Thx
 
Hey Corrupt,

For the script to work, you need to remove the tab "\t" that's added to the CountryCode variable returned by the geoip script. Otherwise the string comparison won't work and all traffic will be treated as international.

This means line 9 of index.php should be:
Code:
$CountryCode = geoip_country_code_by_addr($gi, $IP);
Also, there's a lot of unnecessary whitespace in the index.php file that's caused by putting everything within separate <?php ?> tags. It caused issues on my web server, and I presume it will with other peoples' servers as well. PHP short tags are also used, which are not universally supported.

I would suggest removing all extraneous <?php ?> tags and using php echo for reproducing plain text.

Here's my updated index.php code:
Code:
<?php

$IP = $_SERVER["REMOTE_ADDR"];

include("geo/geoip.inc");

$gi = geoip_open("geo/GeoIP.dat", GEOIP_MEMORY_CACHE);

$CountryCode = geoip_country_code_by_addr($gi, $IP);
geoip_close($gi);

// ****DO NOT TOUCH ABOVE THIS LINE.******
//***Consult the Readme if you aren't sure what you're doing****

if ($CountryCode=="US"){

    //US offers go here
    
}

//Add or remove these else if statements depending on which countries you have offers for

    else if($CountryCode=="GB")
    {
        //UK offers go here
    } 
    
    else if($CountryCode=="AU")
    {
        //AU offers go here
    } 
    
    else if($CountryCode=="DE")
    {
        //DE offers go here
    }

else {

    //Change this to reflect your international offers for country codes not listed above
    echo 'INTERNATIONAL OFFERS GO HERE';
}

?>
 
I hope this will work too, seems fixed every here and there
 
[7:43:11 AM] Corrupt: Thanks for fixing up the \t issue
[7:43:17 AM] Corrupt: As for the excessive php tags
[7:43:40 AM] Corrupt: I changed the original script to include more tags to make it easier for the guys to add new offers
[7:43:57 AM] Corrupt: Otherwise I had it in a compact form on my own installation



@Madruga,
If you need any help setting it up, add me on Skype.
 
Hey Corrupt,

For the script to work, you need to remove the tab "\t" that's added to the CountryCode variable returned by the geoip script. Otherwise the string comparison won't work and all traffic will be treated as international.

This means line 9 of index.php should be:
Code:
$CountryCode = geoip_country_code_by_addr($gi, $IP);
Also, there's a lot of unnecessary whitespace in the index.php file that's caused by putting everything within separate <?php ?> tags. It caused issues on my web server, and I presume it will with other peoples' servers as well. PHP short tags are also used, which are not universally supported.

I would suggest removing all extraneous <?php ?> tags and using php echo for reproducing plain text.

Here's my updated index.php code:
Code:
<?php

$IP = $_SERVER["REMOTE_ADDR"];

include("geo/geoip.inc");

$gi = geoip_open("geo/GeoIP.dat", GEOIP_MEMORY_CACHE);

$CountryCode = geoip_country_code_by_addr($gi, $IP);
geoip_close($gi);

// ****DO NOT TOUCH ABOVE THIS LINE.******
//***Consult the Readme if you aren't sure what you're doing****

if ($CountryCode=="US"){

    //US offers go here
    
}

//Add or remove these else if statements depending on which countries you have offers for

    else if($CountryCode=="GB")
    {
        //UK offers go here
    } 
    
    else if($CountryCode=="AU")
    {
        //AU offers go here
    } 
    
    else if($CountryCode=="DE")
    {
        //DE offers go here
    }

else {

    //Change this to reflect your international offers for country codes not listed above
    echo 'INTERNATIONAL OFFERS GO HERE';
}

?>

Hello,

Where it says - US offers goes here.

Do I need to put it like this

//<?php header('Location: http://usoffer.com'); ?>

Or like this

//http://usoffer.com

Thanks
 
Hello,

Where it says - US offers goes here.

Do I need to put it like this

//<?php header('Location: http://usoffer.com%27%29; ?>

Or like this

//http://usoffer.com

Thanks

The first one is correct, but remove the //
Put it like:
<?php header('Location: http://usoffer.com%27%29;/ ?>
 
I'm having some trouble getting this to work..

It's sending all traffic to catchall international offer, even when I defined other country codes, and I also deleted the "|t" argument.

Somebody help please :D


Thank you for the share!

-edit-
I would PM you, but I have less then 15 posts....
 
Paste your code here in code tags, remove the offer urls though
 
That was fast :D

Code:
<?php


$IP = $_SERVER["REMOTE_ADDR"];


include("geo/geoip.inc");


$gi = geoip_open("geo/GeoIP.dat", GEOIP_MEMORY_CACHE);


$CountryCode = geoip_country_code_by_addr($gi, $IP);
geoip_close($gi);


// ****DO NOT TOUCH ABOVE THIS LINE.******
//***Consult the Readme if you aren't sure what you're doing****


if ($CountryCode=="US"){


header('Location: /mt/13b4v264b4z213s254w2/'); 

}


//Add or remove these else if statements depending on which countries


else if($CountryCode=="UK")
{
//UK offers go here
header('Location: /mt/13b4v264b4z213s254w2/'); 
} 

    else if($CountryCode=="CA")
{
//CA offers go here
header('Location: /mt/13b4v264b4z213s254w2/'); 
} 
else if($CountryCode=="AU")
{
//AU offers go here
header('Location: /mt/13b4v264b4z213s254w2/'); 
} 

else if($CountryCode=="DE")
{
//DE offers go here
header('Location: /mt/13b4v264b4z213s254w2/'); 
}
else if($CountryCode=="IE")
{
//IE offers go here
header('Location: /mt/13b4v264b4z213s254w2/'); 
}
     else if($CountryCode=="NZ")
{
//NZ offers go here
header('Location: /mt/13b4v264b4z213s254w2/'); 
}
     else if($CountryCode=="FR")
{
//FR offers go here
header('Location: /mt/13b4v264b4z213s254w2/'); 
}
     else if($CountryCode=="BE")
{
//BE offers go here
header('Location: /mt/w2b4333494z213s254w2/'); 
} 
         else if($CountryCode=="CH")
{
//CH offers go here
header('Location: /mt/033443a464z213s254w2/'); 
} 
             else if($CountryCode=="AT")
{
//AT offers go here
header('Location: /mt/03344384f4z213s254w2/'); 
} 
                 else if($CountryCode=="NL")
{
//NL offers go here
header('Location: /mt/x25423c4e4z213s254w2/'); 
} 
                     else if($CountryCode=="PL")
{
//PL offers go here
header('Location: /mt/1384138494z213s254w2/'); 
} 
                         else if($CountryCode=="NO")
{
//NO offers go here
header('Location: /mt/z2a4z254a4z213s254w2/'); 
} 
    
                         else if($CountryCode=="FI")
{
//FI offers go here
header('Location: /mt/z2a4z254a4z213s254w2/'); 
} 
                             else if($CountryCode=="DK")
{
//DK offers go here
header('Location: /mt/z2a4z254a4z213s254w2/'); 
} 
                             else if($CountryCode=="SE")
{
//SE offers go here
header('Location: /mt/z2a4z254a4z213s254w2/'); 
} 
                                 else if($CountryCode=="SA")
{
//SE offers go here
header('Location: /mt/x254333474z213s254w2/'); 
} 
                                     else if($CountryCode=="IN")
{
//SE offers go here
header('Location: /mt/x25423c4f4z213s254w2/'); 
} 
else {


//Change this to reflect your international offers for country codes not listed above

    
header('Location: /trafficoptimizer/index.php?toid=70506&r=lc356993'); /* Stuur de browser naar */
}


?>
 
Just to be sure, did you check using proxies?
 
I'm not on proxies but good suggestion :)

-edit-

the other code is not the problem

the ip's aren't catched and redirected accordingly..
 
Last edited:
I'm not on proxies but good suggestion :)

-edit-

the other code is not the problem

the ip's aren't catched and redirected accordingly..

Did you copy paste all the files properly? Do it again, except the index/redirect.php script. Don't change the directory strucutre.
 
Hi Corrupt I have the same issue. I am getting the International Offers even when I go through a U.S. based proxy.

( I haven't even set up banners- I am just testing it).

Also, I can't get your include to work- it just shows blank space.


Here is my code:



include("geo/geoip.inc");


$gi = geoip_open("geo/GeoIP.dat", GEOIP_MEMORY_CACHE);


$CountryCode = geoip_country_code_by_addr($gi, $IP);
geoip_close($gi);


// ****DO NOT TOUCH ABOVE THIS LINE.******
//***Consult the Readme if you aren't sure what you're doing****


if ($CountryCode=="US"){


echo 'US OFFERS GO HERE';
}


//Add or remove these else if statements depending on which countries you have offers for


else if($CountryCode=="GB")
{
//UK offers go here
}

else if($CountryCode=="AU")
{
//AU offers go here
}

else if($CountryCode=="DE")
{
//DE offers go here
}


else {


//Change this to reflect your international offers for country codes not listed above
echo 'INTERNATIONAL OFFERS GO HERE';
}


?>
 
Put your US Proxy IP address here and see what location it gives you: http://www.maxmind.com/app/lookup_city

PM me your Skype id.
 
Thanks for the quick response

After a reboot it miraculously works

would give you my SK id but cannot PM you --if you want gimme yours

The only think I cannot get going is the include- when I try to include the first script from a second it renders blank--suggestions???
 
In case anybody is interested, I was able to implementing this thing for banners using an iframe.

Thanks again Corrupt and Ayomav for the code cleanup !!!!!!!!!!!!
 
Back
Top