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 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.
Database download problems
Please follow these steps if the database can’t be downloaded from the server automatically:
- go to https://dev.maxmind.com/geoip/geoip2/geolite2/
- scroll down to “Downloads”
- get GeoLite2 City and GeoLite2 Country from the Maxmind DB column
- unzip both files
- upload them into wp-content/uploads/advanced-ads-geo via FTP
You can set the constant ADVANCED_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', '126.96.36.199' ); // some German IP addres
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 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 on a local environment.
Matching city and state names
If you are looking for a list of regions and how they might be spelled in the database, check the Free Cities Database by MaxMind.
Keep in mind that city and state names must be perfect matches with the geo location 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 a 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-geoin order to use it.