Skip to content

Script to automatically pull down the latest GeoIP city database and move it into place for Piwik analytics to use

License

Notifications You must be signed in to change notification settings

PeachFlame/geoip-update-for-piwik

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 

Repository files navigation

geoip-update-for-piwik

Script to automatically pull down the latest GeoIP city database and move it into place for Piwik analytics to use. This is accomplished with a single bash script and a cron job. This does not require root access to the server. This is ideal for a shared hosting environment.

What this script is exactly:

Piwik is an excellent open analytics platform. It is able to utilize the MaxMind GeoIP country database for location statistics of your visitors. For even greater location accuracy, you can use the GeoIP city database.

MaxMind updates the database files (country and city) on

"the first Tuesday of each month".

This script will remove the old city database file, download the latest version (via wget), and then rename it for Piwik's use. The last step is needed as MaxMind names the file 'GeoLiteCity.dat', but Piwik expects the file to be called 'GeoIPCity.dat'.

The end result of this script is that you now have monthly updates of city locales for Piwik, with no manual maintenance intervention required.

Installation instructions (command line):

  1. Grab the bash script. Recommended that you place it in the 'misc' folder of your Piwik installation (ex: /path/to/piwik/misc/)
cd /path/to/piwik/misc/
wget --no-check-certificate https://raw.githubusercontent.com/PeachFlame/geoip-update-for-piwik/master/update-geoip.sh
  1. Customize the script by setting the path to your Piwik installation: "PATH_TO_PIWIK"
  2. Add in a cron job to run the script monthly. Example:
25 2 9 * * /bin/sh /path/to/piwik/misc/update-geoip.sh

Installation instructions (FTP):

Alternatively, if you don't have command line access, or you are uncomfortable with SSH, you can simply FTP upload the file.

  1. Download the update-geoip.sh script from this GitHub repo
  2. Edit the file, changing the path to your Piwik installation: "PATH_TO_PIWIK"
  3. FTP upload it to your Piwik server. Recommended that you place it in the 'misc' folder of your Piwik installation (ex: /path/to/piwik/misc/)
  4. Add in a cron job to run the script monthly. Example:
25 2 9 * * /bin/sh /path/to/piwik/misc/update-geoip.sh

Note:

  1. This script can be run by a regular, non-privileged, user. This is ideal for a shared hosting environment where the user does not have root access to install via yum/apt. If you do have root access, you may want to consider using MaxMind's official program instead: https://github.com/maxmind/geoipupdate
  2. It is suggested that you set the cron to run on the 9th of the month (or later) so as not to slam MaxMind's servers as soon as they publish their updated databases. This is a courtesy to MaxMind, but not a requirement for you. It really depends on how much you need the most up-to-date City information. You are using their free database afterall. If you absolutely need city information as quickly as possible, consider buying a commercial subscription.

More information:

About

Script to automatically pull down the latest GeoIP city database and move it into place for Piwik analytics to use

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages