« Back
in piwik analytics intranet read.

Intranet Web App Analytics with Piwik.

Finding something to measure "usage"

So the company I work for was looking for a way to measure the amount of users and how much time they spent on each one of the ever growing amount of web apps at various locations and we didn't want to rewrite all the applications to start logging what type of events happened for reporting; More on that later.

Google analytics obviously looked like a good choice but we didn't have a fully qualified domain name available for the outside world.

Choosing Piwik

Behold, Piwik! It's open source (read free), has a customizable widgety dashboard and sends automated reports. Each widget has an export button and some of them can transform into charts. I bet management would love this!

Setting it up on Windows Server

The company runs nothing but .NET but for the monthly price of $0, I was willing to install my nemesis, PHP. Of course that meant installing a web host that supported the PHP modules so I opted for Apache. For a database it uses MySQL

Step 1. Install Apache Web Server

There's a few download links available on the Apache site but the one you will want to go to is here. Click on Binaries and choose the latest version which will present with you with an .msi file. Installing that is a cinch and pretty much painless.

If you already have other services installed using port 80 you'll need to go into the Apache install folder e.g.
C:\Program Files\Apache Software Foundation\Apache2.2\conf\
and edit httpd.conf.
Change Listen 80 to something like Listen 8080

Step 2. Install PHP

The latest version of PHP for windows at PHP.net was 5.5.13 at the time of writing. I found installing it manually to be a mess and didn't work properly with Windows Server 2003 (Yes I know it's 11 years old but I have to work with what I've got).

Luckily Piwik works with 5.3 and 5.3 also happened to have a .msi file!

Note: During the install make sure you click install into Apache when presented the option and point to your Apache install directory.

To test if everything is honky dory you can put this test.php file into the Apache2.2\htdocs folder.

test.php :

    <html>
        <body>
            <?php
            phpinfo();
            ?>
        </body>
    </html>

Make note of where your php.ini conf directory is pointing to. In this case mine was C:\WINDOWS

You'll need to modify the php.ini file inside your PHP install directory. Remove the comment from the line:
mbstring.func_overload = 0 and add in edit the extension directory to the ext folder of where you installed PHP e.g:
extension_dir="C:\Program Files\PHP\ext"

This is so that Piwik can use the mysqli or pdo/mysql extensions to connect to MySQL.

Now copy this php.ini file to C:\WINDOWS because that's what came out of our phpinfo details earlier and restart Apache.

Step 3. MySQL User for Piwik

From the Piwik site:

$ mysql -u adminusername -p
mysql> CREATE DATABASE piwik;  
mysql> CREATE USER 'piwik'@'localhost' IDENTIFIED BY 'password';  
mysql> GRANT ALL PRIVILEGES ON piwik_db_name_here.* TO 'piwik'@'localhost' WITH GRANT OPTION;  

Create this custom user and replace the necessary strings.

Step 4. Copying Piwik Into Apache

Download a copy of Piwik and unzip the contents into your htdocs folder in apache. Navigate to http://localhost:8080/index.php and you should get the Piwik install page.

Fill in the relevant information and you're good to go!

comments powered by Disqus