ConfigsApr 16, 2026·3 min read

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.

TL;DR
Matomo replaces Google Analytics with a self-hosted, GDPR-compliant analytics platform you fully control.
§01

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.

§02

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.

§03

How to use

  1. 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
  1. Open http://localhost:8080 and complete the web installer. Connect your MySQL or MariaDB instance, create an admin account, and add your first website.
  1. 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.
  1. 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
§04

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:
§05

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
§06

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

How does Matomo compare to Google Analytics for privacy?+

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.

What database does Matomo require?+

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.

Can Matomo import historical data from Google Analytics?+

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.

Does Matomo support tag management?+

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.

How much server resources does Matomo need?+

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)

Discussion

Sign in to join the discussion.
No comments yet. Be the first to share your thoughts.

Related Assets