Technical documentation : Debian
Documentation based on Debian distribution

> > > > Trac and Piwik: traffic analysis of Trac

Trac and Piwik: traffic analysis of Trac

Quote from the author :

This article is a translation of Trac et Piwik : analyse des statistiques de fréquentation de Trac published in french. We translated it following the request of Matt from the Piwik team.
All comment on any mistakes are welcome.

Trac is simply a website like any other, it is frequented by visitors. It may therefore be interesting to analyze visitor statistics of Trac instances on the server.

To do this we will use a third party software called Piwik. Piwik is an open source software that provides all necessary functionalities to analyze traffic statistics and can easily be compared to other tools (proprietary or not) such as Google Analytics.

To do this we created a plugin Piwik4Trac for Trac inspired by the plugin TracGoogleAnalytics developed by Pedro Algarvio.


At first, you must have previously installed a Piwik server (we will not see the setup here) and at least one instance of Trac version 0.11 or more.

As you already have a functional Trac instance, many needed dependencies are already operational (Python, setuptools etc ...).

Common installation

The following command is the easiest way to install the plugin:

  1. sudo easy_install Piwik4Trac

Then, we reload the configuration of the web server that Trac uses (Apache in our case):

  1. sudo /etc/init.d/apache2 force-reload

After these commands, you can go to the plugin setup.

Compilation and installation from source

The source code of the Piwik4Trac plugin is available for consultation here :

At first, we’ll get the sources via SVN [1] :

  1. svn co

Trac requires Python-eggs package for the plugins, we’ll create one with the following commands :

  1. # We go first in the newly created directory
  2. cd Piwik4Trac
  3. # We create the egg package
  4. python bdist_egg


Then, you should have a file named dist/Piwik4Trac-0.0.2-py2.5.egg if you use Python version 2.5. This name may be different depending on the version of Python installed on your server.

To install it on your trac instance, it’s then necessary to copy this file into the plugins/ of your trac instance with a command that looks like the following (change the name of the file and copy the path to your Trac installation where needed) :

  1. sudo cp dist/Piwik4Trac-0.0.2-py2.5.egg /var/trac/nom_de_l_instance/plugins/

It is then necessary to give the rights to the web server on this file. In case you use Apache, the following command will be enough:

  1. sudo chown www-data:www-data /var/trac/nom_de_l_instance/plugins/*

Then you reload the configuration of the web server that Trac uses. In the case of Apache, the following command :

  1. sudo /etc/init.d/apache2 force-reload

Setup of the Piwik4Trac plugin for Trac

To enable the plugin in Trac, you must add these lines in the trac.ini file of your Trac instance. As this example:

  1. sudo nano /var/trac/nom_de_l_instance/conf/trac.ini

Add these lines (the first is not necessary if you already have a [components] in the configuration file:

  1. [components]
  2. tracext.piwik.* = enabled


Then, if you log in as administrator in your Trac instance [2], you should see the administration panel link Piwik > Analytics in the left side.

If you go to this page, two informations are requested:

  • Tracking server : corresponds to the address (URL) of the Piwik server which will record the data. This information must be filled in without the "http://" or "https: / /" or final slash (eg :;
  • Tracked Site : corresponds to the numerical identifier defined by the server Piwik used for the site analyzed (your current instance of Trac);

If this informations are correct, you should see your statistics in your Piwik server for the Trac instance.

External links


[1If Subversion is not installed on your server, you can install it this way:

  1. sudo apt-get install subversion

[2If after logging on, you can not access the administration panel, it means you are not considered as admin.

To correct this, it is necessary to run the following command:

  1. trac-admin /var/trac/nom_de_l_instance/ permission add login_utilisateur TRAC_ADMIN

No comments

Who are you?
[Log in]
Enter your comment here

This form accepts SPIP shortcuts {{bold}} {italic} -*list [text->url] <quote> <code> and HTML code <q> <del> <ins>. To create paragraphs, just leave empty lines.