Why Move Away from Google Analytics?
Google Analytics 4 (GA4) often feels like trying to fly a Boeing 747 just to track a personal blog. It is notoriously complex, and the privacy implications of handing every visitor’s data to a global advertising giant are getting harder to justify. When I looked for an alternative for my projects, I had two choices: pay for a privacy-focused SaaS or host it myself.
SaaS options like Fathom or the managed version of Plausible are great, but the $9/month starter fees add up if you manage several small sites. Self-hosting Plausible via Docker is the perfect middle ground. You get the same lightweight, cookie-less tracking as the paid version, but it runs on your hardware. You own the data, control the privacy, and can finally delete those annoying GDPR consent banners since Plausible doesn’t track personal identifiers.
The Realities of Self-Hosting
Before you migrate your infrastructure, it’s worth weighing the pros and cons. I have run this setup in production for over a year. While it is incredibly stable, there are technical requirements you can’t ignore.
The Advantages
- Blazing Performance: The Plausible script is under 1KB. Compare that to Google Analytics, which is often 40x larger. This swap can instantly boost your Core Web Vitals and PageSpeed scores.
- Compliance Made Easy: Since the tool avoids cookies and doesn’t collect PII (Personally Identifiable Information), you are generally compliant with GDPR, CCPA, and PECR out of the box.
- Data Sovereignty: Your traffic patterns stay on your server. No third party is mining your audience data to build advertising profiles.
- Minimalist UI: The dashboard is a breath of fresh air. You see visitors, sources, and goals on a single page without digging through nested menus.
The Challenges
- RAM Requirements: Plausible relies on ClickHouse for data storage. While ClickHouse is lightning-fast for analytics, it is a memory hog. You’ll need at least 4GB of RAM to prevent the Linux OOM (Out of Memory) killer from crashing your database.
- Manual Maintenance: You are the sysadmin. If your server goes down at 2 AM, you lose tracking data until it’s back up. You also handle your own backups and security patches.
Recommended Hardware and Stack
For a smooth experience, I recommend a VPS or home server with at least 2 vCPUs and 4GB of RAM. If you use a Raspberry Pi 5 or an Intel NUC, ensure you use an SSD. ClickHouse performs heavy disk I/O, and a cheap SD card will fail under the pressure.
Our stack will consist of five main components:
- Docker & Docker Compose: For container orchestration.
- PostgreSQL 14: To store metadata like user accounts and site settings.
- ClickHouse: The high-performance engine for raw analytics data.
- Redis: For caching and temporary task processing.
- Nginx Proxy Manager: To handle SSL certificates and expose the dashboard securely.
Step-by-Step Installation
Setting up Plausible manually is a headache, but Docker Compose makes it manageable. Here is the configuration I use for my own deployments.
1. Prepare the Environment
Start by creating a dedicated directory. Keeping your Docker volumes organized makes backups much easier later on.
mkdir ~/plausible
cd ~/plausible
2. Configure Security Keys
Plausible needs a few secret keys to encrypt session data. Generate a random 64-character string using this command:
openssl rand -base64 48
Create a file named plausible-conf.env. Paste the following and replace the placeholders with your actual details:
[email protected]
ADMIN_USER_NAME=admin
ADMIN_USER_PWD=your_secure_password
BASE_URL=https://analytics.yourdomain.com
SECRET_KEY_BASE=your_generated_64_char_string
TOTP_VAULT_KEY=another_random_string
# Database links
DATABASE_URL=postgres://postgres:password@plausible_db:5432/plausible_db
CLICKHOUSE_DATABASE_URL=http://plausible_events_db:8123/plausible_events_db
3. Build the Docker Compose File
Create your docker-compose.yml. This file tells Docker how to link the application to the databases. Note the ulimits section for ClickHouse; this is vital for handling large datasets.
version: "3.3"
services:
plausible_db:
image: postgres:14-alpine
restart: always
volumes:
- db-data:/var/lib/postgresql/data
environment:
- POSTGRES_PASSWORD=password
- POSTGRES_DB=plausible_db
plausible_events_db:
image: clickhouse/clickhouse-server:23.3.3.52-alpine
restart: always
volumes:
- event-data:/var/lib/clickhouse
- ./clickhouse-config.xml:/etc/clickhouse-server/config.d/logging.xml:ro
- ./clickhouse-user-config.xml:/etc/clickhouse-server/users.d/logging.xml:ro
ulimits:
nofile:
soft: 262144
hard: 262144
plausible:
image: plausible/analytics:latest
restart: always
command: sh -c "sleep 10 && /entrypoint.sh db createdb && /entrypoint.sh db migrate && /entrypoint.sh run"
depends_on:
- plausible_db
- plausible_events_db
ports:
- "8000:8000"
env_file:
- plausible-conf.env
volumes:
db-data:
event-data:
4. Launch and Verify
Before starting, ensure you have the required clickhouse-config.xml files from the official Plausible repo in your folder. Then, bring the stack online:
docker-compose up -d
It usually takes about 60 seconds for the databases to initialize. You can follow the progress by tailing the logs:
docker-compose logs -f plausible
5. Setting Up the Reverse Proxy
To access your dashboard over HTTPS, use Nginx Proxy Manager or Traefik. Point analytics.yourdomain.com to your server’s IP on port 8000. Always enable “Force SSL” to keep your login credentials encrypted.
Connecting Your Website
Once you log in, add your domain to the dashboard. Plausible will give you a tiny snippet of code. It looks like this:
<script defer data-domain="yourdomain.com" src="https://analytics.yourdomain.com/js/script.js"></script>
Drop this into your site’s <head>. Unlike GA4, you don’t need to spend hours tagging events. Plausible tracks basic pageviews and referrers automatically.
Final Maintenance Tips
Monitoring disk space is your biggest priority. If your site hits 100,000 monthly visitors, those ClickHouse logs will grow quickly. I recommend setting up a cron job to back up your Postgres database weekly. By taking these steps, you’ve built a professional-grade analytics engine that respects your users and gives you total control over your data.

