If you want to know the location of the visits your website received before you started using Matomo with a geolocation database, there is a console command you can use. The command will geolocate every one of your visits that have not been located (or just the ones you want to geolocate). Since it goes through many visits in your database, it can take a long time to run.

Connect to your Matomo server over SSH, and open a terminal. The command is called usercountry:attribute and can be executed in the terminal by running (for example):

php ./console usercountry:attribute 2012-01-01,2013-01-01

Things you should note:

  • The command will not work with the Apache or NginX server modules, since this requires sending requests through a web server.
  • If you use the GeoIP2 PHP API it will take longer to run, so we recommend using this command with the GeoIP2 PHP extension. You can see how to install the PHP extension here.

After you run the script make sure you reprocess your reports so new reports w/ location data will be shown.

Previous FAQ: How do I install the GeoIP 2 module for Nginx?