---
title: Matomo
url: 'https://www.niklas-stephan.de/en/wiki/free-open-source-software/matomo'
markdown: 'https://www.niklas-stephan.de/en/wiki/free-open-source-software/matomo.md'
lang: en
date: '2021-06-01'
description: 'Matomo Everyone who deals with web presences has certainly already heard of Google Analytics. With it one can e.g. see from where, under which technical conditions, and when which pages thereof are accessed. Matomo (matomo.org) does not stand for a mozzarella sandwich with mayonnaise and tomatoes, …'
---

#  Matomo 

Everyone who deals with web presences has certainly already heard of [Google Analytics](https://en.wikipedia.org/wiki/Google_Analytics). With it one can e.g. see from where, under which technical conditions, and when which pages thereof are accessed. Matomo ([matomo.org](https://matomo.org/)) does not stand for a mozzarella sandwich with mayonnaise and tomatoes, but is an open-source tool with which the same and partly even more can be achieved. In this article I go into the advantages of using Matomo and also deliver directly an example of how it can be used quickly.

![](https://www.niklas-stephan.de/user/pages/wiki/free-open-source-software/matomo/matomo.webp)

## Data krake – but visitor-friendly

The essential advantage of using Matomo consists in that one can operate it oneself ([Docker Hub](https://hub.docker.com/_/matomo)) and one thus has full control over which data of the visitor is stored where. I myself have been using the tool for many years now and have only positive things to report about it. It can be set entirely GDPR-compliant ([IT-Recht Kanzlei](https://www.it-recht-kanzlei.de/matomo-richtig-verwenden-dsgvo.html)) and nevertheless granularly: which information is stored. For meaningful analyses one does not e.g. need to store the complete IP address of the visitor – to name only one of the many options. Also tools like Google Analytics rely strongly on the use of digital fingerprints (cookies); more on that shortly. But so much beforehand: with Matomo the use of cookies can on request even be completely deactivated!

## How do I install and use Matomo?

1. **The Matomo Cloud** – this is how the provider of Matomo earns its money, besides additionally commercially viable plugins. Analogous to Google Analytics I entrust the data of my users to a third-party provider. Somehow exactly what we do not want.
2. **Integrated as a plugin in a web content management system (WCMS)** – For WordPress and others there is a complete installation of Matomo as a plugin, which can be added via the respectively available marketplace. Here we have no possibility of separating website content and analytics. That is therefore also not particularly performant and only suitable for smaller installations. Besides that of course only works if one uses one of the supported WCMS.
3. **Self hosting** – That is what I describe here, and by means of a container pre-fabricated by Matomo itself ([Docker Hub](https://hub.docker.com/_/matomo)) it is also very easy.

A \\"clean\\" possibility of installing Matomo is thus via Docker Compose containers. In the appendix I have attached a corresponding example file. What I again skip here is the configuration of the reverse proxy together with its settings. We simply assume that I have made the needed settings for my subdomain [stats.handtrixxx.com](http://stats.handtrixxx.com) with the Nginx Reverse Proxy Manager and also have gotten a corresponding certificate from Let's Encrypt from there.

After all that is set up and brought up (duration approx. 20 minutes), we can log in at the web interface of Matomo for the initial configuration. How that works is described extensively and well [here](https://matomo.org/docs/installation/). Thanks to Docker containers we can completely skip the first part of the instructions and start roughly at the point \\"Super User\\".

## How do I now integrate Matomo into my website/app?

As described at the same place on [matomo.org/docs/installation](https://matomo.org/docs/installation/), if we have scrolled a bit there, the use on a first website can now be carried out. Therewith it also becomes clear that with a single Matomo installation several websites/apps can be attached separately from each other or together.

For the integration into a website one can, as proposed by the standard, either use a JavaScript snippet or insert an \\"invisible\\" image via the so-called image tracker. In this way it can now also be set that NO cookie is to be used at the user for tracking. Prime!

## Maintenance

Finally a few tips for the maintenance of our installation. As you, if you have performed an installation yourself, may have already seen, the availability of an update of Matomo is displayed directly in the web GUI and can also be carried out from there.

To keep the containers themselves current, the occasional and also automatable execution of `docker-compose pull` suffices, with subsequent `docker-compose up -d`, from the root directory of your Docker Compose environment.

That is easy.

## Conclusion

Definitely writing this article took longer than a Matomo installation. Besides that I hopefully could make clear that in comparison to other web analytics tools with Matomo there are no essential restrictions, but plenty of advantages. A small drop of bitterness is perhaps that the kind of reports in the web GUI cannot be particularly \\"bent\\". Probably that would however only be desirable at all for larger companies. Besides that there is for it, perhaps as a final glimpse of light, a great API which allows us to use the data captured via Matomo in an application of our choice! See: [developer.matomo.org/api-reference/reporting-api](https://developer.matomo.org/api-reference/reporting-api). Actually the article was only intended as a \\"short\\" addition to a previous one (*More than just Performance King – headless CMS, APIs and IoT for the website*), in which it was among other things about setting up a website with a headless CMS. It has however now become \\"somewhat\\" longer. I ask to excuse the many technical terms. Due to the heterogeneous target audience the choice of words is not always quite easy.

## Appendix

Here an example of a `compose.yml` for the simple commissioning of Matomo.

```yaml
services:
    stats-db:
        image: mysql:5.7
        logging:
            options:
              max-size: "10m"
              max-file: "3"
        container_name: stats-db
        command: --max-allowed-packet=64MB
        restart: always
        networks:
            - dmz
        environment:
            MYSQL_ROOT_PASSWORD: ADMINPASSWORD
            MYSQL_DATABASE: DBNAME
            MYSQL_USER: DBUSER
            MYSQL_PASSWORD: DBUSERPW
        volumes:
            - ./db_data:/var/lib/mysql
    stats-app:
        depends_on:
            - stats-db
        image: matomo:latest
        logging:
            options:
              max-size: "10m"
              max-file: "3"
        restart: always
        networks:
            - dmz
        environment:
            MATOMO_DATABASE_HOST: stats-db
            MATOMO_DATABASE_ADAPTER: mysql
            MATOMO_DATABASE_TABLES_PREFIX: matomo_
            MATOMO_DATABASE_USERNAME: DBUSER
            MATOMO_DATABASE_PASSWORD: DBUSERPW
            MATOMO_DATABASE_DBNAME: DBNAME
        volumes:
            - ./data:/var/www/html

volumes:
    db_data: {}
networks:
    dmz:
        external: true
```

---

## Navigation

- Parent: [Free Open-Source Software](https://www.niklas-stephan.de/en/wiki/free-open-source-software.md)
- Previous: [Immich – Image Archive](https://www.niklas-stephan.de/en/wiki/free-open-source-software/immich-bilderarchiv.md)
- Next: [Ollama](https://www.niklas-stephan.de/en/wiki/free-open-source-software/ollama.md)
