Note: This guide is applicable only for Matomo On-Premise, if you have any issue with Geolocation in Matomo Cloud, please get in touch with our Support team.
Geolocation is the process of determining where an IP address is geographically located. Within Matomo there are three main ways of establishing a user’s location. These are accessed via the Settings section of Matomo which is accessed via the cog icon in the top menu. Within this section, you need to click on the System submenu which will reveal the Geolocation menu item.
On arrival at the Geolocation page, you’ll find the following four configuration options:
Disabled – If you don’t need or want geolocation data for your users, this is the most private option and will completely disable Matomo’s geolocation features.
Default – The default option guesses a visitor’s country based on the language that their browser is set to use. This is not very accurate as languages can be used in multiple countries and people may default to their native tongue even when living overseas. This setting should probably only be used if you can’t use a geolocation database for some reason.
DBIP / GeoIP 2 (Php) – Since version 1.9, Matomo has included the ability to check a visitor’s IP address against a database of known and estimated IP locations to more accurately determine the location of your visitors. The PHP API method is the simplest way to do this and is typically the best option if you use shared hosting as it does not require any additional custom server configurations which may not be in some shared environments.
DBIP / GeoIP 2 (HTTP Server Module) – This is a more advanced version of the former setting which takes advantage of a GeoIP module installed on your HTTP server. This is a fast and accurate method, but can only be used with normal browser tracking and may require you to set up the GeoIP module if it isn’t already active on your server. Details on how to do this can be found at the following links:
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. More information on how to get access to DBIP and MaxMind GeoIP databases can be found here.
Maintaining Geolocation Databases
The data used to find locations for IP addresses changes constantly, either due to IP addresses changing owners or due to database providers applying corrections. You can setup Matomo to automatically download the latest version of a database in the « Setup automatic updates of GeoIP databases » section of Administration > System > Geolocation.
DB-IP updates their free databases once a month, and their commercial databases every day. 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.
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:
Geolocation Configuration FAQs
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 DB-IP 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 purchase the commercial databases.
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.
You can read about the accuracy of DB-IP’s databases here. (Note: currently DB-IP’s city geolocation results do not appear to be very accurate.)
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 (which is the default in Matomo), then by default Matomo will not store the full IP address in the database, but it will still use the full IP address to get the geo-location information (for better accuracy). For better privacy, you may change this setting in Matomo Settings > Privacy > Anonymize data, and under « Anonymize Tracking Data » set the setting « Also use the Anonymized IP addresses when enriching visits. » to « Yes (recommended for privacy) ».
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 (Piwik) 1.9?