Saturday, May 9, 2009

Generating Website Statistics With Piwik, An Open-Source, Google Analytics-Like Web Analytics Tool - Page 2

Now fill in a user name for the Piwik administrator (e.g. admin), a password for that user, and the email address of that user. This is the username and password that you'll need later on to log into Piwik:














You can configure Piwik to generate reports for multiple web sites later on, but during the installation, we configure Piwik for our first (and maybe only?) web site. Fill in a name for that web site and its URL:














Afterwards, Piwik will display a Javascript code for that web site. Copy it and paste it right above the tag of all pages belonging to the web site that you've configured in the last screen (www.example.com):














Click on Next afterwards:

The installation is now finished. Click on Continue to Piwik:





3 Using Piwik

Now log in with the account you've created during the installation:



This is the Piwik Dashboard (in my example it's quite empty, but on a real-life system, you should see quite a lot statistics after some time):

You can manage Piwik by clicking on the Settings link in the upper right corner. Here you can enable or disable Piwik plugins,...

..., manage users and access permissions,...


... and add further web sites (you will get a unique Javascript code for each web site):


4 High-Traffic Web Sites

The Piwik reports are generated in real-time which can make the Piwik web interface a little bit slow on high-traffic web sites. Therefore you should set up a cron job (as described on http://piwik.org/docs/setup-auto-archiving/) that generates the reports once a day - the Piwik interface should then react faster again:

crontab -e

MAILTO="falko@example.com"
5 0 * * * www-data /var/www/example.com/web/piwik/misc/cron/archive.sh

(This generates the reports each day at 00:05h. Make sure you use the correct user name for the web server. On Debian/Ubuntu, it's www-data, on Fedora/CentOS, it's apache.)

Make the /var/www/example.com/web/piwik/misc/cron/archive.sh file executable:

chmod 755 /var/www/example.com/web/piwik/misc/cron/archive.sh

Then run it manually to see if it throws any errors:

/var/www/example.com/web/piwik/misc/cron/archive.sh

If you see something like this...

[root@server1 cron]# /var/www/example.com/web/piwik/misc/cron/archive.sh
/var/www/example.com/web/piwik/misc/cron/archive.sh: line 20: /usr/bin/php5: No such file or directory
[root@server1 cron]#

... run...

which php

... to find out where PHP is located...

[root@server1 cron]# which php
/usr/bin/php
[root@server1 cron]#

... and edit /var/www/example.com/web/piwik/misc/cron/archive.sh:

vi /var/www/example.com/web/piwik/misc/cron/archive.sh

Change PHP_BIN; also adjust the PIWIK_PATH variable:

[...]
PHP_BIN=/usr/bin/php
PIWIK_PATH=/var/www/example.com/web/piwik/index.php
[...]

Then run

/var/www/example.com/web/piwik/misc/cron/archive.sh

again. It shouldn't throw any errors anymore.

No comments: