Plausible Analytics
Lightweight, privacy-friendly Google Analytics alternative
Overview
Plausible Analytics is a lightweight, open-source web analytics platform that serves as a privacy-focused alternative to Google Analytics. Developed with GDPR, CCPA, and PECR compliance in mind, Plausible delivers essential website metrics without using cookies or collecting personal data. The platform provides a clean, intuitive dashboard that displays visitor counts, page views, traffic sources, and device information while maintaining user privacy through data anonymization and aggregation.
This stack combines Plausible with PostgreSQL and ClickHouse to create a powerful dual-database architecture optimized for both operational and analytical workloads. PostgreSQL handles user accounts, site configurations, and application metadata with its robust ACID compliance and relational integrity. ClickHouse manages the high-volume event data from website visitors, leveraging its columnar storage and real-time query capabilities to process millions of pageviews efficiently. This separation allows Plausible to maintain fast dashboard performance even with large traffic volumes.
This configuration is ideal for privacy-conscious organizations, European businesses requiring GDPR compliance, and anyone seeking full control over their analytics data. The self-hosted approach eliminates third-party data sharing while providing enterprise-grade analytics capabilities. Startups can avoid Google Analytics' data sampling limitations, while larger organizations benefit from unlimited data retention and custom reporting without per-seat licensing costs.
Key Features
- Cookie-free tracking with <1KB JavaScript snippet that doesn't impact site performance
- Real-time visitor analytics with ClickHouse-powered sub-second query responses
- PostgreSQL-backed user management supporting multiple team members and site ownership
- GDPR-compliant data collection with automatic IP anonymization and EU data residency
- Custom event tracking and goal conversion measurement without personal data collection
- ClickHouse columnar compression reducing storage requirements by 80% compared to traditional databases
- Built-in referrer spam filtering and bot detection using PostgreSQL pattern matching
- Open-source transparency allowing full audit of data collection and processing methods
Common Use Cases
- 1European businesses needing GDPR-compliant analytics without consent banners or cookie notices
- 2Privacy-focused websites wanting visitor insights without compromising user anonymity
- 3High-traffic sites requiring real-time analytics with ClickHouse's billion-row processing capabilities
- 4Organizations avoiding Google's data collection while maintaining comprehensive traffic analysis
- 5SaaS companies tracking product usage and conversion funnels with custom event goals
- 6News and content sites monitoring article performance and reader engagement patterns
- 7E-commerce platforms analyzing visitor behavior without storing personal shopping data
Prerequisites
- Minimum 4GB RAM to support ClickHouse's in-memory operations and PostgreSQL concurrency
- Docker Engine 20.10+ with docker-compose for multi-container orchestration
- Available ports 8000 (Plausible), 5432 (PostgreSQL), and 8123 (ClickHouse) or custom port mapping
- Generate secure SECRET_KEY_BASE using openssl rand -base64 64 for session encryption
- Domain name or reverse proxy setup for production BASE_URL configuration
- Understanding of basic SQL for custom ClickHouse queries and PostgreSQL user management
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 plausible: 3 image: plausible/analytics:latest4 container_name: plausible5 restart: unless-stopped6 command: sh -c "sleep 10 && /entrypoint.sh db createdb && /entrypoint.sh db migrate && /entrypoint.sh run"7 ports: 8 - "${PLAUSIBLE_PORT:-8000}:8000"9 environment: 10 - BASE_URL=${BASE_URL:-http://localhost:8000}11 - SECRET_KEY_BASE=${SECRET_KEY_BASE}12 - DATABASE_URL=postgres://postgres:${POSTGRES_PASSWORD}@plausible_db:5432/plausible_db13 - CLICKHOUSE_DATABASE_URL=http://plausible_events_db:8123/plausible_events_db14 depends_on: 15 - plausible_db16 - plausible_events_db1718 plausible_db: 19 image: postgres:16-alpine20 container_name: plausible_db21 restart: unless-stopped22 environment: 23 - POSTGRES_PASSWORD=${POSTGRES_PASSWORD}24 - POSTGRES_DB=plausible_db25 volumes: 26 - plausible_db_data:/var/lib/postgresql/data2728 plausible_events_db: 29 image: clickhouse/clickhouse-server:latest30 container_name: plausible_events_db31 restart: unless-stopped32 volumes: 33 - plausible_events_data:/var/lib/clickhouse34 ulimits: 35 nofile: 36 soft: 26214437 hard: 2621443839volumes: 40 plausible_db_data: 41 plausible_events_data: .env Template
.env
1# Plausible Configuration2PLAUSIBLE_PORT=800034# Your site URL5BASE_URL=http://localhost:800067# Secret key (generate with: openssl rand -base64 64)8SECRET_KEY_BASE=your-64-char-secret-key910# Database password11POSTGRES_PASSWORD=postgres1213# Optional: Email (for registration)14# MAILER_EMAIL=hello@plausible.local15# SMTP_HOST_ADDR=mail.example.comUsage Notes
- 1Dashboard at http://localhost:8000
- 2First visit creates admin account
- 3Add tracking script to your sites
- 4GDPR compliant - no cookies by default
- 5Lightweight ~1KB tracking script
- 6Self-hosted = you own your data
Individual Services(3 services)
Copy individual services to mix and match with your existing compose files.
plausible
plausible:
image: plausible/analytics:latest
container_name: plausible
restart: unless-stopped
command: sh -c "sleep 10 && /entrypoint.sh db createdb && /entrypoint.sh db migrate && /entrypoint.sh run"
ports:
- ${PLAUSIBLE_PORT:-8000}:8000
environment:
- BASE_URL=${BASE_URL:-http://localhost:8000}
- SECRET_KEY_BASE=${SECRET_KEY_BASE}
- DATABASE_URL=postgres://postgres:${POSTGRES_PASSWORD}@plausible_db:5432/plausible_db
- CLICKHOUSE_DATABASE_URL=http://plausible_events_db:8123/plausible_events_db
depends_on:
- plausible_db
- plausible_events_db
plausible_db
plausible_db:
image: postgres:16-alpine
container_name: plausible_db
restart: unless-stopped
environment:
- POSTGRES_PASSWORD=${POSTGRES_PASSWORD}
- POSTGRES_DB=plausible_db
volumes:
- plausible_db_data:/var/lib/postgresql/data
plausible_events_db
plausible_events_db:
image: clickhouse/clickhouse-server:latest
container_name: plausible_events_db
restart: unless-stopped
volumes:
- plausible_events_data:/var/lib/clickhouse
ulimits:
nofile:
soft: 262144
hard: 262144
Quick Start
terminal
1# 1. Create the compose file2cat > docker-compose.yml << 'EOF'3services:4 plausible:5 image: plausible/analytics:latest6 container_name: plausible7 restart: unless-stopped8 command: sh -c "sleep 10 && /entrypoint.sh db createdb && /entrypoint.sh db migrate && /entrypoint.sh run"9 ports:10 - "${PLAUSIBLE_PORT:-8000}:8000"11 environment:12 - BASE_URL=${BASE_URL:-http://localhost:8000}13 - SECRET_KEY_BASE=${SECRET_KEY_BASE}14 - DATABASE_URL=postgres://postgres:${POSTGRES_PASSWORD}@plausible_db:5432/plausible_db15 - CLICKHOUSE_DATABASE_URL=http://plausible_events_db:8123/plausible_events_db16 depends_on:17 - plausible_db18 - plausible_events_db1920 plausible_db:21 image: postgres:16-alpine22 container_name: plausible_db23 restart: unless-stopped24 environment:25 - POSTGRES_PASSWORD=${POSTGRES_PASSWORD}26 - POSTGRES_DB=plausible_db27 volumes:28 - plausible_db_data:/var/lib/postgresql/data2930 plausible_events_db:31 image: clickhouse/clickhouse-server:latest32 container_name: plausible_events_db33 restart: unless-stopped34 volumes:35 - plausible_events_data:/var/lib/clickhouse36 ulimits:37 nofile:38 soft: 26214439 hard: 2621444041volumes:42 plausible_db_data:43 plausible_events_data:44EOF4546# 2. Create the .env file47cat > .env << 'EOF'48# Plausible Configuration49PLAUSIBLE_PORT=80005051# Your site URL52BASE_URL=http://localhost:80005354# Secret key (generate with: openssl rand -base64 64)55SECRET_KEY_BASE=your-64-char-secret-key5657# Database password58POSTGRES_PASSWORD=postgres5960# Optional: Email (for registration)61# MAILER_EMAIL=hello@plausible.local62# SMTP_HOST_ADDR=mail.example.com63EOF6465# 3. Start the services66docker compose up -d6768# 4. View logs69docker 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/plausible/run | bashTroubleshooting
- ClickHouse 'Cannot allocate memory' errors: Increase Docker memory limits to 4GB+ and set ClickHouse max_memory_usage
- Plausible 'Database migration failed' on startup: Ensure PostgreSQL is fully ready before Plausible starts, increase sleep time in command
- Missing SECRET_KEY_BASE causes 'KeyError' on first access: Generate 64-character base64 key and restart all services
- ClickHouse connection refused: Verify port 8123 accessibility and check ClickHouse container logs for initialization errors
- PostgreSQL 'password authentication failed': Confirm POSTGRES_PASSWORD matches in both DATABASE_URL and PostgreSQL environment
- High memory usage from ClickHouse: Configure max_memory_usage and max_bytes_before_external_group_by in ClickHouse settings
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
plausiblepostgresclickhouse
Tags
#analytics#privacy#metrics#tracking#gdpr
Category
Monitoring & ObservabilityAd Space
Shortcuts: C CopyF FavoriteD Download