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/ 
    wget http://builds.piwik.org/latest.zip
    apt-get install unzip
    unzip latest.zip
    

    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];
    FLUSH PRIVILEGES;
    exit
    

    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.

    2016-08-03_10-22-57.png

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

    2016-08-03_10-27-24.png

    Upon successfully database setup you should see this.

    2016-08-03_10-28-20.png

    Create an admin user

    2016-08-03_10-28-54.png

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

    2016-08-03_10-29-52.png

    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.

    2016-08-03_10-30-11.png

    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.

    2016-08-03_17-24-05.png

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

    2016-08-03_17-24-35.png

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

    2016-08-03_17-24-54.png

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

    0_1470322452608_upload-d9ea5997-cefd-4d67-9617-3baaf42c244d

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

    2016-08-03_17-25-42.png

    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.

    2016-08-03_10-48-32-1.png

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


Log in to reply