If you want to know the location of the visits your website received before you started using Piwik with GeoIP, we’ve created a command that will help you. 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.

The command is called usercountry:attribute and can be executed 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 GeoIP module, since this requires sending requests through a web server.
  • If you use the GeoIP PHP API it will take longer to run, so we recommend using this command with the GeoIP PECL extension. You can see how to install the PECL extension here.

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