Hello Elites,
I wrote a comment in another thread about geo redirection and I saw some of you are confused about it. So I decided to share a really simple and of course free php script, to redirect your visitors to the correct CPA offer based on their country. You know, if you promote an offer where only USA visitors are allowed, then your visitors from other countries are redirected somewhere else, to a different offer, which often not related to your main offer. So best option is to pick you your offers for all the targeted countries and redirect them by yourself! Some networks has a builtin tool to do this, but sometimes there isn't.
Of course no one wan't to pay for such a simple thing, which can be made in 5 minutes. But I know, most of you don't have programming knowledge, so I share this script with you.
Let's get started:
[hide]
Log in to your FTP client and locate the folder where you want to place your redirect script. Make a new file with .php extension, let's name it redirect.php
Place the following code inside:
PHP Code:
<?php
$a = unserialize(file_get_contents('http://www.geoplugin.net/php.gp?ip='.$_SERVER['REMOTE_ADDR']));
$countrycode= $a['geoplugin_countryCode'];
if ($countrycode=='US')
header( 'Location: https://www.cpagrip.com/show.php?l=0&u=97145&id=9378&tracking_id=' ) ;
else if ($countrycode=='GB')
header( 'Location: https://www.cpagrip.com/show.php?l=0&u=97145&id=9643&tracking_id=' ) ;
else if ($countrycode=='CA')
header( 'Location: https://www.cpagrip.com/show.php?l=0&u=97145&id=5882&tracking_id=' ) ;
else if ($countrycode=='FR')
header( 'Location: https://www.cpagrip.com/show.php?l=0&u=97145&id=9970&tracking_id=' ) ;
else if ($countrycode=='AU')
header( 'Location: https://www.cpagrip.com/show.php?l=0&u=97145&id=5872&tracking_id=' ) ;
else if ($countrycode=='IE')
header( 'Location: https://www.cpagrip.com/show.php?l=0&u=97145&id=10791&tracking_id=' ) ;
else if ($contrycode=='TR')
header( 'Location: https://www.cpagrip.com/show.php?l=0&u=97145&id=9654&tracking_id=' ) ;
else if ($countrycode=='IN')
header( 'Location: https://www.cpagrip.com/show.php?l=0&u=97145&id=10815&tracking_id=' ) ;
else
header( 'Location: http://google.com' ) ;
?>
The URLs in the code are just examples!!! CHANGE it to your own offer URLs.
You can see, the code is really simple. The $countrycode variable contains the code of visitors country. So you can just check it, wheter it matches with some countries, or not.
The last "else" contains the case, if none of the above countries matches you visitors country. Then your visitor will be redirected to here. This is a default case URL, so if you pick offers for 10 countries, then all of the visitors from the remained countries will be redirected here.
You can easily add new countries, just add a new "else if", above the last "else".
For example:
PHP Code:
else if ($countrycode=='IN')
header( 'Location: https://www.cpagrip.com/show.php?l=0&u=97145&id=10815&tracking_id=' ) ;
else if($countrycode=='HU')
header( 'Location: http://google.hu' ) ;
else
header( 'Location: http://google.com' ) ;
The country codes can be found here:
http://www.geoplugin.com/iso3166
[/hide]