Skip to main content

Home

Matomo (preview only)

Notice

This feature is in beta/preview mode.

Preview features are in beta and are subject to change. The design and code is less mature than official GA features and is being provided as-is with no warranties. Preview features are not subject to the support SLA of official GA features. We do not recommend you deploy Preview features in a production environment.

Matomo is a free and open-source web analytics platform that runs on MySQL or MariaDB. When you integrate Matomo with Unravel you get information on page visits in Unravel UI.

You can co-locate Matomo with Unravel Server or install it on a separate host. Make sure that your Matomo host meets the sizing requirements for tracking 100,000 pageviews per month. Matomo has no data collection or storage limits, so if you need to adjust your MySQL database size, follow their instructions.

Note

Matomo works with RHEL 6.0-7.6 and CentOS 6.10-7.6.

It is only compatible with Unravel 4.5.1.2 and onward.

  1. Install NGINX.

    yum install epel-release
    yum install nginx
  2. Install PHP.

    If the host machine's underlying operating system is CentOS 7.x, install PHP7.3, because the default PHP version on CentOS 7 is PHP 5.4, which isn't supported by Matomo.

    yum install http://rpms.remirepo.net/enterprise/remi-release-7.rpm
    yum install --enablerepo=remi-php73 php php-mcrypt php-cli php-gd php-curl php-mysql php-ldap php-zip php-fileinfo php-fpm php-mbstring php-dom php-xml php-simplexml
  3. Create a user and database for Matomo and connect it to Unravel. Perform only one of the following steps based up the database you are using.

  4. Configure PHP.

    On the Matomo host, edit /etc/php-fpm.d/www.conf as follows:

    1. Change these lines:

      Old

      New

      user = apache

      user = nginx

      group = apache

      group = nginx

    2. Add the following line after listen = 127.0.0.1:9000.

      listen = /var/run/php-fpm/php-fpm.sock
    3. Change these lines (notice the removal of the semicolon):

      Old

      New

      ;listen.owner = nobody

      listen.owner = nginx

      ;listen.group

      listen.group = nginx

      ;listen.mode = 0660

      listen.mode = 0660

  5. Configure nginx.

    1. On the Matomo host, create the directory /etc/nginx/snippets.

      mkdir /etc/nginx/snippets
    2. Create /etc/nginx/snippets/fastcgi-php.conf with the contents shown below.

      fastcgi_connect_timeout 60;
      fastcgi_send_timeout 180;
      fastcgi_read_timeout 180;
      fastcgi_buffer_size 512k;
      fastcgi_buffers 512 16k;
      fastcgi_busy_buffers_size 1m;
      fastcgi_temp_file_write_size 4m;
      fastcgi_max_temp_file_size 4m;
      fastcgi_intercept_errors off;
      
      fastcgi_param SCRIPT_FILENAME   $request_filename;
      fastcgi_param PATH_INFO         $fastcgi_path_info;
      fastcgi_param PATH_TRANSLATED   $document_root$fastcgi_path_info;
      fastcgi_param QUERY_STRING      $query_string;
      fastcgi_param REQUEST_METHOD    $request_method;
      fastcgi_param CONTENT_TYPE      $content_type;
      fastcgi_param CONTENT_LENGTH    $content_length;
      fastcgi_param SCRIPT_NAME       $fastcgi_script_name;
      fastcgi_param REQUEST_URI       $request_uri;
      fastcgi_param DOCUMENT_URI      $document_uri;
      fastcgi_param DOCUMENT_ROOT     $document_root;
      fastcgi_param SERVER_PROTOCOL   $server_protocol;
      fastcgi_param REQUEST_SCHEME    $scheme;
      fastcgi_param HTTPS             $https if_not_empty;
      fastcgi_param HTTP_PROXY        "";
      fastcgi_param GATEWAY_INTERFACE CGI/1.1;
      fastcgi_param SERVER_SOFTWARE   nginx/$nginx_version;
      fastcgi_param REMOTE_ADDR       $remote_addr;
      fastcgi_param REMOTE_PORT       $remote_port;
      fastcgi_param SERVER_ADDR       $server_addr;
      fastcgi_param SERVER_PORT       $server_port;
      fastcgi_param SERVER_NAME       $server_name;
      fastcgi_param REDIRECT_STATUS   200;
    3. Create /etc/nginx/conf.d/matomo.conf with the contents shown below.

      server {
          listen [::]:80; # remove this if you don't want Matomo to be reachable from IPv6
          listen 80;
          server_name YOUR_SERVER.YOUR_DOMAIN; # list all domains Matomo should be reachable from
          access_log /var/log/nginx/matomo.access.log;
          error_log /var/log/nginx/matomo.error.log;
      
          ## uncomment if you want to enable HSTS with 6 months cache
          ## ATTENTION: Be sure you know the implications of this change (you won't be able to disable HTTPS anymore)
      #    add_header Strict-Transport-Security max-age=15768000;
      
          ## replace with your SSL certificate
      #    ssl_certificate /path/to/fullchain.pem;
      #    ssl_certificate_key /path/to/privkey.pem;
      #    include ssl.conf; # if you want to support older browsers, please read through this file
      
          add_header Referrer-Policy origin; # make sure outgoing links don't show the URL to the Matomo instance
          
          root /var/www/matomo/; # replace with path to your matomo instance
          
          index index.php;
              
          ## only allow accessing the following php files
          location ~ ^/(index|matomo|piwik|js/index).php {
              include snippets/fastcgi-php.conf; # if your Nginx setup doesn't come with a default fastcgi-php config replace this with the one from this repository
              fastcgi_param HTTP_PROXY ""; # prohibit httpoxy: https://httpoxy.org/
              fastcgi_pass unix:/var/run/php-fpm/php-fpm.sock; #replace with the path to your PHP socket file
              #fastcgi_pass 127.0.0.1:9000; # uncomment if you are using PHP via TCP sockets
          }
          
          ## needed for HeatmapSessionRecording plugin
          location = /plugins/HeatmapSessionRecording/configs.php { 
              include snippets/fastcgi-php.conf;
              fastcgi_param HTTP_PROXY "";
              fastcgi_pass unix:/var/run/php-fpm/php-fpm.sock; #replace with the path to your PHP socket file
      #       fastcgi_pass 127.0.0.1:9000; # uncomment if you are using PHP via TCP sockets
          }
          
          ## deny access to all other .php files
          location ~* ^.+\.php$ {
              deny all;
              return 403;
          }
      
          ## serve all other files normally
          location / {
              try_files $uri $uri/ =404;
          }
          
          ## disable all access to the following directories
          location ~ /(config|tmp|core|lang) {
              deny all;
              return 403; # replace with 404 to not show these directories exist
          }
          location ~ /\.ht {
              deny  all;
              return 403;
          }
      
          location ~ \.(gif|ico|jpg|png|svg|js|css|htm|html|mp3|mp4|wav|ogg|avi|ttf|eot|woff|woff2|json)$ {
              allow all;
              ## Cache images,CSS,JS and webfonts for an hour
              ## Increasing the duration may improve the load-time, but may cause old files to show after an Matomo upgrade
              expires 1h;
              add_header Pragma public;
              add_header Cache-Control "public";
          }
      
          location ~ /(libs|vendor|plugins|misc/user) {
              deny all;
              return 403;
          }
      
          ## properly display textfiles in root directory
          location ~/(.*\.md|LEGALNOTICE|LICENSE) {
              default_type text/plain;
          }
      }
      
    4. In /etc/nginx/conf.d/matomo.conf, replace server_name with the name of your Matomo server.

  6. On the Matomo host, enable and start all services.

    systemctl enable php-fpm
    systemctl start php-fpm
    systemctl enable nginx
    systemctl start nginx
  7. On the Matomo host, install Matomo.

    1. Download the latest version of Matomo.

      curl https://builds.matomo.org/matomo-latest.tar.gz -o /tmp/matomo-latest.tar.gz
    2. Install it in /var/www.

      tar zxf /tmp/matomo-latest.tar.gz -C /var/www/
    3. Change the owner to nginx.

      chown -R nginx /var/www/
  8. Configure Matomo.

    Using a web browser, go to http://server_name (as configured in /etc/nginx/conf.d/matomo.conf) and enter the following information at the prompts.

    Prompt

    Value

    Database server

    If you installed Matomo on the same host as your database, enter 127.0.0.1. Otherwise, enter the IP address of your database server, which depends on which database you're using (the database bundled with Unravel, your own MySQL, or your own MariaDB).

    Login

    matomo

    Password

    The password you assigned to the user matomo

    Database name

    matomo

  9. Confirm Matomo's connection to Unravel.

    On the Matomo UI, you should see the dashboard, which gives you a single pane of glass overview of Unravel UI usage:

    matomo-dashboard-740w.png

    Visitors | Visits Log shows you what pages visitors have looked at in Unravel UI.

    matomo-visitslog-740w.png
Matomo properties