Analytics Configuration

Guide for configuring various analytics providers with PKB-theme

Analytics Configuration for PKB-theme

This document describes how to configure various self-hosted analytics options for your PKB-theme website.

Available Analytics Providers

PKB-theme supports the following privacy-focused analytics providers:

  • Matomo (formerly Piwik)
  • Plausible
  • Umami
  • Fathom Lite
  • Shynet

Configuration

Add the following to your config.toml or hugo.toml file:

[params.analytics]
  # Uncomment and configure the analytics system you want to use
  
  # Matomo Analytics
  # matomo = true
  # matomoSiteId = "1"
  # matomoURL = "https://analytics.yourdomain.com/"
  
  # Plausible Analytics
  # plausible = true
  # plausibleDomain = "yourdomain.com"
  # plausibleScriptSrc = "https://plausible.io/js/script.js"
  
  # Umami Analytics
  # umami = true
  # umamiWebsiteId = "XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX"
  # umamiScriptSrc = "https://analytics.yourdomain.com/umami.js"
  
  # Fathom Analytics
  # fathom = true
  # fathomSiteId = "ABCDEFGH"
  # fathomScriptSrc = "https://cdn.usefathom.com/script.js"
  
  # Shynet Analytics
  # shynet = true
  # shynetURL = "https://analytics.yourdomain.com"
  # shynetUUID = "XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX"

Detailed Installation Guides

For detailed installation instructions, refer to these content pages:

Matomo Analytics Setup Guide

Comprehensive guide for setting up Matomo Analytics with your PKB-theme site

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

  1. 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:2px

Diagram Internet to files

flowchart TB

Here are the suggested file locations and names for each configuration:

Self-Hosted Analytics for PKB-theme

A comprehensive guide for implementing privacy-focused, FOSS analytics in your PKB-theme site

Self-Hosted Analytics for PKB-theme

This guide helps you implement visitor analytics for your PKB-theme using privacy-respecting, FOSS (Free and Open Source Software) solutions. Unlike commercial analytics platforms that collect excessive data and track users across sites, these tools focus on essential metrics while respecting user privacy.

Analytics Solutions Comparison

SolutionTechnologiesSizePrivacy FeaturesComplexityKey AdvantagesLimitations
PlausibleElixir/PostgreSQL<1KBNo cookies, GDPR compliantEasyLightweight script, simple dashboardLimited segmentation compared to Matomo
UmamiNext.js/PostgreSQL~2KBNo cookies, GDPR compliantEasyEasy deployment options, multiple usersFewer features than Matomo
MatomoPHP/MySQL~20KBConfigurable tracking, opt-outMediumFeature-rich, similar to GARequires more resources
Fathom LiteGo/SQLite~1KBMinimal data collectionEasyExtremely lightweightLimited features
ShynetPython/Django~0KB*Can work without JSMediumWorks with JS disabledLess intuitive interface

*Shynet can use tracking pixels instead of JavaScript