If your readers come from several countries, a German Amazon link does not help a visitor from Austria or Switzerland. With geo-targeting, affiliate-toolkit detects the visitor's country and shows the offers of the shops you assigned to that country – everyone else sees your default offers. Your product boxes stay the same; only the offers inside change.
Prerequisites: affiliate-toolkit with the Geo-Targeting module (included in the passes), a free MaxMind account and at least one shop per target country, for example Amazon.de and a Geizhals shop for Austria.
1. Get a MaxMind license key
affiliate-toolkit determines the country from a local copy of the free GeoLite2 country database by MaxMind. You need a free license key for the download:
- Create a free account at MaxMind GeoLite2.
- In your MaxMind account, open Manage License Keys and create a new key.
- Copy the key right away – it is only shown in full once. It can take a few minutes until a new key is active.
2. Import the country database
- Install the Geo-Targeting module and activate its license under affiliate-toolkit → Settings → Licenses.
- Open the new tab Settings → Geo IP, paste the key into Maxmind License Key and save.
- affiliate-toolkit now downloads the database and imports it into the table
{prefix}atkp_geo_ip_country. The status shows whether the table exists and how many rows were imported. The database is updated automatically once a week. - Under Countries, select only the countries that should get their own offers, for example Austria and Switzerland. You do not need to select every country.

Below the settings you see which country was detected for your own IP address – a quick way to check that the detection works.
If the import stops with a timeout, that is not a problem: the cronjob repeats it. If nothing happens at all, the MaxMind key is probably not active yet – wait a few minutes and save again.
3. Assign shops to countries
Open the shop that should only serve one country – for example a Geizhals shop with location Austria – and select the country under Only valid for these countries. Save the shop. Shops without a country are your default for all other visitors.

The shop list shows the assigned countries as small flags next to each shop.

4. How offers are chosen
Every offer of a product belongs to a shop, so it inherits the shop's countries. On the product you see for which countries each offer is shown. Offers without a country are marked as shown "as soon as no country offer is available".

- A visitor from a selected country sees the offers of the shops assigned to this country first, followed by the offers without a country. The first country offer becomes the main offer of the box.
- All other visitors see only the offers without a country.
- If a product has no offer without a country, all offers are shown.
Caching
A page cache would deliver the same country to everybody. Enable Load product displays via AJAX request under Settings → Display settings: the product boxes are then loaded per visitor and are not stored in the cache.
Privacy
The country is determined locally on your server from the imported database. affiliate-toolkit does not send the visitor's IP address to an external service and does not set a cookie for the country.
The imported database contains IPv4 ranges. Visitors who reach your site via IPv6 cannot be assigned to a country and see the default offers.
Testing other countries
To test how your site looks for another country, override the detected IP address with the filter atkp_geo_ipaddress:
// For testing only – remove afterwards.
add_filter( 'atkp_geo_ipaddress', function ( $ip ) {
return '197.221.23.194'; // an IP address from the country you want to test
} );
| Parameter | Type | Description |
|---|---|---|
$ip | string | The detected IP address of the visitor (Cloudflare and proxy headers are taken into account). |
| Return value | string | The IP address used for the country lookup. |
Remove the filter after testing, otherwise every visitor is treated as coming from that country.