Piwik vs. Google Analytics

Piwik is an open source, free (fremium) analytics package in PHP that runs on one's website or hosted. It provides comparable analytics as does Google Analytics. There is also a free, open source plugin -- Piwik AOM -- for integrating data from third parties, such as Bing, Adwords, Facebook.

Note: this article is valid for Piwik 3.0.2

Piwik and Third Party Integration

Piwik, along with AOM, has a great advantage in terms of not requiring a third party (such as Google) to do the tracking and integration, which can be viewed as a privacy violation. Instead, the data that is collected from Google Adwords, Bing Ads, and Facebook Ads is then integrated by Piwik and AOM into a local database.

AOM is one of many plugins (a mix of free and paid) available from the Piwik Marketplace which is embedded in Piwik. Though on inspection it appears that a Piwik installation does not have access to all plugins available through the website (at least when using search).

Piwik and Privacy

By self-hosting Piwik, all data stays on one's own servers. A configuration I prefer is using WordPress Multisite. Then, a local install of Piwik in a directory can be accessed by all domain names in the Multi-site, which means no third party site calls to slow things down.

Piwik has a setting (per site, in the tracking code) that allows for following the Do-Not-Track data directive. Piwik also has an anonymizing IP function (required in Germany for those keeping IP addresses).

Overall Piwik has features that support the privacy expectations of many people and governments.

Piwik Speed

Piwik is arguably faster than Google Analytics, and certainly than Google Tag Manager, especially if third party scripts are loaded. While these usually happen later, after the screen has already been painted, it is a less-than-idea experience.

Summary of Benefits of Piwik

  • Realtime (very similar to Statcounter in terms of display of data and real-time
  • Faster (code is loaded from own site)
  • Better privacy
  • Can obey do-not-track directive
  • Can anonymize IP (the last octet) which is required by German privacy laws
  • Can show exit links (tracks all clicks, including outbound)

Basically it seems to have all the same info that Statcounter has when looking at recent visitors, though some of the info have to click once to see (e.g., screen resolution).

Finally, Piwik is open source (at least a usable part) and extensible, which means that creating reports as well as display screens (and plugins) are viable and supported by the Piwik design.

Piwik Installation on CentOS

These steps worked out on PHP 5.6, though 5.5 might also work. This is for version 3.0.2

From the root of the site you want to install into:

sudo wget https://builds.piwik.org/piwik.zip 
sudo unzip piwik.zip

Restart the web server

Piwik Database Configuration

After installing Piwik, create the database and database user, and assign user rights.

The website should then have a web-based wizard walkthrough at the /piwik/ installation URL.

Piwik Web Configuration

Once everything is installed and running, it is time to start web configuration. First, understand the capabilities and purpose of Piwik, and from there start setting up basic parameters and insertion code.

Note that there is a Piwik plugin that can be configured to track single-page websites.

Install GeoIP for Geographic Data

This works for Piwik, but also others.

sudo mkdir /usr/share/GeoIP
sudo cd /usr/share/GeoIP
sudo wget http://geolite.maxmind.com/download/geoip/database/GeoLiteCountry/GeoIP.dat.gz
sudo wget http://geolite.maxmind.com/download/geoip/database/GeoLiteCity.dat.gz
sudo gunzip GeoIP.dat.gz
sudo gunzip GeoLiteCity.dat.gz
sudo yum update -y
sudo yum install -y geoip geoip-devel
sudo pecl channel-update pecl.php.net
sudo pecl install geoip
sudo nano /etc/php.d/geoip.ini

Add the following to the geoip.ini file

geoip.custom_directory = /usr/share/GeoIP/

Restart the web server