This script will redirect users from specific countries to wherever you’d like them to go.
This is useful when your CPA offer automatically redirects based on country and you are having a tough time getting it approved, or when you are optimizing a campaign and need a way to redirect traffic from a certain country to a different offer.

A lot of times traffic sources will send you some international traffic even though your campaign is set to a specific country, so it makes sense to send those visitors to an offer that accepts their country.

Step 1: Download Geo-IP Plugin

—> Download

Step 2: Use This Code in Your Redirect File

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
<?php
// ccr.php - country code redirect
require_once('geoplugin.class.php');
$geoplugin = new geoPlugin();
$geoplugin->locate();
$country_code = $geoplugin->countryCode;
switch($country_code) {
case 'US':
header('Location: http://www.domain.com/links/usa.php');
exit;
case 'CA':
header('Location: http://www.domain.com/links/canada.php');
exit;
case 'GB':
header('Location: http://www.domain.com/links/greatbritain.php');
exit;
case 'IE':
header('Location: http://www.domain.com/links/ireland.php');
exit;
case 'AU':
header('Location: http://www.domain.com/links/australia.php');
exit;
case 'NZ':
header('Location: http://www.domain.com/links/newzealand.php');
exit;
default: // exceptions
header('Location: http://www.domain.com/links/allelse.php');
exit;
}
?>
Here it is in .txt format so you may copy/paste without any quotes getting screwed up.

Example

I like to store all my outbound links in its own folder, so for this example let’s say the folder we are working in is domain.com/links – here is what it should look like.

geoip redirect

Now, whenever somebody goes to domain.com/links/redirect.php they will be redirected to the links you set based on the country they are in. Here is a full list of country codes.

1 comments:

Unknown said...

Good work,

If you want to expand the business into multiple countries, then its better to use GeoIP store selector feature in online store.
I have used FME GeoIP Store Selector Magento extension to create a personalized store view for specific countries.
Check the demo here: http://www.fmeextensions.com/magento-geo-ip-default-store-view.html