General issues

Please be aware that IPs are constantly changing. The more populated the region, the more accurate and constant the geo-targeting is working.

Please note that the used GeoLite2 database by MaxMind might miss IPs especially for small locations and cities. See the upgrade options below.

There is also a list of how accurate the lists are on a city level for each country, see GeoIP2 City Accuracy.

If Cache Busting is used, the Geo-Location Visitor Condition only looks up the location of the visitor ones. This could lead to unexpected behavior when you change the IP address while debugging the option. Make sure to either disable Cache Busting for the placement that uses geo-targeting or remove the advanced_ads_pro_visitor_referrer cookie after each check.

Geo-targeting test ad

The following ad shows your current position according to the geo-targeting database. It allows you to estimate how far it might be off for your position.

You can download the code of this ad on this page and use it with the Allow PHP option enabled in the Plain text and code ad type.

Database download problems

Please follow these steps if the database can’t be downloaded from the server automatically:

  1. get GeoLite2 City and GeoLite2 Country from the Maxmind DB column on this page
  2. unzip both files
  3. upload them into wp-content/uploads/advanced-ads-geo via FTP

Testing locations

You can set the constantADVANCED_ADS_GEO_TEST_IP in your wp-config.php to simulate a user with a specific IP or when using a local environment.

define( 'ADVANCED_ADS_GEO_TEST_IP', '31.17.16.74' ); // some German IP address

Other resources for testing:

Debugging geo-targeting

In order to find a potential problem with geo-targeting, you can log all checks made by the plugin.

Add the following line to your wp-config.php file in order to log all checks done by the Geo-Targeting plugin.

define('ADVANCED_ADS_GEO_CHECK_DEBUG', true );

Once the constant is added, all checks will be written into the geo_check.log file in your wp-content folder. You can access it by using the following URL with example.com being your domain: http://www.example.com/wp-content/geo-check.log.

One log entry might look like this:

GEO CHECK (setting|visitor): COUNTRY |DE – REGION | – CITY new york|berlin

The value from the ad settings (left) and the one from the current user (right) are separated by a pipe (|). In the example above, the visitor is in Berlin, Germany (DE) but the ad setting is New York.

Note that COUNTRY and REGION will only be listed here if you provided a value in the geo-targeting Visitor Condition. When you set a continent, it will also be listed next to COUNTRY.

There is no error output if your IP is empty, e.g. when you are in a local environment.

Matching city and state names

Unfortunately, there is no list available with all regions. We suggest to enable geo-targeting debugging and get regions from the log file.

Keep in mind that city and state names must be perfect matches with the geolocation database. Even small differences will result in a broken check.

Example: Bryanskaya Oblast’ and Bryanskaya Oblast’ are not the same string, because of the different apostrophe.

Missing entries and extending the database

The GeoLite2 database created by MaxMind might not be as accurate, especially for smaller areas.

MaxMind offers the GeoIP2 database with better accuracy on a country or city level. See their offers.

In order to use their additional database, just rename it to GeoLite2-City.mmdb for the city level and GeoLite2-Country.mmdb for the country level and replace the file with the same name in wp-content/uploads/advanced-ads-geo in order to use it.