Extension:Piwik Integration

From MediaWiki.org
Jump to: navigation, search
MediaWiki extensions manual
Crystal Clear action run.png
Piwik Integration

Release status: stable

Implementation User activity
Description Inserts Piwik script into MediaWiki pages for tracking and adds a Special Page. Based on Google Analytics Integration by Tim Laqua.
Author(s) Isb1009, Youri van den Bogert, DaSch (DaSchtalk)
Latest version 2.4.2 (2014-11-08)
Composer mediawiki/piwik-integration
License GNU General Public License 2.0
Download
README
Parameters
  • $wgPiwikIDSite
  • $wgPiwikURL
  • $wgPiwikIgnoreSysops
  • $wgPiwikIgnoreBots
  • $wgPiwikCustomJS
  • $wgPiwikUsePageTitle
  • $wgPiwikActionName
  • $wgPiwikDisableCookies
Hooks used
SkinAfterBottomScripts

Translate the Piwik Integration extension if it is available at translatewiki.net

Check usage and version matrix; code metrics

The Piwik Integration extension inserts your Piwik tracking code to the bottom of every page. It excludes the views of the users with 'bot' privileges (bots) and the 'protect' privileges (sysops). It also adds a Special Page to some of the statistics.

Minimum requirements[edit | edit source]

  • MediaWiki 1.14+
  • A Piwik (0.4+) installation with the site configured

Installation instructions[edit | edit source]

  • Download and extract the tarball in your extensions/ folder. It should generate a new folder called Piwik directly inside your extensions/ folder.
  • Add the following code at the bottom of your LocalSettings.php:
require_once "$IP/extensions/Piwik/Piwik.php";
  • Configure the Piwik URL and site-id by setting up the following variables below this extension's call:
$wgPiwikURL = "piwik-host.tld/dir/";
$wgPiwikIDSite = "piwik_idsite";
Do not define the protocol of $wgPiwikURL
  • Done! Navigate to "Special:Version" on your wiki to verify that the extension is successfully installed.

Custom variables[edit | edit source]

Disable cookies by setting the $wgPiwikDisableCookies variable to true

 For example: $wgPiwikDisableCookies = true;


To define custom javascript tags in the Piwik javascript code, its possible to define the $wgPiwikCustomJS variable. For example if you have a single setting to insert; use the following code:

  $wgPiwikCustomJS = "_paq.push(['trackGoal', '1']);"

If you have multiple variables to define; use an array. For example:

  $wgPiwikCustomJS = array( 
  "_paq.push(['setCustomVariable', '1','environment','production']);",
  "_paq.push(['setCustomVariable', '1','is_user','yes']);"
  );


If you want to change the title of your pages inside the Piwik tracker, set $wgPiwikActionName inside your LocalSettings.php file


In case you want to include the title as, for example, "wiki/Title of the page", you can set $wgPiwikUsePageTitle to true and set $wgPiwikActionName to wiki/. The extension will print piwik_action_name = 'wiki/Title of the page';

Tracking with MobileFrontend[edit | edit source]

Due to a bug in Hooks/SkinAfterBottomScripts, Piwik Integration will not function when 'Mobile view' mode is used with the MobileFrontend Extension.

For those desiring to track across both views, comment or delete the Piwik Integration entries in LocalSettings.php and add to the file:

$wgUseSiteJS = true;

Then paste the Piwik tracking code generated in the Piwik dashboard into http://www.example.comk/wiki/MediaWiki:Common.js. Piwik will now track users in both Desktop view and Mobile view.