Showing posts with label Piwik. Show all posts
Showing posts with label Piwik. Show all posts

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.

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

This guide explains how you can install and use Piwik for generating website analytics. The reports generated by Piwik are similar to the ones generated by Google Analytics. Piwik is an Open-Source (GPL) tool that you can download and host on your own servers which means you are in full control over your data. In addition to that, Piwik's functionality can be extended by plugins.

I do not issue any guarantee that this will work for you!

1 Preliminary Note

I'm using the web site www.example.com here with the document root /var/www/example.com/web/. I'm assuming that the web site is working, and that PHP 5.1 or newer is installed on the server. I'm also assuming that you have an empty MySQL database that you can use for the Piwik installation. I'm using the database c0piwik with the database user c0piwik and the password piwik here (ask your hoster to create an empty MySQL database for you, or create it yourself through your control panel, e.g. ISPConfig).

2 Installing Piwik

Download Piwik to your desktop and unzip it. This will give you a folder latest/piwik/. Upload the piwik/ folder to your document root (e.g. with FTP). In my case where the document root is /var/www/example.com/web/ this will result in a folder /var/www/example.com/web/piwik/.

Now open a browser and go to http://www.example.com/piwik to start the Piwik installer. If you see something like this...












... either run the shown commands in the command line (if you have shell access)...

chmod 777 /var/www/clients/client0/web1/web/piwik/tmp
chmod 777 /var/www/clients/client0/web1/web/piwik/tmp/templates_c
chmod 777 /var/www/clients/client0/web1/web/piwik/tmp/cache

(In my installation, /var/www/example.com/web/ is a symlink to /var/www/clients/client0/web1/web/, that's why you see /var/www/clients/client0/web1/web/ instead of /var/www/example.com/web/ here in the screenshot and the command.)

... or change the folder permissions in your FTP client:






















(In my installation, the tmp/ folder was empty, so I did not have to change permissions for tmp/templates_c and tmp/cache.)

Then refresh the Piwik page in your browser. You should now see the welcome page of the installer. Click on Next:











On the next page, the installer performs a system check to see if all prerequisites are fulfilled. If there's a problem with the config folder,...















... scroll down, and you should see the command to execute to solve the problem (if you don't have shell access, you can as well fix the permissions with your FTP client):






















After you have fixed the problem, scroll down and click on the Refresh the page link:













The system check should now succeed. Click on Next:















Now we come to the database settings. Fill in the database name of your empty database as well as the database user and the password. You can leave the table prefix (piwik_) as it is. The same goes for the MySQL server (localhost) unless it is located on a remote server:

















The installer creates the necessary database tables. Click on Next:
























Page 2