Google Analytics is the defacto standard for website operators in the area of website traffic analysis. Not everyone wants to send their website data directly to Google, and not everyone wants to be dependent on a company.
The Google Analytics alternative: Matomo
Many don’t even know that there are alternatives to Google Analytics. A Google Analytics alternative to install yourself is Matomo, the former Piwik. Matomo is an open source solution and in my opinion even better than Google Analytics in some points. This article describes how to install Matomo quickly and easily with Docker.
Matomo briefly introduced
Matomo is extremely extensive and, like Google Analytics, also offers analyzes and reports on top keywords and search engines, websites, social media websites, top page URLs, page titles, user countries, providers, operating system, browser market distribution, screen resolution, desktop VS-Mobile, engagement (time on site, pages per visit, repeated visits), top campaigns, custom variables, top entry / exit pages, downloaded files and much more.
What I personally like about Matomo is that it offers many functions and tools for GDPR. There is an opt-out form that can be integrated directly into the data protection settings as an IFrame to deactivate tracking. Matomo is also economical when it comes to creating cookies. Since you have full control over the system, you can determine exactly which data is analyzed and deal with it in your data protection regulations. How long something is saved is up to you and you can simply clean up the system. The data is also on your server, not somewhere in the USA or other European countries.
Requirements for the Docker installation
Matomo can easily be installed without Docker, but it’s much easier and faster with Docker. If you decide against Matomo, you have freed your system from Matomo faster and cleaner than if you manually installed the software on your server.
For local tests you need:
- Docker compose
- A Linux system or at least Windows 10 Pro
For productive use you need:
- Docker compose
- A Linux system (VPS) or Windows server
- A (sub) domain so that your website can send data to Matomo
- A website to connect to Matomo
What could the hosting look like?
Download from GitHub
I created a Docker-Compose file for you to install Matomo. You can find the latest version in my GitHub repository for Matomo. Download the complete directory and adapt the user names and passwords to your ideas in the db.env file. If necessary, adjust the port in the Docker-Compose file. This is set to 8090 by default. Then run the Docker-Compose file with admin (root) rights. On Linux this works as follows:
sudo docker-compose up
You can then access Matomo with “hostname: 8090”, establish the database connection and create an administrator user.
The Docker Compose file
The Docker Compose file describes which services (containers) should be pulled up. At Matomo, this is a MariaDB database (alternatively MySQL) and Matomo itself. So that the data from the MariaDB database and Matomo are persistent, two named volumes are created in which the data is stored. You should back up these volumes using RSync or a method of your choice.
version: "3" services: db: image: mariadb command: --max-allowed-packet=64MB restart: always volumes: - db:/var/lib/mysql environment: - MYSQL_ROOT_PASSWORD=matomo env_file: - ./db.env app: image: matomo restart: always volumes: - ./config:/var/www/html/config - ./logs:/var/www/html/logs - matomo:/var/www/html environment: - MATOMO_DATABASE_HOST=db - VIRTUAL_HOST= env_file: - ./db.env ports: - 8090:80 volumes: db: matomo:
The db.env file
The db.env file describes how the database for Matomo should be installed
MYSQL_PASSWORD=matomo MYSQL_DATABASE=matomo MYSQL_USER=matomo MATOMO_DATABASE_ADAPTER=mysql MATOMO_DATABASE_TABLES_PREFIX=matomo_ MATOMO_DATABASE_USERNAME=matomo MATOMO_DATABASE_PASSWORD=matomo MATOMO_DATABASE_DBNAME=matomo