You can support us by downloading this article as PDF from the Link below. Download the guide as PDF

A strong online presence is a target that most organizations, e-commerce sites, blogs, politicians and every faction that depends on it requires in order to increase the depth of their customers reach. While it is a beautiful thing to have such a fabulous online presence, how exactly do you get to measure its successes, failures, opportunities and gain an insight into what to improve on? Feedback can be one strategy but as you know, one cannot fully depend on it due to its erratic nature. On the other side of the tide, there is this one thing that can be utilized to produce dependable insights.

Data has revolutionized how decisions are made in many facets of life. Be it in education, business, health care and even in politics. We can borrow from this to curve ourselves a better understanding of the progress of our blogs, e-commerce sites, websites and other online ventures powered by the web. It is uncommon to find a website without data wherever it is hosted and hence the rise of Web Analytics. Briefly, Web Analytics is the process of collecting, processing, and analyzing of website data and we thank Matomo for coming up with a leading open alternative to Google Analytics that gives you full control over your data. Let us now delve into this Matomo analytics platform.

Matomo is a full-featured PHP MySQL software program that you download and install on your own webserver and lets you easily collect data from websites, apps & the IoT. Subsequently, it gives you the opportunity to visualize this data and extract insights. Privacy is built-in and with a few clicks, you can now install Matomo directly in your WordPress as a plugin.

“I will prepare and some day my chance will come.”
― Abraham Lincoln

Unique Matomo Features

Matomo has the following features:

  • Full control of your web analytics data: since Matomo is installed on your server, the data is stored in your own database and you can get all the statistics using the powerful Matomo Analytics API.
  • Matomo is a Free Software which can easily be configured to respect your visitors’ privacy.
  • Modern, easy to use User Interface.
  • Matomo features are built inside plugins: you can add new features and remove the ones you don’t need.
  • A vibrant international Open community of more than 200,000 active users.
  • Advanced Web Analytics capabilities such as E-commerce Tracking, Goal tracking, Campaign tracking, Custom Variables, Email Reports, Custom Segment Editor, Geo Location, Real-time visits and maps, and a lot more!

System Requirements

In order to install and use Matomo analytics platform on your CentOS 8 server, we must meet the following requirements.

  • PHP 5.5.9 or greater
  • Web Server
  • MySQL version 5.5 or greater, or MariaDB
  • PHP extension pdo and pdo_mysql, or the MySQLi extension

Step 1: Server preparation

Jump into the terminal of your fresh CentOS 8 server, update it and install essential tools we shall use in our installation process.

sudo dnf update
sudo dnf -y install git unzip vim nginx

Disable SELinux

This is optional if you can handle SELinux with ease. To set it in Permissive mode, run the command below in your server.

sudo sed -i 's/^SELINUX=.*/SELINUX=permissive/g' /etc/selinux/config

Step 2: Install PHP

Let us get the PHP requirements above met by installing it in our server. Kindly follow How To Install PHP 7.4 on CentOS 8 | RHEL 8 guide to get everything up and running fast.

Once your PHP 7.4 is well installed, add the following modules as illustrated below

sudo yum install -y php-cli php-pdo php-common php-mysql php-curl php-json php-zip php-gd php-xml php-mbstring

Edit php-fpm file /etc/php-fpm.d/www.conf and set the user and group to nginx. They are usually set to apache by default.

$ sudo vim /etc/php-fpm.d/www.conf

user = nginx
group = nginx

Open up your php-fpm ini file and add/edit the details shown below. They include Timezone, and memory limit settings. Add your date.timezone and change memory_limit to 512MB.

$ sudo vim /etc/php.ini

memory_limit = 512M

[Date]

date.timezone = Africa/Nairobi

Restart php-fpm after you have made those changes

sudo systemctl restart php-fpm

Step 3: Install and setup database

Matomo requires a Database as it had been mentioned before. Due to that, we are going to setup and use MariaDB. Fortunately, we have a detailed guide already to get MariaDB 10.5 installed on CentOS 8. Check out Install MariaDB on CentOS 8 | CentOS 7

After you have the database installed, create a database and user that Matomo will use. Get this accomplished as illustrated below. You are free to name your database and user differently and ensure you use a safe password.

$ mysql -u root -p

MariaDB [(none)]> CREATE DATABASE matomodb;
MariaDB [(none)]> GRANT ALL ON matomodb.* TO 'matomoadmin' IDENTIFIED BY 'SafePassword';
MariaDB [(none)]> FLUSH PRIVILEGES;
MariaDB [(none)]> quit

Step 4: Matomo Analytics installation

We are going to create a directory that we shall drop Matomo files in. This will also help us in setting up the root directory that our web server will be looking into serve the files.

sudo mkdir /var/www/html-matomo && cd /var/www/html-matomo

Fetch Matomo files and unzip them.

sudo wget https://builds.matomo.org/matomo.zip
sudo unzip matomo.zip

The command above will unzip the files and lay matomo folder in the directory. Our intended root directory becomes /var/www/html-matomo/matomo.

Step 5: Configure webserver

Open Nginx configuration file and edit the server block to look like below. Ensure you place the right server_name and root directory depending on your environment.

$ sudo vim /etc/nginx/nginx.conf

    server {
        listen       80 default_server;
        listen       [::]:80 default_server;
        server_name  _;
        root         /var/www/html-matomo/matomo;
        server_name example.com;

        index index.php index.html;
        # Load configuration files for the default server block.
        include /etc/nginx/default.d/*.conf;

        location / {
                try_files $uri /index.php$is_args$args;
        }
        location ~ \.php$ {
           fastcgi_pass unix:/run/php-fpm/www.sock;
           fastcgi_index index.php;
           fastcgi_read_timeout 240;
           fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
           include fastcgi_params;
               fastcgi_split_path_info ^(.+.php)(/.+)$;
        }
    }

Modify the permissions on the root directory and restart the webserver

sudo chown -R nginx:nginx /var/www/html-matomo
sudo chmod -R 755 /var/www/html-matomo
sudo systemctl restart nginx php-fpm

Modify firewall rules in order to allow port 80 or 443 as you wish:

sudo firewall-cmd --permanent --add-service={http,https}/tcp
sudo firewall-cmd --reload

Step 6: Finish Matomo Installation via web interface

After everything has gone well thus far, we should be at our final stages of installing Matomo Analytics. In this step open http://[ip-address-or-domain-name] to launch Matomo installation panel on your browser. The first page will be a welcome page as shown below. Click “Next

System Check

On the next page, Matomo will check your server against what it requires for successful installation. All of the ticks should be green on this page. Scroll down and click “Next”

Database Setup

In this page, enter the database details we created in Step 3 and click on “Next“. Give it time to create tables and you should get Tables created with success! message.

Creating Tables

On this next page. Simply click on “Next“.

Super User

The super user is the user that you create when you install Matomo. Do not lose this information; it is the only way for you to log in to Matomo for the first time. This user is the only one super user in each Matomo installation. The super user can perform administrative tasks such as adding new websites to monitor, adding users, changing user permissions, and enabling and disabling plugins.This user has the highest permissions. Choose your username and password and fill in the information then click “Next

Setup a Website

In this step, enter the name and URL of the first website you would wish to track. You can add more websites once the installation is complete

JavaScript Tracking Code

To track your web traffic with Matomo you need to make sure some extra code is added to each of your webpages. In case your blog or website runs on common CMS such as : WordPress | Squarespace | Wix | SharePoint | Joomla | Shopify, there are pre-made plugins that will do that for you. If there is no plugin for your use case, you will be provided with extra code to add to each of your webpages immediately before the closing tag. Click “Next” after getting the code.

Congratulations

Congratulations! Your Matomo installation is complete. Make sure your JavaScript code is entered on your pages, and wait for your first visitors! Scroll down and click on “Continue to Matomo“. Sign in with the Super User details and you are ready to begin.

If the Matomo JavaScript tracking tag is properly installed on your website, you’ll be receiving real time analytics data. If you are not receiving any data, make sure that you have copied and pasted the Matomo Javascript code to your website’s pages. (Source: Matomo)

That was all about installing Matomo Analytics on your CentOS 8 box. You can find out much more about Matomo by checking out their GitHub space and also visiting Matomo main webpage.

Concluding Words

Matomo analytics presents an easy to use platform that anyone can use. You also get maximum flexibility to do whatever you want and gain powerful insights to grow your business without data limitations or the need for multiple web analytics tools. As usual, give it a try guys and check out if it will make a difference in your businesses or online projects. We appreciate you for stopping by.

Marketing and digital analytics courses to try:

$15.41
$154.12
in stock
Udemy.com
$15.41
$154.12
in stock
Udemy.com
$15.41
$154.12
in stock
Udemy.com

Also Read:

How to Install Open Web Analytics on RHEL 8 / CentOS 8

How to install Matomo (Piwik) Web Analytics Tool on Ubuntu

Install Fathom website analytics tool on Ubuntu / CentOS / Arch Linux

You can support us by downloading this article as PDF from the Link below. Download the guide as PDF