Extending Piwik for Track OER

Cloud created by:

Nick Freear
10 August 2012

A software component that we had in mind for the Track OER project from early on is Piwik. Piwik is an open-source Web analytics tool, that offers similar features to Google Analytics, in terms of logging page views, and outputting reports.

It offers a number of advantages over competitors:

  • You host Piwik yourself, so it can be easier to debug problems, particularly for our no-Javascript work,
  • You also have more control over access to the analytics reports on the site,
  • Piwik has an extensive plugin interface, widgets, and an API to access data over the Web,
  • There is good documentation, and a wide community,

To date I've found it quite simple to install and customize. There are a number of considerations,

  • As Piwik is self-hosted it needs to be installed on a robust server, with similar uptime/support to your other production servers (if it goes down, you risk users seeing a broken image),
  • There may be issues around the new EU cookie laws - many sites use Google Analytics, so adding another system to the mix may cause confusion and concern,

Against this last point, I would say that precisely because Google Analytics is so prevalent, with Google able track journeys between sites and sell advertising, adopting something like Piwik may be seen as an advantage by some end-users.

Web bug

At the heart of most analytics systems, including Google Analytics and Piwik, and with/without Javascript, is a one-pixel hidden GIF image. This so-called Web beacon (Web bug) is hosted by the analytics server, and is used to record a user's visits. (The Javascript provided by most analytics tools are merely wrappers around this web-bug, to add extra parameters like screen-resolution and browser capabilities among other things.)

One aim of the Track OER project is to explore the use of a Creative Commons License image in place of the hidden GIF.

AlternateImage plugin

So, to that end, we have forked Piwik (network), and created a plugin named AlternateImage. This adds an extra parameter named img to the Piwik tracking API, which is used to specify the image to display. The value takes the form cc:{license}, for example cc:by-nc-sa.

A standard Piwik no-Javascript tracking call takes the form,

<!-- Piwik Image Tracker -->
<img style="border:0" src="http://demo.piwik.org/piwik.php?idsite={$IDSITE}&rec=1" alt="" />
<!-- End Piwik -->

 

The extended tracking call looks like this,

<!-- Piwik Image Tracker -->
<img style="border: 0;" src="http://demo.piwik.org/piwik.php?idsite={$IDSITE}&rec=1&img=cc:by-nc-sa" alt="" />
<!-- End Piwik -->

 

The AlternateImage plugin currently contains the larger 88 x 31 pixels PNG images. In time it will be extended with the compact Creative Commons License images, with the parameter taking the form ?img=cc:by-nc-sa/2.0/uk/80x15 (URL encoded, naturally). As an aside, the value for img is a form of Compact URI. So AlternateImage can be extended for other logos and icons.

You will be able to see Piwik and the AlternateImage plugin in use soon.

I've also found a very useful PHP library called codeigniter-piwik, and developed by Bryce Johnston (wingdspur).

Extra content

Embedded Content

Contribute

Contribute to the discussion

Please log in to post a comment. Register here if you haven't signed up yet.