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. Something like:

mysql -u root -p
CREATE DATABASE p1w1k;
CREATE USER 'p1w1k'@'localhost' IDENTIFIED BY '**********************';
GRANT SELECT, INSERT, UPDATE, DELETE, CREATE, DROP, ALTER, 
CREATE TEMPORARY TABLES, LOCK TABLES ON p1w1k.* TO 'p1w1k'@'localhost';

The website should then have a web-based wizard walkthrough at the /piwik/ installation URL. After installation, there is a prompt to createe a user account for piwik (different from the database account).

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

Especially with Amazon Linux AMI, the GeoIP apache plugins aren't an approach I recommend. Better to just download, unzip, and rename the GeoIP Lite City database, and then tell Piwik to use PHP for lookup.

Download the GeoIP database from the Piwik webiste.

It is likely easiest to download to a client machine, unzip, then scp as follows:

scp -r -i /Users/USER/.ssh/key /Users/USER/Downloads/GeoIPCity.dat username@11.22.33.44:html/piwik
GeoIPCity.dat

Restart the web server, then visit the "GeoIP config](https://rehabthailand.com/piwik/index.php?module=UserCountry&action=adminIndex) and set to PHP.

Conversion Tracking in Piwik and Google Analytics

Goals are created and given a number (and assigned an event, but those variables do not seem to be used directly). The best approach is to get organized and do things the Google Analytics way:

  • eventCategory
  • eventAction
  • eventLabel
  • eventValue

For me, the categories are distinct, so the action is simply submit. eventLabel can be used for currency in transactions, and eventValue for the price.

Now for Piwik it is simpler, merely push trackGoal with a goal number.

Piwik and Google Analytics Conversion Tracking with Contact Form 7

Under Additional Settings for a contact form, paste the following script:


document.addEventListener( 'wpcf7mailsent', function( event ) { _paq.push(['trackGoal', 1]); ga('send', 'event', 'contact', 'submit'); }, false );

This will fire on the first Piwik goal for the site, as well as a Google Analytics goal with event configuration of eventCategory:contact and eventAction:submit.

Piwik and Google Analytics Conversion Tracking with WooCommerce

A third party plugin Woocommerce Conversion Tracking provides form fields in WooCommerce in an extended Integration tab.

The following script added to the integration tab in WooCommerce:


ga('send', 'event', 'payment', 'submit', '{currency}', {order_total}); _paq.push(['trackGoal', 3, {order_total}]);

This would provide the following information to Google Analytics, and Piwik, respectively:

  • eventCategory: payment
  • eventAction: submit
  • eventLabel: {currency}
  • eventValue: {order_total}

  • trackGoal: 3

  • priceOfMyObject/Revenue: {order_total}

Unfortunately, it does not appear to be clear how to track currency in Piwik, though there is open discussion that might be fruitful.

Piwik and Google Analytics Conversion Tracking with Downloads

Incomplete


Piwik and Google Analytics Conversion Tracking with Follow-Up-Emails (FUE)

Incomplete

No comments yet.

Leave a Reply