Matomo Web Analytics
Privacy-focused Google Analytics alternative for web analytics.
Overview
Matomo (formerly Piwik) is an open-source web analytics platform that serves as a privacy-focused alternative to Google Analytics. Originally launched in 2007, Matomo has become the leading self-hosted analytics solution, offering complete data ownership and GDPR compliance while providing comprehensive visitor tracking, conversion analysis, and behavioral insights. Unlike cloud-based analytics services, Matomo gives organizations full control over their data collection and storage.
This stack combines Matomo with MariaDB to create a robust analytics infrastructure that processes visitor data efficiently while maintaining data sovereignty. MariaDB's enhanced MySQL compatibility ensures optimal performance for Matomo's data-intensive operations, while its Aria storage engine provides better crash recovery for analytics data. The combination leverages MariaDB's improved thread pool handling to manage concurrent visitor tracking requests and complex report generation queries simultaneously.
This configuration is ideal for organizations requiring GDPR compliance, companies seeking independence from third-party analytics providers, and businesses needing detailed visitor insights without data sharing restrictions. Privacy-conscious websites, European organizations under strict data protection laws, and enterprises managing sensitive customer data will find this self-hosted analytics solution particularly valuable for maintaining complete control over visitor information.
Key Features
- Real-time visitor tracking with heatmaps, session recordings, and conversion funnel analysis
- GDPR-compliant data collection with built-in privacy controls and cookie consent management
- Google Analytics data import wizard for migrating historical analytics data
- Custom dimension tracking for e-commerce goals, form submissions, and event monitoring
- MariaDB's Aria storage engine optimized for analytics workloads with better crash recovery
- Multi-site analytics management from a single Matomo installation
- Advanced segmentation and custom reporting with scheduled email delivery
- Plugin ecosystem supporting A/B testing, cohort analysis, and marketing attribution
Common Use Cases
- 1E-commerce websites tracking conversion funnels and customer behavior analytics
- 2European businesses requiring GDPR-compliant visitor analytics without third-party data sharing
- 3Marketing agencies managing analytics for multiple client websites from one dashboard
- 4Content publishers analyzing article performance and reader engagement metrics
- 5SaaS companies tracking user onboarding flows and feature adoption rates
- 6Educational institutions monitoring course completion and student portal usage
- 7Healthcare organizations needing HIPAA-compliant website analytics with data residency
Prerequisites
- Minimum 1GB RAM for MariaDB operations and Matomo report generation
- Port 8080 available for Matomo web interface access
- Environment variables DB_PASSWORD and DB_ROOT_PASSWORD configured in .env file
- Understanding of JavaScript tracking code implementation for website integration
- Basic knowledge of analytics concepts like goals, conversions, and custom dimensions
For development & testing. Review security settings, change default credentials, and test thoroughly before production use. See Terms
docker-compose.yml
docker-compose.yml
1services: 2 matomo: 3 image: matomo:latest4 container_name: matomo5 environment: 6 - MATOMO_DATABASE_HOST=db7 - MATOMO_DATABASE_ADAPTER=mysql8 - MATOMO_DATABASE_TABLES_PREFIX=matomo_9 - MATOMO_DATABASE_USERNAME=matomo10 - MATOMO_DATABASE_PASSWORD=${DB_PASSWORD}11 - MATOMO_DATABASE_DBNAME=matomo12 volumes: 13 - matomo-data:/var/www/html14 ports: 15 - "8080:80"16 depends_on: 17 - db18 networks: 19 - matomo-network20 restart: unless-stopped2122 db: 23 image: mariadb:10.1124 container_name: matomo-db25 environment: 26 - MYSQL_ROOT_PASSWORD=${DB_ROOT_PASSWORD}27 - MYSQL_DATABASE=matomo28 - MYSQL_USER=matomo29 - MYSQL_PASSWORD=${DB_PASSWORD}30 volumes: 31 - mariadb-data:/var/lib/mysql32 networks: 33 - matomo-network34 restart: unless-stopped3536volumes: 37 matomo-data: 38 mariadb-data: 3940networks: 41 matomo-network: 42 driver: bridge.env Template
.env
1# Matomo Analytics2DB_PASSWORD=secure_matomo_password3DB_ROOT_PASSWORD=secure_root_passwordUsage Notes
- 1Web UI at http://localhost:8080
- 2Complete installation wizard
- 3Add tracking code to websites
- 4GDPR compliant analytics
- 5Importers for Google Analytics
Individual Services(2 services)
Copy individual services to mix and match with your existing compose files.
matomo
matomo:
image: matomo:latest
container_name: matomo
environment:
- MATOMO_DATABASE_HOST=db
- MATOMO_DATABASE_ADAPTER=mysql
- MATOMO_DATABASE_TABLES_PREFIX=matomo_
- MATOMO_DATABASE_USERNAME=matomo
- MATOMO_DATABASE_PASSWORD=${DB_PASSWORD}
- MATOMO_DATABASE_DBNAME=matomo
volumes:
- matomo-data:/var/www/html
ports:
- "8080:80"
depends_on:
- db
networks:
- matomo-network
restart: unless-stopped
db
db:
image: mariadb:10.11
container_name: matomo-db
environment:
- MYSQL_ROOT_PASSWORD=${DB_ROOT_PASSWORD}
- MYSQL_DATABASE=matomo
- MYSQL_USER=matomo
- MYSQL_PASSWORD=${DB_PASSWORD}
volumes:
- mariadb-data:/var/lib/mysql
networks:
- matomo-network
restart: unless-stopped
Quick Start
terminal
1# 1. Create the compose file2cat > docker-compose.yml << 'EOF'3services:4 matomo:5 image: matomo:latest6 container_name: matomo7 environment:8 - MATOMO_DATABASE_HOST=db9 - MATOMO_DATABASE_ADAPTER=mysql10 - MATOMO_DATABASE_TABLES_PREFIX=matomo_11 - MATOMO_DATABASE_USERNAME=matomo12 - MATOMO_DATABASE_PASSWORD=${DB_PASSWORD}13 - MATOMO_DATABASE_DBNAME=matomo14 volumes:15 - matomo-data:/var/www/html16 ports:17 - "8080:80"18 depends_on:19 - db20 networks:21 - matomo-network22 restart: unless-stopped2324 db:25 image: mariadb:10.1126 container_name: matomo-db27 environment:28 - MYSQL_ROOT_PASSWORD=${DB_ROOT_PASSWORD}29 - MYSQL_DATABASE=matomo30 - MYSQL_USER=matomo31 - MYSQL_PASSWORD=${DB_PASSWORD}32 volumes:33 - mariadb-data:/var/lib/mysql34 networks:35 - matomo-network36 restart: unless-stopped3738volumes:39 matomo-data:40 mariadb-data:4142networks:43 matomo-network:44 driver: bridge45EOF4647# 2. Create the .env file48cat > .env << 'EOF'49# Matomo Analytics50DB_PASSWORD=secure_matomo_password51DB_ROOT_PASSWORD=secure_root_password52EOF5354# 3. Start the services55docker compose up -d5657# 4. View logs58docker compose logs -fOne-Liner
Run this command to download and set up the recipe in one step:
terminal
1curl -fsSL https://docker.recipes/api/recipes/matomo-analytics/run | bashTroubleshooting
- Matomo shows database connection error: Verify MariaDB container is running and DB_PASSWORD matches in both services
- Installation wizard fails at database step: Check that MATOMO_DATABASE_HOST points to 'db' service name
- Tracking code not recording visits: Ensure JavaScript tracking code is properly embedded before closing </head> tag
- MariaDB container crashes during startup: Increase Docker memory allocation to minimum 1GB for stable operation
- Reports loading slowly or timing out: Optimize MariaDB performance by increasing innodb_buffer_pool_size in database configuration
- Archive processing fails with memory errors: Add PHP memory limit environment variable MATOMO_GENERAL_MEMORY_LIMIT_WHEN_ARCHIVING=2048M
Community Notes
Loading...
Loading notes...
Download Recipe Kit
Get all files in a ready-to-deploy package
Includes docker-compose.yml, .env template, README, and license
Components
matomomariadb
Tags
#analytics#matomo#privacy#web-analytics#ga-alternative
Category
Monitoring & ObservabilityAd Space
Shortcuts: C CopyF FavoriteD Download