Skip to main content

13: Matomo - Privacy‑Friendly Analytics

Matomo is a self‑hosted web analytics platform (an alternative to Google Analytics) that lets you track website visits while keeping full control of your data. For detailed usage and advanced features, please refer to the official Matomo documentation.

What is Matomo? (Simple Explanation)

Matomo shows you how people use your website: how many visitors you have, what pages they view, where they come from, and more — all without sending data to third parties.

  • Privacy‑friendly and GDPR‑compliant
  • Real‑time stats and easy dashboards
  • Full control — runs on your own server
  • Unlimited sites can be tracked

Prerequisites

Before installing Matomo, make sure you have:

  • Traefik installed (from Chapter 4) for HTTPS and domains
  • Docker running (from Chapter 3)
  • Apprise installed (from Chapter 5) for notifications
  • Borgmatic installed (from Chapter 6) for automated backups
  • A domain name (recommended) and email for SSL certificates

Interdependencies: Matomo uses a MariaDB database. Database backups are handled by Borgmatic (Chapter 6). Borgmatic notifications rely on Apprise (Chapter 5).

Step 1: Start Infinity Tools

Connect to your server via SSH and start Infinity Tools:

sudo infinity-tools

Open Applications

  1. Go to 📱 APPLICATIONS
  2. Select Matomo
  3. Choose Install Matomo

Step 2: Choose HTTPS Mode

When prompted:

Use Traefik for SSL? (Y/n)
  • Y (recommended): Uses your domain and automatic SSL via Traefik
  • N: Standalone mode using a direct port (HTTP or self‑signed HTTPS)

Step 3: Enter Your Domain (Traefik Mode)

Examples:

  • analytics.yourdomain.com
  • stats.yourdomain.com

No domain? The installer will ask you to pick a port for local access.

Step 4: Wait for Installation

First‑time setup takes a few minutes. Matomo and its database will be created and started.

Step 5: Open Matomo and Complete the Wizard

  • Traefik mode: Visit https://your-domain
  • Standalone mode: Visit the IP and port shown by the installer (e.g., http://SERVER_IP:PORT or https://SERVER_IP:PORT)

Follow the Matomo setup wizard:

  1. System check → Next
  2. Database setup → The installer shows your database credentials
  3. Create your admin account
  4. Add your first website to track
  5. Copy the tracking code (you’ll paste it into your website later)

Step 6: Verify It’s Running

In Infinity Tools, go to 📊 STATUS & HEALTH → STATUS. You should see Matomo and its database running.

  • Add the tracking code to your website (before </head>)
  • Set up the Matomo cron for reports and archiving (see below)
  • Confirm backups include Matomo’s database
  • Review privacy settings (IP anonymization, Do Not Track)

Cron for Archiving (Recommended)

Add this to your server’s crontab to keep reports up‑to‑date:

*/5 * * * * docker exec matomo /usr/local/bin/php /var/www/html/console core:archive >/dev/null 2>&1

Troubleshooting

Can’t access the site

  • Check Traefik is running: docker ps | grep traefik
  • Verify your domain points to your server (DNS)
  • Wait a few minutes for SSL certificates
  • View logs: docker logs matomo

Database connection error

  • Check database container: docker ps | grep matomo-db
  • Use the database credentials shown during installation
  • Restart: cd /opt/speedbits/matomo && docker compose restart

Quick Reference

Check containers:

docker ps | grep -E "matomo|matomo-db"

View logs:

docker logs matomo

Restart services:

cd /opt/speedbits/matomo && docker compose restart

Helpful Resources