Matomo Analytics for PKB-theme
This guide provides detailed instructions for integrating Matomo Analytics with your PKB-theme. Matomo is a powerful, privacy-focused alternative to Google Analytics that gives you complete control over your data.
Why Choose Matomo?
Matomo (formerly Piwik) offers several advantages:
- Full data ownership: All data stays on your server
- Privacy compliance: Built-in GDPR, CCPA, and cookie law compliance tools
- Feature parity: Similar features to Google Analytics
- No data limits: Analyze unlimited websites and users
- Customizable: Extensive API and plugin system
Installation Options
Option 1: Docker Installation (Recommended)
- Create a docker-compose.yml file:
flowchart TB
subgraph subGraph0["PKB-theme Project"]
PKB["/home/gespitia/projects/PKB-theme/"]
CONFIG_TOML["config/_default/hugo.toml<br>๐ง Analytics Configuration"]
SEO_YML["data/seo.yml<br>๐ Performance Config"]
end
subgraph subGraph1["Core Docker Configuration"]
DOCKER_COMPOSE["docker-compose.yml<br>๐ณ Container Orchestration"]
DOCKER_OVERRIDE["docker-compose.override.yml<br>๐ง Development Overrides"]
ENV_FILE[".env<br>๐ Environment Variables"]
end
subgraph subGraph2["Database Configuration"]
POSTGRES_CONF["postgresql.conf<br>๐๏ธ Database Tuning"]
POSTGRES_INIT["postgres-init/01-init.sql<br>๐ Database Setup"]
end
subgraph subGraph3["Cache Configuration"]
REDIS_CONF["redis.conf<br>โก Cache Settings"]
end
subgraph subGraph4["Backup & Monitoring"]
BACKUP_SCRIPT["backup-script.sh<br>๐พ Database Backup"]
BACKUP_CLEANUP["backup-cleanup.sh<br>๐งน Cleanup Script"]
MONITOR_SCRIPT["monitor-matomo.sh<br>๐ Health Check"]
end
subgraph subGraph5["Runtime Directories (Auto-created)"]
CONFIG_DIR["config/<br>๐ Matomo Config"]
LOGS_DIR["logs/<br>๐ Application Logs"]
PLUGINS_DIR["plugins/<br>๐ Custom Plugins"]
BACKUPS_DIR["backups/<br>๐พ Database Backups"]
end
subgraph subGraph6["Existing Config Files"]
MATOMO_CONFIG["config/config.ini.php<br>โ๏ธ Matomo Settings (Auto-generated)"]
GLOBAL_CONFIG["config/global.ini.php<br>๐ Global Settings (Read-only)"]
PLUGIN_CONFIGS["plugins/*/config/<br>๐ Plugin Configurations"]
end
subgraph subGraph7["Matomo Analytics Project"]
MATOMO_ROOT["/home/gespitia/projects/matomo-analytics/"]
subGraph1
subGraph2
subGraph3
subGraph4
subGraph5
subGraph6
end
subgraph subGraph8["System Configuration (Optional)"]
NGINX_CONF["nginx-analytics.conf<br>๐ Reverse Proxy"]
SYSTEM_NGINX["/etc/nginx/sites-available/<br>๐ System Nginx Config"]
SYSTEMD_SERVICE["/etc/systemd/system/matomo-docker.service<br>๐ Auto-start Service"]
CRON_JOBS["/etc/cron.d/matomo<br>โฐ Scheduled Tasks"]
end
subgraph subGraph9["Project Structure Overview"]
subGraph0
subGraph7
subGraph8
end
PKB --> CONFIG_TOML & SEO_YML
MATOMO_ROOT --> DOCKER_COMPOSE & DOCKER_OVERRIDE & ENV_FILE & POSTGRES_CONF & POSTGRES_INIT & REDIS_CONF & BACKUP_SCRIPT & BACKUP_CLEANUP & MONITOR_SCRIPT
MATOMO_ROOT -.-> CONFIG_DIR & LOGS_DIR & PLUGINS_DIR & BACKUPS_DIR
CONFIG_DIR --> MATOMO_CONFIG & GLOBAL_CONFIG
PLUGINS_DIR --> PLUGIN_CONFIGS
NGINX_CONF -.-> SYSTEM_NGINX
ENV_FILE -.-> DOCKER_COMPOSE
POSTGRES_CONF -.-> DOCKER_COMPOSE
REDIS_CONF -.-> DOCKER_COMPOSE
BACKUP_SCRIPT -.-> DOCKER_COMPOSE & CRON_JOBS
BACKUP_CLEANUP -.-> DOCKER_COMPOSE
POSTGRES_INIT -.-> DOCKER_COMPOSE
CONFIG_TOML -.-> NGINX_CONF
NGINX_CONF -.-> SYSTEMD_SERVICE
MONITOR_SCRIPT -.-> CRON_JOBS
CONFIG_TOML:::pkb
SEO_YML:::pkb
DOCKER_COMPOSE:::coreConfig
DOCKER_OVERRIDE:::coreConfig
ENV_FILE:::coreConfig
POSTGRES_CONF:::dbConfig
POSTGRES_INIT:::dbConfig
REDIS_CONF:::cacheConfig
BACKUP_SCRIPT:::monitoring
BACKUP_CLEANUP:::monitoring
MONITOR_SCRIPT:::monitoring
CONFIG_DIR:::runtime
LOGS_DIR:::runtime
PLUGINS_DIR:::runtime
BACKUPS_DIR:::runtime
MATOMO_CONFIG:::existing
GLOBAL_CONFIG:::existing
PLUGIN_CONFIGS:::existing
NGINX_CONF:::system
SYSTEMD_SERVICE:::system
CRON_JOBS:::system
classDef coreConfig fill:#e1f5fe,stroke:#01579b,stroke-width:2px
classDef dbConfig fill:#f3e5f5,stroke:#4a148c,stroke-width:2px
classDef cacheConfig fill:#fff3e0,stroke:#e65100,stroke-width:2px
classDef monitoring fill:#e8f5e8,stroke:#1b5e20,stroke-width:2px
classDef runtime fill:#fce4ec,stroke:#880e4f,stroke-width:2px
classDef existing fill:#f3e5f5,stroke:#6a1b9a,stroke-width:2px
classDef system fill:#fff8e1,stroke:#f57f17,stroke-width:2px
classDef pkb fill:#e0f2f1,stroke:#00695c,stroke-width:2pxDiagram Internet to files
flowchart TB
Here are the suggested file locations and names for each configuration: