WP.com Geo Uniques

Target distinct markets with different content by geo-targetting users at a country level, while still benefitting from the awesomeness that is Batcache.

Target distinct markets with different content while still benefitting from the awesomeness that is Batcache.

// add list of supported countries, probably in functions.php
wpcom_geo_add_location( 'us' );

// later on in your code
if ( 'us' == wpcom_geo_get_user_location() ) {
	echo "USA: A-Okay!";
} else {
	echo "You're not American! No soup for you!";
}

This plugin relies on WP.com-specific functions to be fully functional but will work in your local environment with WP_DEBUG === true.

If you just need to know which country the user is visiting from, we have a variable $_SERVER['GEOIP_COUNTRY_CODE'] which is quicker than wpcom_geo_get_user_location(), but you’ll need to handle your own Batcache variants if you use this. Examples values are “US” (N. America), “RU” (Russia), or “GB” (Great Britain). This variable is set for all requests and does not require the WP.com Geo Uniques plugin to be active.

Note that either of these techniques should only be used with a very small list of countries for performance reasons.

Please get in touch before using this plugin.