Hacking

If you want to work on the tracking code you should have a look at the original PiwikTracking.php in the Piwik source tree. There’s also a PiwikTracking.java implementation in the release.

To run the unit tests you need to:

  • Create a new Piwik site
  • Configure your environment
  • Enable tracker debugging

Creating a new site

You want to create a new site specifically for running the unit tests as to not pollute a real site with test data.

Configuring your environment

The tests assume that the following variables are set in your shell environment:

PIWIK_SITE_ID = '<ID of your test site>'
PIWIK_TRACKING_API_URL = '<Your Piwik tracker API URL>'
PIWIK_ANALYTICS_API_URL = '<Your Piwik API URL>'
PIWIK_TOKEN_AUTH = '<Your Piwik auth token>'
PIWIK_GOAL_ID = None

PIWIK_TRACKING_API_URL must contain the URL to your Piwik install’s /piwik.php, something like ‘http://example.com/piwik.php‘. PIWIK_TRACKING_API_URL must contain the URL to your Piwik install’s root, so ‘http://example.com/‘.

The auth token must have admin access for the site defined in PIWIK_SITE_ID. The goal id doesn’t have to be set, the goal can be autogenerated by the tests.

Please let me know if you need a different way of defining those settings.

Enabling tracker debugging

Some unit tests parse the output of the tracker script, so you have to enable debugging in your Piwik install’s /piwik.php:

$GLOBALS['PIWIK_TRACKER_DEBUG'] = true;