DEV Community

Deploy Instant
Deploy Instant

Posted on

"Your Analytics Know More About Ad Blockers Than About You: Self-Host Plausible"

If you run a small online shop, SaaS side project, or content site, there is a good chance your traffic numbers still come from Google Analytics. On paper, it feels like the default choice. In practice, it quietly breaks the exact things you care about.

First, ad blockers and privacy-focused browsers block the Google Analytics script out of the box. Depending on your audience—especially if you sell to developers, designers, or tech-savvy buyers—your dashboard may be telling you more about how many visitors turn off ad blockers than how many people actually read your landing page. Second, the tracking bundle adds real page weight and extra network requests right when a prospect is waiting for your storefront or signup form to load. Third, your visitor history sits inside someone else's account, behind an interface whose reports, data-retention defaults, and settings can change without asking you first.

And then there is the cookie-banner tax. Under EU privacy rules, dropping tracking cookies means greeting every visitor with a consent modal before they even see your headline. A chunk of visitors reject it (creating another blind spot), another chunk bounces out of annoyance, and you spend time maintaining consent tooling instead of shipping product.

Self-hosting Plausible fixes all four problems at once. You get fast, honest numbers on a server you control—and no cookie banner required.

What Plausible Is (and Why It Fits Indie Sites)

Plausible is an open-source, privacy-friendly web analytics tool with around 22k GitHub stars. Instead of trying to build cross-site user profiles or feed an ad network, it focuses strictly on the metrics small businesses and indie makers use to make decisions.

Two design choices make it work well out of the box:

  • Lightweight tracking script: The Plausible script is tiny—under 1 KB—so it does not drag down your Core Web Vitals or delay your checkout page.
  • Cookieless by design: Plausible never sets persistent cookies and never stores personal data across sessions. Daily unique visitors are counted using a salted hash of the visitor's IP address and User-Agent, and the salt rotates every 24 hours. Because there is no cross-site tracking or persistent device fingerprinting, you do not need a cookie banner just to count pageviews.

Best of all, when you self-host it, the raw clickstream stays on your own disk.

Step 1: Set Up Plausible with Docker Compose

You only need a small Linux VPS with Docker and Docker Compose installed, plus a reverse proxy (like Caddy or Nginx) to terminate HTTPS in front of port 8000.

Plausible runs as three containers working together:

  • plausible/analytics for the web app, API, and tracking script
  • postgres for user accounts, site settings, and configured goals
  • clickhouse for fast storage and querying of pageviews and events

Create a new directory for your deployment:

mkdir -p plausible && cd plausible
Enter fullscreen mode Exit fullscreen mode

Next, generate a cryptographic SECRET_KEY_BASE for session signing:

openssl rand -base64 48
Enter fullscreen mode Exit fullscreen mode

Copy the output string. Now create a plausible-conf.env file in the same directory and fill in your values (replace <your-domain> with the domain of the site you want to host analytics on, and replace the placeholders):

BASE_URL=https://analytics.<your-domain>
SECRET_KEY_BASE=<paste-your-generated-key-here>
DATABASE_URL=postgres://postgres:<choose-a-strong-db-password>@plausible_db:5432/plausible_db
CLICKHOUSE_DATABASE_URL=http://plausible_events_db:8123/plausible_events_db
Enter fullscreen mode Exit fullscreen mode

Now create compose.yml:

services:
  plausible_db:
    image: postgres:16-alpine
    restart: always
    volumes:
      - db-data:/var/lib/postgresql/data
    environment:
      - POSTGRES_USER=postgres
      - POSTGRES_PASSWORD=<same-strong-db-password>
      - POSTGRES_DB=plausible_db

  plausible_events_db:
    image: clickhouse/clickhouse-server:24-alpine
    restart: always
    volumes:
      - event-data:/var/lib/clickhouse
    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:
      - "127.0.0.1:8000:8000"
    env_file:
      - plausible-conf.env

volumes:
  db-data:
  event-data:
Enter fullscreen mode Exit fullscreen mode

Start the stack in the background:

docker compose up -d
Enter fullscreen mode Exit fullscreen mode

Point a DNS A record for analytics.<your-domain> to your server, and configure your reverse proxy to forward HTTPS traffic to http://127.0.0.1:8000. Once TLS is live, open https://analytics.<your-domain> in your browser.

First Admin Registration

On your first visit, Plausible greets you with a registration screen to create the initial admin account. Enter your name, email address, and password. After submitting, add your website domain (for example, <your-domain>) and pick your reporting timezone.

If you have not wired up outbound SMTP email yet, Plausible may pause on email verification—you can either configure SMTP right away (covered below) or temporarily mark the admin user as verified in Postgres if you are testing locally before setting up mail.

Step 2: Install the Tracking Script on Your Site

Once you add your site in the Plausible dashboard, it gives you a single <script> tag to paste inside the <head> of your HTML template or layout:

<script defer data-domain="<your-domain>" src="https://analytics.<your-domain>/js/script.js"></script>
Enter fullscreen mode Exit fullscreen mode

The defer attribute ensures the browser downloads the script without blocking HTML parsing, so your page renders just as fast as before. Deploy that one line, visit your site in a browser tab, and watch your Plausible dashboard: you should see your live visitor count tick up to 1 within seconds.

Because the script is served from your own subdomain (analytics.<your-domain>) rather than a well-known third-party ad-tech domain, far fewer blockers intercept it—meaning your numbers match reality much more closely.

What You Actually Get in the Dashboard

Plausible puts everything on a single, scannable screen instead of burying answers across nested menus:

  • Core traffic metrics: Unique visitors, total pageviews, bounce rate, and average visit duration over any date range.
  • Top pages: See which landing pages bring people in, which pages they leave from, and which blog posts or product pages hold attention.
  • Referrers: Track search engines, social links, newsletters, and UTM campaign tags (utm_source, utm_medium, utm_campaign) so you know which channels actually convert.
  • Countries (plus devices and browsers): Country, region, and city breakdowns alongside screen size, OS, and browser data—without storing personal profiles.
  • Goals and custom events: Define page-visit goals (such as reaching /thank-you or /order-confirmed) right in the UI, or trigger custom events from your frontend code whenever someone clicks a signup button or downloads a lead magnet:
plausible('Signup', { props: { plan: 'starter' } })
Enter fullscreen mode Exit fullscreen mode

You can also attach CSS classes like plausible-event-name=Newsletter+Subscribe to links or buttons when you want zero-JavaScript event tracking.

Turn On Weekly Email Reports

You do not have to remember to check a dashboard every morning to stay on top of your site. Plausible can email you weekly digests every Monday, monthly summaries, and traffic spike notifications.

Add your SMTP credentials to plausible-conf.env:

MAILER_EMAIL=analytics@<your-domain>
SMTP_HOST_ADDR=smtp.<your-mail-provider>
SMTP_HOST_PORT=587
SMTP_USER_NAME=<smtp-username>
SMTP_USER_PWD=<smtp-password>
SMTP_HOST_SSL_ENABLED=true
Enter fullscreen mode Exit fullscreen mode

Apply the updated environment variables:

docker compose up -d
Enter fullscreen mode Exit fullscreen mode

Then open Site Settings -> Email Reports in Plausible to toggle weekly and monthly digests for yourself or teammates.

Honest Notes Before You Run It in Production

Self-hosting is straightforward, but a few operational details are worth knowing upfront:

  • Bots and your own visits: Plausible filters out known crawlers and bots automatically so scraper traffic does not wreck your bounce rate. For your own visits—especially when tweaking copy or checking deploys—use Plausible's built-in visit exclusion toggle in Site Settings -> Visibility, or add your office IP to the exclusion list so you do not count yourself as twenty customers a day.
  • Backing up the data volumes: Remember that your state lives in two Docker volumes: db-data (Postgres) and event-data (ClickHouse). Backing up only Postgres saves your login and goals while losing every historical pageview. Schedule regular backups of both volumes—ideally using pg_dump for Postgres and a ClickHouse backup or stopped-container volume snapshot—before making server changes.
  • Updates: Avoid leaving plausible/analytics:latest unpinned forever in production. Pin a specific release tag in compose.yml, read the release notes for any breaking environment variable or migration changes, snapshot both data volumes, and then update cleanly with docker compose pull && docker compose up -d.

Skip the Manual Setup If You Just Want It Running

Running Docker Compose, wiring up Postgres and ClickHouse, managing TLS certificates, and maintaining volume backups takes an afternoon the first time you do it—and ongoing attention whenever updates drop. If you want the exact same self-hosted, cookieless Plausible instance without maintaining the stack by hand, you can install Plausible in about a minute from the catalog at https://deployinstant.com/apps.

Top comments (0)