Installing Piwik

  • Piwik is an open source web analytics application. It rivals Google Analytics and includes even more features and allows you to brand your brand and send out custom daily, weekly, and monthly reports to your clients. For an overview and screenshots you can visit my blog entry here.

    Install LAMP

    LAMP is pre-requisite for Piwik. I have a full tutorial on installing LAMP here. If your sever already has LAMP installed you can skip to the next step.

    Downloading and installing Piwik

    This command will download and extract the latest version of Piwik

    cd /var/www/html/ 
    apt-get install unzip

    Assigning permissions for Piwik

    The command above created a new directory called Piwik under /var/www/html/ now we we need to give the appropriate permission to that directory.

    chown -R www-data:www-data /var/www/html/piwik
    chmod -R 0755 /var/www/html/piwik/tmp

    note: if the chown and chmod commands don’t work verify the piwik directory exists. If not run the first command to download and extract piwik again.

    Creating the Database

    Now we need to create the piwikdb. Run the following command and replace “mySecurepassword” with your own password.

    CREATE DATABASE piwikdb;
    CREATE USER [email protected] IDENTIFIED BY 'mySecurepassword';
    GRANT ALL PRIVILEGES ON piwik.* TO [email protected];

    Install PHP MBstring

    Our last step is to install the PHP MBstring. Just run this simple command.

    sudo apt-get install libapache2-mod-php

    You will also need to restart Apache

    service apache2 restart

    Configuring Piwik

    Browse to Piwik by going to http://yourserverIP/piwik

    Click next and you will run through the system check. Everything should pass if not make sure LAMP is properly installed and configured.


    Now you will configure the database you already setup. Just use the appropriate credentials and then click Next.


    Upon successfully database setup you should see this.


    Create an admin user


    Now we need to add our website. This is very easy just fill out the following fields.


    Piwik will now give you the Javascript Tracking Code. You can add that manually just like you do with Google Analytics or you can use the WP plugin which is great and gives you stats right from your site. If you are using WordPress scroll down and see the plugin installation.


    Piwik WordPress Plugin Installation

    Download the WP-Piwik plugin here. Now upload the plugin to your WordPress site and activate it.

    Once you activate head over to Settings > WP-Piwik. Fill out your server information. We will get the Auth Token here in a second.


    Login to Piwik and select the User icon on the top right of the toolbar.


    Then select API on the left menu. Your token will be under User authentication. Copy that over to your WordPress site.


    Configure the settings you would like to show on your dashboard.


    Now you need to actually enable the tracking. Select default tracking, change any settings you’d like and hit save.


    Now if you go back to Piwik you should see your website on the dashboard. Note all alot of the information will be blank since it uses yesterday’s information like Google Analytics.


    Congratulations you installed Piwik on Ubuntu 16.04 LTS and configured the Piwik Plugin on your WordPress site.

Log in to reply