Documentation VIP Go Geo targeting on VIP Go

Geo targeting on VIP Go

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 targetted 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.

// 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 them 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 targetting #

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.

Documentation is licensed under a Creative Commons Attribution-ShareAlike 4.0 International License.