Geo targeting on VIP Go

VIP Go platform specific

This document is for sites running on VIP Go.

Learn more

Overview #

VIP Go allows you to differentiate visitors from different countries, tailoring the content you serve to your visitors on a country by country basis, while still keeping the benefits of our fast caching infrastructure.

Adding geo targeting to your VIP Go code takes two parts:

  • Loading and configuring the VIP Go Geo Uniques plugin
  • Serving geo targeted content

↑ Top ↑

Loading the VIP Go Geo Uniques plugin #

As the VIP Go Geo Uniques plugin requires configuration in code, we recommend loading this plugin using the wpcom_vip_load_plugin function.

Download the plugin from the GitHub repo (https://github.com/Automattic/vip-go-geo-uniques), add it to your `plugins` folder, and then activate it for your site:

// Load the VIP Go Geo Uniques plugin
wpcom_vip_load_plugin( 'vip-go-geo-uniques' );

To configure the plugin, you must set a default location using the VIP_Go_Geo_Uniques::set_default_location method. You must then configure each country separately, using the VIP_Go_Geo_Uniques::add_location method.

The example below sets the default location as the US (US), and a further location as the UK (GB).

// Configure the VIP Go Geo Uniques plugin
if ( class_exists( 'VIP_Go_Geo_Uniques' ) ) {
    VIP_Go_Geo_Uniques::set_default_location( 'US' );
    VIP_Go_Geo_Uniques::add_location( 'GB' );
}

↑ Top ↑

Serving geo targetted content #

You can now tailor your content to the different country audiences:

if ( function_exists( 'vip_geo_get_country_code' ) && 'GB' == vip_geo_get_country_code() ) {
    echo "Please select your favourite colour:";
} else {
    echo "Please select your favorite color:";
}

↑ Top ↑

Caching for sites using geo targeting #

When you enable the VIP Go Geo Uniques plugin, your page cache is varied by country code. This means that, for each URL requested, we hold a separate copy of the page (i.e. the HTTP response) for each country in our page cache. When you update a post or page, all cached copies for all country codes are automatically invalidated. When you purge the cache for your whole site, the whole cache is still invalidated.

↑ Top ↑

Geo targeting and reverse proxies #

Geo targeting on VIP Go is not reliable if your site uses a reverse proxy.

This is because when a request comes via a reverse proxy, the remote IP address is that of the reverse proxy. The load balancers on VIP Go will assign the country code to the reverse proxy IP, and not the IP address of the end user; sometimes this may by chance be the right country for the end user, but many times it will not be.

↑ Top ↑

Unexpected country codes #

Our country codes are supplied via the Maxmind GeoIP database, which implements special “pseudo country codes” for particular situations:

Please note that “EU” and “AP” codes are only used when a specific country code has not been designated (see FAQ). Blocking or re-directing by “EU” or “AP” will only affect a small portion of IP addresses. Instead, you should list the countries you want to block/re-direct individually.

GeoIP and ISO 3166 Country Codes

At time of writing, the GeoIP pseudo  country codes are:

  • AP,”Asia/Pacific Region”
  • A1,”Anonymous Proxy”
  • A2,”Satellite Provider”
  • O1,”Other Country”
  • EU,”Europe”

A common misconception is that the country code for the United Kingdom is UK, in fact it is GB.

Ready to get started?

Drop us a note.

No matter where you are in the planning process, we’re happy to help, and we’re actual humans here on the other side of the form. 👋 We’re here to discuss your challenges and plans, evaluate your existing resources or a potential partner, or even make some initial recommendations. And, of course, we’re here to help any time you’re in the market for some robust WordPress awesomeness.