Matomo — Self-Hosted Google Analytics Alternative
Matomo is a privacy-respecting, self-hosted web analytics platform used by over 1 million websites with full data ownership and GDPR compliance.
What it is
Matomo (formerly Piwik) is an open-source web analytics platform that you host on your own infrastructure. It tracks page views, visitor flows, referrers, e-commerce conversions, and campaign attribution while keeping all data under your control. Unlike cloud analytics services, Matomo stores everything on your servers.
Matomo is built for website operators who need analytics without sending visitor data to third parties. It suits teams subject to GDPR, CCPA, or PECR regulations, as well as organizations that simply prefer data sovereignty.
How it saves time or tokens
This TokRepo workflow provides a ready-to-run Docker configuration for Matomo. Instead of reading through installation docs and configuring PHP, MySQL, and cron jobs manually, you get a single docker-run command that launches a working instance. The included cron-based archiver setup automates report pre-processing, so dashboards load instantly rather than computing on every request.
How to use
- Run the Docker container with your database credentials:
docker run -d --name matomo -p 8080:80 \
-v matomo-data:/var/www/html \
-e MATOMO_DATABASE_HOST=db \
matomo:latest
- Open
http://localhost:8080and complete the web installer. Connect your MySQL or MariaDB instance, create an admin account, and add your first website.
- Add the Matomo JavaScript tracking snippet to your site. The installer generates the snippet automatically. Paste it before
</body>on every page you want to track.
- Set up the cron archiver to pre-process reports:
*/5 * * * * /usr/bin/php /var/www/html/console core:archive \
--url=http://localhost:8080 > /dev/null 2>&1
Example
# docker-compose.yml for Matomo + MariaDB
version: '3'
services:
db:
image: mariadb:10.11
environment:
MYSQL_ROOT_PASSWORD: secret
MYSQL_DATABASE: matomo
volumes:
- db-data:/var/lib/mysql
matomo:
image: matomo:latest
ports:
- '8080:80'
environment:
MATOMO_DATABASE_HOST: db
MATOMO_DATABASE_USERNAME: root
MATOMO_DATABASE_PASSWORD: secret
MATOMO_DATABASE_DBNAME: matomo
volumes:
- matomo-data:/var/www/html
depends_on:
- db
volumes:
db-data:
matomo-data:
Related on TokRepo
- Self-hosted tools -- Browse other self-hosted platforms for AI and developer workflows
- Monitoring tools -- Explore observability and monitoring solutions that complement analytics
Common pitfalls
- Forgetting to set up the cron archiver leads to slow dashboard loads because Matomo computes reports on every page view instead of pre-processing them.
- Running Matomo on shared hosting with limited PHP memory causes archiving failures. Allocate at least 256MB for the archiver process.
- Not configuring a reverse proxy with HTTPS means tracking requests are sent in plain text, which defeats the privacy purpose.
Frequently Asked Questions
Matomo stores all data on your own server. No visitor information leaves your infrastructure. This makes it compliant with GDPR, CCPA, and PECR by default, whereas Google Analytics sends data to Google servers and requires additional consent mechanisms.
Matomo requires MySQL 8.0 or later, or MariaDB 10.4 or later. The database stores raw visit logs, archived reports, and configuration. For high-traffic sites, a dedicated database server with SSD storage is recommended.
Yes. Matomo provides a Google Analytics importer plugin that pulls historical data via the GA API. The import runs as a background job and can take hours for large datasets, but it preserves continuity when migrating.
Yes. Matomo includes a built-in Tag Manager that lets you deploy tracking scripts, conversion pixels, and custom HTML without modifying your site code. It works similarly to Google Tag Manager but runs on your own server.
For sites under 100K page views per month, a single 2-core server with 2GB RAM is sufficient. High-traffic sites benefit from separating the database and web server, increasing PHP memory to 512MB, and running the archiver more frequently.
Citations (3)
- Matomo GitHub— Matomo is the leading open-source analytics platform formerly known as Piwik
- Matomo Installation Guide— Matomo requires PHP 8.x and MySQL 8.0+ or MariaDB 10.4+
- Matomo Archiving Docs— Cron-based archiving for report pre-processing
Related on TokRepo
Discussion
Related Assets
DTM — Distributed Transaction Manager for Microservices
A cross-language distributed transaction framework supporting Saga, TCC, XA, and two-phase message patterns for reliable microservice coordination.
WatermelonDB — Reactive Database for React Native Apps
A high-performance reactive database framework for React Native and React web apps, built on top of SQLite with lazy loading and sync primitives.
Dexie.js — Minimalist IndexedDB Wrapper for the Web
A lightweight wrapper around IndexedDB that provides a clean Promise-based API for client-side storage in web applications.