Software & Configuration

Plausible Analytics

Self-hosted privacy-friendly web analytics with Plausible, Docker installation, site setup and tracking script

Plausible is a privacy-centric alternative to Google Analytics that collects aggregated data without identifying individual users. It's GDPR and PECR compliant, requiring no cookie consent banner, making it ideal for European sites and privacy-conscious deployments.


Requirements

  • Docker and Docker Compose installed
  • Minimum 1GB RAM (2GB recommended for production)
  • Domain name with DNS configured
  • Port 80 and 443 accessible

Installation

1. Clone Plausible Community Edition

git clone https://github.com/plausible/community-edition.git
cd community-edition

2. Configure Environment

Create plausible-conf.env with the following variables:

# Generate a secure secret key
openssl rand -base64 64

# Update plausible-conf.env
ADMIN_USER_EMAIL=admin@yourdomain.com
ADMIN_USER_NAME=Admin
ADMIN_USER_PWD=change_me_to_secure_password
BASE_URL=https://analytics.yourdomain.com
SECRET_KEY_BASE=your_generated_secret_key_from_above
DISABLE_REGISTRATION=true
DISABLE_CRON=false

Store the generated SECRET_KEY_BASE safely. Keep DISABLE_REGISTRATION=true to prevent unauthorized account creation.

3. Deploy with Docker Compose

docker compose up -d

The service will be available on port 8000 internally. Proceed to Nginx reverse proxy configuration.


Nginx Reverse Proxy

Configure Nginx to expose Plausible on your domain with SSL:

# Create configuration file
nano /etc/nginx/sites-available/plausible

server {
    listen 80;
    server_name analytics.yourdomain.com;
    return 301 https://$server_name$request_uri;
}

server {
    listen 443 ssl http2;
    server_name analytics.yourdomain.com;

    ssl_certificate /etc/letsencrypt/live/analytics.yourdomain.com/fullchain.pem;
    ssl_certificate_key /etc/letsencrypt/live/analytics.yourdomain.com/privkey.pem;

    location / {
        proxy_pass http://localhost:8000;
        proxy_set_header Host $host;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header X-Forwarded-Proto $scheme;
    }
}

Enable and test:

ln -s /etc/nginx/sites-available/plausible /etc/nginx/sites-enabled/
nginx -t
systemctl reload nginx

Obtain SSL certificate:

certbot certonly --standalone -d analytics.yourdomain.com

Initial Configuration

Access your Plausible instance:

  1. Visit https://analytics.yourdomain.com
  2. Log in with the admin credentials from plausible-conf.env
  3. Add a new site from the dashboard
  4. Copy your tracking script snippet

Add Tracking to Your Website

After creating a site, you'll receive a tracking script. Add it to the <head> section of your HTML:

<script defer data-domain="yoursite.com" src="https://analytics.yourdomain.com/js/script.js"></script>

Replace yoursite.com with your actual domain and analytics.yourdomain.com with your Plausible instance URL.


Custom Events and Goals

Track specific user actions (form submissions, signups, purchases):

// JavaScript event tracking
window.plausible('FormSubmitted', {
    props: {
        plan: 'premium'
    }
});

Define goals in Plausible dashboard under site settings to aggregate these events.


Updates

Plausible releases updates regularly. Update your deployment:

cd community-edition
git pull
docker compose pull
docker compose up -d

Check the changelog before updating for breaking changes.


Data Privacy

Plausible collects only aggregated data without identifying individual users. No cookies are set, and data cannot be tied to specific persons. This makes it GDPR and PECR compliant without requiring cookie consent.


Backup

Your Plausible data is stored in PostgreSQL. Back up the database regularly:

docker compose exec plausible pg_dump -U postgres plausible > backup_$(date +%Y%m%d).sql

Store backups securely alongside your application data.

On this page