How to

How to GEO-Redirect CPA Traffic | Step By Step Tutorial

Some countries convert better on a particular CPA network while some on the other. That’s why we need a tool that could redirect automatically based on the location of the user. Therefore, In this Tutorial, we are going to learn how to do exactly that.

Step 1:

Navigate to the cPanel of your hosting and click “PHP Pear Packages.”

9JrQHgj.png

Step 2:
In the search box, type “GeopIp,” and click “GO.” You will see “Net_GeoIP (1.0.0)” is the 1st option. Install it by clicking “Install.”

aGBcGky.png

Step 3:

Now, that we have installed the PHP software, it’s time to get a database of IP ranges. Go over to this link and download the latest database.

ihH5kzS.png

Step 4:
Now, go to the file manager of your hosting and navigate to the “PHP” folder and then to the “NET” folder. Upload your downloaded database here. Make sure to upload the “.DAT” file and not the Gzipped archive.

Step 5:
Since everything is done on the software side, it’s time to create our PHP file. Make sure to replace the texts highlighted with your own.

<?php

// Change the location of both xyzs with your details
require_once ‘/home/xyz/php/Net/GeoIP.php’;
$geoip = Net_GeoIP::getInstance(‘/home/xyz/php/Net/GeoIP.dat’);

try {
$country = $geoip->lookupCountryCode($_SERVER[‘REMOTE_ADDR’]);

switch((string)$country) {

// For Indian Traffic
case ‘IN’:
$url = “http://google.co.in”;
break;

// For USA Traffic
case ‘US’:
$url = “http://www.bing.com”;
break;

// For the Rest
default:
$url = “http://cpaelites.com”;
}

header(‘Location: ‘.$url);
} catch (Exception $e) {
// Handle exception
}
?>

 

This file will redirect Indian traffic to Google and US traffic to Bing. The default location of all the others will be CPAElites. You can create as many cases as you want by writing in the short codes one after the other.

Step 6:
Upload the file to your web hosting and provide the Link to whomever you want.

4 thoughts on “How to GEO-Redirect CPA Traffic | Step By Step Tutorial

  1. I don’t have php pear packages in my cpanel kindly guide me what to do and I have tried many others script that I found while googling but none of them work

Leave a Reply

Your email address will not be published. Required fields are marked *