Geolocation is the process of determining where an IP address is geographically located. Matomo offers various methods to determine your visitors’ location:
- Before 1.9, Matomo (Piwik) guessed a visitor’s location based on the language they used.
- In 1.9 and later, Matomo included the ability to use one of MaxMind’s GeoIP (Legacy) databases to more accurately determine the locations of visitor IPs.
- Since Matomo 3.5.0 the ability to use MaxMind’s GeoIP2 databases was added
Additionally there are some plugins on the Marketplace that give the abillity to use other Geolocation providers, such as IP2Location.
Enabling Accurate Visitors Geolocation in Matomo Analytics
To enable GeoIP2 go to the Administration > Geolocation admin page. Here you will see the list of options available for determining a visitor’s location:
The Default option uses the pre-1.9 method of geolocation. That is, it will guess based on a visitor’s language.
The other options are different ways of using a GeoIP2 database. The easiest way to start using GeoIP2 is to use the ‘GeoIP2 (Php)’ option. All that is required to use this option is to install a GeoIP2 database.
The other options are faster, but are more complicated to setup. In addition to installing a GeoIP2 database, you have to install other software. You can see instructions for installing these options in the resources section below.
Once a GeoIP2 option is installed, it should be selectable and be Installed.
If there’s something wrong with the setup, it will be Broken, and the reason why will be displayed.
To use an option, simply select it.
Reports: Continent, Country, Region, City & Provider
The geolocation feature provides the data for all of the reports on the Visitors > Locations & Provider page. On this page you can see what geographic locations most of your visits come from.
The Region & City reports will only be populated if a GeoIP2 geolocation option was used when tracking the visits during the period. Otherwise, they will have one “Unknown” row:
Maintaining GeoIP2 Databases
The data used to find locations for IP addresses changes constantly, either due to IP addresses changing owners or due to MaxMind applying corrections. You can setup Matomo to automatically download the latest Maxmind databases in the “Setup automatic updates of GeoIP databases” section of Administration > Geolocation.
MaxMind updates their free databases once a month on the first Tuesday, and their commercial databases every week on Tuesday. Matomo can be set to auto update the geo databases every week or every month. The geolocation databases automatic updates are executed by the Matomo Archiving script.
Details & Resources
When is a Visitor detected as Unknown city or country?
If you are using GeoIP2 it is possible you will still see many of your visits as located in an “Unknown” region or city. This is unfortunate, and MaxMind does its best to provide accurate and complete data, but geolocation will never be 100% accurate.
Also, if you’re using the free database, your results won’t be as complete and accurate as the commercial ones. If you feel this additional accuracy would be helpful to you and/or your business, you can buy the commercial databases here.
Exactly how accurate is accurate?
The GeoIP2 databases aren’t 100% accurate, and the accuracy depends on what type of location information you’re interested in, and it varies by country as well.
MaxMind’s databases are 99.8% accurate at the country level (99.5% for the GeoLite2 City database) and 90% accurate at the region level (there is no listed accuracy for the GeoLite2 City database). The city level accuracy depends on the country. You can find more information on the commercial database accuracy here and on the GeoLite2 City database here.
What about World Maps and Region maps?
Geolocation and Privacy
A couple notes about Geolocation and Privacy in Matomo:
- The geo location database is installed in your server, so your visitor IP addresses (and any other of your data) will never be sent to an external geo location server.
- If you enable IP anonymisation then by default Matomo will process geo location information using the anonymised IP address. You may change this in the Privacy Settings in Matomo.
Do you not get the insights you need out of the standard reports in Matomo? You can create any report tailored to your needs using the Custom Reports premium feature in a matter of seconds. For example, easily see which pages were viewed how often per region or country. Or see which referrers work best per region or country. The sky is the limit.
- How do I get the GeoIP2 databases to improve accuracy of Country detection, and detect visitors’ Cities and Regions?
- How do I install the GeoIP2 PHP extension?
- How do I install the GeoIP2 module for Apache?
- How do I install the GeoIP2 module for Nginx?
- How do I apply accurate geolocation to old visits, after updating to Matomo 1.9?