← All case studies Google Analytics → Matomo

Leaving Google Analytics for self-hosted Matomo after Schrems II

On 20 January 2022 a blog replaced Google Analytics with Matomo and MariaDB in Docker. The snag was container networking. The write-up mentions a GA import and does not describe running one.

Johan Driessen took Google Analytics off his blog and stood up Matomo himself. The post is dated 20 January 2022. It is his own write-up.

The blog had used GA since the beginning, because it was free and because he already knew it from client work. He had been uneasy for two reasons. He did not want to hand Google his visitors’ data. And GA had become an ecommerce product that fit a small blog badly.

The trigger was an Austrian decision, after Schrems II, that he read as saying Google Analytics was probably illegal in the EU. He keeps the “probably”. His footnote says EU and GDPR answers are usually probable.

The Google Analytics → Matomo playbook is the historical-import path. Driessen’s post is the Docker install. He points at the importer and does not show himself running it.

What he almost did instead

He considered deleting the GA script and reading server logs. For this blog, he thinks logs would have been enough. He would lose browser and screen-size detail. He also wanted a replacement for other sites, where logs would not be enough, so he looked for a real analytics tool.

Paid hosts were fine for a client. This blog makes no money, so he wanted something he could run for free, on a machine he controls. That is how he landed on Matomo. It can be self-hosted or bought as a cloud service. It has plugins. The docs include a way to import old Google Analytics data. He notes that the import exists. He does not say he imported this blog’s history.

Docker, then the database that would not answer

Matomo documents a server install. He used the official Docker image instead, and MariaDB, because Matomo needs MySQL or MariaDB.

The Matomo container could not reach a database on the host. Two containers on the same Docker network were easier. He published the commands. The password in the post is a placeholder he chose for the example.

sudo docker run -d --name mariadb --env MARIADB_ROOT_PASSWORD=somesupersecretpassword mariadb:latest
sudo docker run -d -p 8080:80 --link mariadb:db -v matomo:/var/www/html --name matomo matomo

He then inspected the MariaDB container. Its address was 172.17.0.3. He typed that address into Matomo’s setup. He also opened a shell in the MariaDB container and created a database and a user before the Matomo wizard.

He says you should add a persistent volume for MariaDB if you might reinstall. The command he printed does not mount one. The Matomo container does mount a volume at /var/www/html. The database does not.

--link is in the snippet he published in 2022. Treat the snippet as his recipe from that week, including the link flag and the raw container IP.

After that, he writes that the job was done, and the remaining work was to see whether the tracking behaved. There is no follow-up in this post. No pageview comparison, no goal list, no note about whether the GA tag was removed the same day.

What I would copy

Decide whether logs are enough before you run a second collector. He almost stopped at the web server. He stood up Matomo because other sites needed more than a log line.

Put the database in a container on the same network if the host database is the thing you cannot reach. Then give MariaDB a volume. His own aside says the printed command is missing that.

Write down the container IP only as a one-time setup value. It will change when the container is recreated. A Docker network alias is the piece his --link mariadb:db was reaching for.

If the old GA property matters, run the import on purpose and label those hits. He knew the feature was there. This write-up ends at the Docker install.

The Google Analytics → Matomo playbook covers the report import, goals, and the numbers that will not match. Driessen’s post covers the afternoon where the container could not see the database.