How to create multiple location affiliate site

There are many worldwide stores which have good partner programs. One of well known store is Amazon. Problem is that most of such stores doesn’t provide autodetection of buyer’s location. Instead of this, stores have different domains (example, amazon.com, amazon.de). So, if you have world wide site, you can lose money if you promote offers for one location. For example, users from Europe don’t like to buy in USA stores, because they must pay additional VAT for each product. How can you solve this? I will show some technics

First of all, you need to have geo ip base and plugin which can detect user country. I tested many plugins and currently I choose GeoIP Detection plugin which is most powerfull as I think. This is because this plugin provides not only shortcodes, but also additional functions for developers. And my favorite functions of plugin is that it has option to add user country and continent to body class. This is very usefull for my tips which I will write now. Also plugin use Maxmind GeoIP Lite City free base and has option to use paid version of base.

Let’s start to do multi location amazon links. You can use such tips also for any shop.

Multi locale dynamic links

One of feature of amazon is that most of products have the same position across all locales. This means that, for example, amazon.com/product_url will be available also in amazon.de/product_url, amazon.es/product_url, etc. So, you need only to check user location and show him correct locale of amazon.

I wrote early, that GeoIP Detection plugin can add class to body tag. Plugin adds two classes, for example, geoip-country-CY and geoip-continent-EU

geoip-country-CY shows country code of user

geoip-continent-EU shows continent code of user

Full list of continents

Code Continent name
AF Africa
AN Antarctica
AS Asia
EU Europe
NA North america
OC Oceania
SA South america

So, for USA, continent class will be geoip-continent-NA

For country code, you can see all codes from Maxmind base page

Now, we can add simple jquery code on your site which will change default domain to domain of country of user.

For example, our main url of offers will be from amazon.com. Now, you want to send all users from Europe to amazon.co.uk. Place such code in your theme

Many themes have field where you can add different scripts, for example, for ads, etc. In my themes, you can place this code in theme option – Analytics/js code

Place in domainforchange your default domain of links. As you see, we use geoip-continent-EU to detect users from Europe and if script find such class, all links which have amazon.com on your pages will be changed to amazon.co.uk. You can do the same for other continents, just place such peaces of codes

Ok, but what about different countries which have own store locale. For example, it would be bad if you send german users to amazon.co.uk when they have amazon.de. In this case, you can use country code of GeoIp plugin. So, full code will be

Such code will change links to amazon.co.uk for europe, and change to amazon.de for german users or to amazon.es for users from Spain. Last thing I forgot to add is affiliate ID. Most of multylocation stores use the same affiliate ID for all locations. But Amazon requires separate registration for each locale and you have separate affiliate ID. So, you need to change also a affiliate ID. Code for this will be

Update.

Ajax call and links changing

Problem with code above is that it’s working only on current page. But many sites have ajax call of links and content parts, so, you can try to change links on click event. Sometimes can be buggy, but you can try. Code above will have next look

Check one important thing. In first line I used a.re_track_btn, because “re_track_btn” is class in my theme for all affiliate links. Maybe you have another common class for such links. Also, you can try to use just “a” without any class to handle all links, but this is not recommended.

Multiple offers for different localizations

This was easy way to change links. But such method is not universal. Sometimes, you can’t just change domain to get correct links, because offers for different locations have different links and you need to create different offers.

In this case you can use similar plugin GeoTargeting Lite

This plugin has some shortcode to show and hide content to specific countries. For example,

So, you need to create different offers and then wrap each offer for specific country shortcode.

Plugin also supports setting several countries in shortcode

Another way is to use previous plugin but wrap each offer to own div. For this, enable text view of wordpress editor and wrap your offers.

Example

According to such code, your js code will be

Caching issues and how to make cache compatibility geo ip detection

There is one problem with most of plugins. They didn’t support cache, because if you cache page, this page will show the same code to all users and will be static.

But some of cache systems have it’s own Geo Ip extension. One of such system is CloudFlare.

If you use it, you can use it’s geo ip detection instead of Geoip plugins. But you need to add some functions to your theme.

This is code which will do the same as GeoIp detection plugin to add special class to body tag. We will use the same classes, so, other codes which I wrote above will work.

Add such code to functions.php

 

 

How to create multiple location affiliate site
5 (100%) 1 vote

Want to get unique wordpress tips?

We won't rent or sell or spam your email. We promise!

Leave a Reply

7 Comments on "How to create multiple location affiliate site"

Notify of
avatar
Sort by:   newest | oldest | most voted
Mantas
Guest

That’s a great post! Would any of these methods work with Rehub theme+Content Egg plugin? At this moment if I insert the same prduct from 3 different amazon sites (.com co.uk and .ca) it would display the one that has the lowest prices as the main one. It would be great if it could just display the price based on users location. Does it make sense?

James
Guest

Thank author!

I have coupon site ( see demo here -> https://chiasedeal.com ) and now I want to expand to Asia.

In this post, you mean I can install GeoIp Detection, and then copy code in below into functions.php?

add_filter(‘body_class’,’geoip_classes_add’);

function geoip_classes_add($classes) {

$country_code = (!empty($_SERVER[“HTTP_CF_IPCOUNTRY”])) ? $_SERVER[“HTTP_CF_IPCOUNTRY”] : ”;
if ($country_code !=”) {

$classes[] = ‘geoip-country-‘.$country_code;

$africa = array(“DZ”,”AO”,”BJ”,”BW”,”BF”,”BI”,”CM”,”CV”,”CF”,”TD”,”KM”,”CG”,”CD”,”CI”,”DJ”,”EG”,”GQ”,”ER”,”ET”,”GA”,”GM”,”GH”,”GN”,”GW”,”KE”,”LS”,”LR”,”LY”,”MG”,”MW”,”ML”,”MR”,”MU”,”YT”,”MA”,”MZ”,”NA”,”NE”,”NG”,”RW”,”RE”,”SH”,”SN”,”SC”,”SL”,”SO”,”ZA”,”SD”,”SZ”,”ST”,”TZ”,”TG”,”TN”,”UG”,”EH”,”ZM”,”ZW”);
$oceania = array(“AS”,”AQ”,”AU”,”BV”,”IO”,”CX”,”CC”,”CK”,”FJ”,”PF”,”TF”,”GU”,”HM”,”KI”,”MH”,”FM”,”NR”,”NC”,”NZ”,”NU”,”NF”,”MP”,”PW”,”PG”,”PN”,”WS”,”SB”,”GS”,”TK”,”TO”,”TV”,”UM”,”VU”,”WF”);
$europe = array(“AL”,”AD”,”AT”,”BY”,”BE”,”BA”,”BG”,”HR”,”CY”,”CZ”,”DK”,”DD”,”EE”,”FO”,”FI”,”FR”,”DE”,”GI”,”GR”,”GG”,”HU”,”IS”,”IE”,”IM”,”IT”,”JE”,”LV”,”LI”,”LT”,”LU”,”MK”,”MT”,”FX”,”MD”,”MC”,”ME”,”NL”,”NO”,”PL”,”PT”,”RO”,”RU”,”SM”,”RS”,”CS”,”SK”,”SI”,”ES”,”SJ”,”SE”,”CH”,”UA”,”SU”,”GB”,”VA”,”AX”);
$asia = array(“AF”,”AM”,”AZ”,”BH”,”BD”,”BT”,”BN”,”KH”,”CN”,”CY”,”GE”,”HK”,”IN”,”ID”,”IR”,”IQ”,”IL”,”JP”,”JO”,”KZ”,”KW”,”KG”,”LA”,”LB”,”MO”,”MY”,”MV”,”MN”,”MM”,”NP”,”NT”,”KP”,”OM”,”PK”,”PS”,”YD”,”PH”,”QA”,”SA”,”SG”,”KR”,”LK”,”SY”,”TW”,”TJ”,”TH”,”TL”,”TR”,”TM”,”AE”,”UZ”,”VN”,”YE”);
$south_america = array(“AI”,”AG”,”AR”,”AW”,”BS”,”BB”,”BZ”,”BO”,”BR”,”VG”,”KY”,”CL”,”CO”,”CR”,”CU”,”DM”,”DO”,”EC”,”SV”,”FK”,”GF”,”GD”,”GP”,”GT”,”GY”,”HT”,”HN”,”JM”,”MQ”,”MX”,”MS”,”AN”,”NI”,”PA”,”PY”,”PE”,”PR”,”BL”,”KN”,”LC”,”MF”,”VC”,”SR”,”TT”,”TC”,”VI”,”UY”,”VE”);
$north_america = array(“BM”,”CA”,”GL”,”PM”,”US”);

if(in_array($country_code, $africa)) {
$classes[] = ‘geoip-continent-AF’;
}
elseif(in_array($country_code, $oceania)) {
$classes[] = ‘geoip-continent-OC’;
}
elseif(in_array($country_code, $europe)) {
$classes[] = ‘geoip-continent-EU’;
}
elseif(in_array($country_code, $asia)) {
$classes[] = ‘geoip-continent-AS’;
}
elseif(in_array($country_code, $south_america)) {
$classes[] = ‘geoip-continent-SA’;
}
elseif(in_array($country_code, $south_america)) {
$classes[] = ‘geoip-continent-NA’;
}

}
return $classes;
}

romuald kieffer
Guest

Hi Author,
I am usng Rehub and tyr to find were to put those code and can’t seem to find Analytics/js code .
In Theme options- General option , I can see Js code for footer and header….is that were I am suppose to put those code?

wpDiscuz