Skip to main content

Business tech · Beginner · 14 min

Add privacy-friendly analytics to a site with Plausible

By Padding · Updated 18 Nov 2026
Ubuntu 26.04 · Docker Compose 5 · Plausible Community Edition v3.2.2 · Plausible Analytics (hosted), November 2026

You will add Plausible to a small business site, hosted by Plausible or self-hosted with Community Edition v3.2.2, and see your first page views and a contact form goal on the dashboard.

On this page

Ember Studio, a fictional seven-person design agency with staff in Lagos and Nairobi and clients in the UK, wants to know three things about its website: which pages people read, where they come from, and how many of them send an enquiry through the contact form. It does not want to put a cookie banner in front of every visitor, or hand visitor data to an advertising company to get those answers.

Plausible Analytics fits that brief. It counts page views and events without cookies and without storing IP addresses, and shows the results on a single dashboard page. You can use it in two ways: pay Plausible to host it for you (Plausible Cloud), or run the free, open source Community Edition on your own server with Docker Compose. This tutorial covers both. The self-hosting steps pin Community Edition v3.2.2, the current release.

By the end you will have the Plausible snippet on your pages, goals for contact form submissions and clicks on outbound links, and a dashboard showing your own test visit and one recorded goal.

Step 1 · Know what Plausible records

Before you add any analytics, be clear about what it collects, because your privacy notice has to say so. Plausible's data policy (plausible.io/data-policy) lists it:

  • The page URL (hostname and path; query strings are dropped apart from campaign tags such as utm_source).
  • The referrer, so you see that a visit came from LinkedIn or a newsletter.
  • Browser, operating system and device type, worked out from the User-Agent and kept only as a major and minor version.
  • Country, region and city, worked out from the IP address. The IP address itself is not stored.
  • Scroll depth and time engaged on the page, plus any events and goals you set up.

To count unique visitors without a cookie, Plausible combines a salt, your site's domain, the visitor's IP address and User-Agent into a one-way hash. The salt is deleted every 24 hours, so the same person on two different days counts as two visitors, and nobody can be followed across days, devices or other websites. The script writes nothing to the visitor's browser.

Two consequences are worth knowing before you read your numbers:

  • Many mobile networks share one public IP address between lots of customers. Two visitors on the same network, with the same phone model and browser version, can produce the same hash on the same day and be counted as one visitor. On a site where most traffic comes from mobile data, as is common in Nigeria and Kenya, treat the unique visitor count as a floor and lean on page views and goal counts.
  • Plausible's view is that, because it uses no cookies and stores no personal data, you do not need a cookie banner or consent for it under the GDPR, the CCPA or the UK's PECR. That is the vendor's position, not legal advice. Name Plausible in your privacy notice either way, and check your own country's data protection law, such as Nigeria's NDPA 2023 or Kenya's Data Protection Act 2019.

Check it worked

Open your privacy notice (or your draft of one, see /tutorials/write-a-privacy-notice-for-a-small-business-website) and add a short analytics paragraph. Ember Studio's reads: "We use Plausible Analytics to count visits. It sets no cookies and does not store your IP address. We see totals such as page views, referring sites, country and device type." You have a saved paragraph that names Plausible and lists those data points.

Step 2 · Choose hosted or self-hosted

Both options give you the same dashboard and the same snippet format. The difference is who runs the server.

  • Plausible Cloud. Sign up at plausible.io and add your site. Plausible runs the servers in the EU, updates them and keeps the data. There is a free trial, then a monthly subscription priced by page views; check the current price on plausible.io before you commit. Goals such as form submissions and outbound link clicks count towards your monthly page view allowance.
  • Community Edition (CE). Free software under the AGPL-3.0 licence that you run on your own server. You pay only for the server, but you do the updates and backups yourself. It runs three containers: Plausible itself, PostgreSQL for accounts and settings, and ClickHouse for the visit data.

If you choose Cloud, sign up, then skip ahead to the step "Add your site and the snippet".

For Community Edition, check the server first. ClickHouse needs a processor with SSE 4.2 (Intel and AMD) or NEON (ARM), and the project recommends at least 2 GB of memory:

Bash
grep -m1 -o -w -E 'sse4_2|asimd' /proc/cpuinfo
free -h

Check it worked

You have written your choice and the reason into your project notes, for example "Self-hosted CE on the existing 4 GB server; we already run Docker and back it up nightly." If you chose CE, the first command printed sse4_2 or asimd (the Linux name for NEON) and the Mem: line of free -h shows a total of about 2 GB or more. If the first command prints nothing, this server cannot run ClickHouse; use Cloud or a different server.

Step 3 · Get the Community Edition files at a pinned version

The Community Edition repository on GitHub keeps one branch per release. Cloning the v3.2.2 branch gets you a compose.yml that pins the matching image, ghcr.io/plausible/community-edition:v3.2.2, plus the small ClickHouse config files it mounts. Pinning means a later docker compose pull cannot jump you to a new major version by surprise.

Confirm Compose is installed, install Git if the server does not have it, and clone into a folder in your home directory:

Bash
docker compose version
sudo apt-get install -y git
cd ~
git clone -b v3.2.2 --single-branch https://github.com/plausible/community-edition plausible-ce
cd ~/plausible-ce

Check it worked

Bash
git branch --show-current
ls -1
grep 'image: ghcr.io/plausible' compose.yml

The first command prints v3.2.2. The listing shows clickhouse, compose.yml, LICENSE and README.md, and the last line prints image: ghcr.io/plausible/community-edition:v3.2.2. Run every command from here on in ~/plausible-ce.

Step 4 · Create the private env file

Community Edition needs two settings before it will start:

  • BASE_URL is the public address of your Plausible instance. It goes into the snippet and into every link Plausible generates, so it must be the real https:// address your subdomain will answer on.
  • SECRET_KEY_BASE signs dashboard sessions and is used to derive other secrets. It must be at least 64 bytes long. Anyone who has it can forge a login session, so it never goes into compose.yml, a chat message or Git.

Create the file empty and readable only by you first, then add the values, so the secret is never in a file other users can read. HTTP_PORT=80 and HTTPS_PORT=443 tell Plausible to listen on the standard ports and to get and renew its own Let's Encrypt certificate for the BASE_URL domain. Replace analytics.emberstudio.example with your subdomain on the first line before you run this:

Bash
PLAUSIBLE_DOMAIN=analytics.emberstudio.example # replace this with your subdomain
install -m 600 /dev/null .env
{
  echo "BASE_URL=https://$PLAUSIBLE_DOMAIN"
  echo "SECRET_KEY_BASE=$(openssl rand -base64 48)"
  echo "HTTP_PORT=80"
  echo "HTTPS_PORT=443"
} >> .env

openssl rand -base64 48 produces 48 random bytes written as 64 characters, so you never type the secret and it never lands in your shell history. The repository's .gitignore ignores every file it did not ship, so .env cannot be committed by accident.

Check it worked

Bash
stat -c '%a %n' .env
cut -d= -f1 .env

The first command prints 600 .env: only your user can read or write it. The second prints the four names, BASE_URL, SECRET_KEY_BASE, HTTP_PORT and HTTPS_PORT, without their values.

Step 5 · Publish the ports and check the configuration

The shipped compose.yml does not publish any ports, so add an override file. Compose reads compose.override.yml automatically and merges it with compose.yml, which leaves the project's own file untouched for the next upgrade:

Bash
cat > compose.override.yml <<'YAML'
services:
  plausible:
    ports:
      - 80:80
      - 443:443
YAML

Port 80 has to be reachable from the internet for Let's Encrypt to issue the certificate, and port 443 serves the dashboard and the script. If something else on the server already uses these ports, such as Nginx or Caddy for another site, keep that proxy in front instead and follow the reverse proxy page of the Community Edition wiki.

Now ask Compose to read both files, fill in the variables from .env and report any mistake, without starting anything:

Bash
docker compose config --quiet && echo "Compose files are valid"
docker compose config --services

Plain docker compose config prints the merged file with SECRET_KEY_BASE filled in, so do not paste its output anywhere.

Check it worked

The first command prints Compose files are valid. The second lists the three services: plausible_db, plausible_events_db and plausible. An error such as yaml: line 4: did not find expected key means the indentation in compose.override.yml is off; it uses two spaces per level, no tabs.

Step 6 · Start Plausible and create your account

Start the three containers in the background. The first run downloads the images, which takes a few minutes on a slow connection:

Bash
docker compose up -d

On first start Plausible creates its databases and runs its migrations, then requests the certificate. Give it a minute or two, then check:

Bash
docker compose ps
docker compose logs plausible --tail 20

docker compose ps lists plausible_db and plausible_events_db as healthy and plausible as up. If plausible keeps restarting, the log usually names the cause; a common one on a 1 GB server is ClickHouse running out of memory.

Open your BASE_URL, for example https://analytics.emberstudio.example, in a browser. A fresh instance shows a registration form. The first account becomes the owner. Fill it in straight away, so nobody else who finds the address gets there first. After that, new people can only join by invitation, which is the Community Edition default.

Check it worked

The page loads with a valid certificate (no browser warning), and after registering you land on Plausible's prompt to add your first website. Store the account password in your team's password manager, as in /tutorials/roll-out-a-password-manager-to-your-team.

Step 7 · Add your site and the snippet

In Plausible (Cloud or your own instance), add a website and enter your domain without https:// or www, for example emberstudio.example. Plausible then shows a snippet that belongs to that site only. It looks like this, with your own script name in place of pa-XXXXXXXX and, on Community Edition, your own BASE_URL in place of https://plausible.io:

HTML
<!-- Privacy-friendly analytics by Plausible -->
<script async src="https://plausible.io/js/pa-XXXXXXXX.js"></script>
<script>
  window.plausible=window.plausible||function(){(plausible.q=plausible.q||[]).push(arguments)},plausible.init=plausible.init||function(i){plausible.o=i||{}};
  plausible.init()
</script>

Copy the snippet from your own dashboard rather than from this page. If you closed that screen, find it again under the site's Settings, in the General section, under Site installation.

Paste it inside <head>, before </head>. Where depends on how the site is built:

  • Plain HTML files. Each page has its own <head>, so paste the snippet into every page you want counted, just below the <title> line. Pages without it are not counted.
  • A static site generator or a theme (Hugo, Eleventy, a WordPress theme). Add it once to the shared layout that every page uses.
  • WordPress. Plausible's official plugin is an alternative to pasting the snippet, and it leaves out your own logged-in visits.

Ember Studio's site is a handful of HTML pages. The head of its contact page now reads:

HTML
<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <title>Contact Ember Studio</title>
  <!-- Privacy-friendly analytics by Plausible -->
  <script async src="https://analytics.emberstudio.example/js/pa-XXXXXXXX.js"></script>
  <script>
    window.plausible=window.plausible||function(){(plausible.q=plausible.q||[]).push(arguments)},plausible.init=plausible.init||function(i){plausible.o=i||{}};
    plausible.init()
  </script>
</head>

The async attribute means the page does not wait for the script, so the snippet does not slow the first paint for a visitor on a weak mobile connection. Upload the changed pages to your host as usual.

Check it worked

From your laptop, fetch a live page and look for the snippet. Replace the address with one of your own pages:

Bash
curl -s https://emberstudio.example/contact.html | grep -c '/js/pa-'

It prints 1: the script tag is the only line that loads your pa- file. A 0 means the page on the server is still the old one: check that the upload went to the right folder and clear any cache your host or CDN keeps.

Step 8 · Turn on the contact form and outbound link goals

A goal is an action you want to count, not just a page someone loaded. Ember Studio wants two: enquiries sent through the contact form, and clicks on links that leave the site, such as its Behance portfolio and Instagram.

Plausible can track both without any extra code. In the site's Settings, open General, go to the Tracking area and find Default tracking. Turn on:

  • Form submissions. Plausible detects the forms on your pages and records each submission under one goal called Form: Submission. You can then filter by page to see which form it came from.
  • Outbound links. Every click on a link to a different hostname is recorded under a goal called Outbound Link: Click, with the destination URL attached.

Both are usually on already for a site added recently, so you may only need to confirm them. The change applies to the snippet you already pasted; you do not need to touch your pages again.

Two details to keep in mind:

  • A link to one of your own subdomains (from emberstudio.example to shop.emberstudio.example) is a different hostname, so it counts as outbound. Plausible's outbound link docs show how to filter those out with a transformRequest option in plausible.init.
  • On Plausible Cloud, goal events count towards your monthly page view allowance, alongside page views.

If you want to count a single button that is not a form or an outbound link, add a class such as plausible-event-name=Brief+Download to it; Plausible's custom events docs cover that.

Check it worked

Open the list of goals in the site's settings. It includes Form: Submission and Outbound Link: Click.

Step 9 · See your first page view and goal

Plausible does not record every visit you might expect while testing. It ignores visits from localhost unless you configure it otherwise, ignores browsers driven by automation tools such as Selenium or Playwright, and many ad blockers block the script. So test with an ordinary browser on a phone or a second device, with any content blocker paused for your site, against the live site.

  1. Open the Plausible dashboard for your site on your laptop. Leave it open.
  2. On your phone, open the contact page of the live site.
  3. Fill in the contact form with a test enquiry ("Test from Plausible setup, please ignore") and send it.
  4. Tap one of the outbound links, such as the Behance portfolio.

Once you have seen your test visit arrive, keep your team's own visits out of future numbers: in the site settings, block your office's IP addresses. If your connection's IP address changes often, as it does on most mobile data plans, set the plausible_ignore flag in each team browser instead. Plausible's excluding-localstorage docs show the one-line console command, and how to build a small opt-out page on your own site that sets it.

Check it worked

Within a minute the dashboard's current visitors figure shows at least one, and the pages list shows /contact.html. Scroll down to the goals list: Form: Submission and Outbound Link: Click each show 1. Click a goal to filter the whole dashboard to visits that converted. If nothing arrives, open the page on your phone's browser with developer tools if you can, or on your laptop with the console open: a message beginning Ignoring Event: names the reason, for example localStorage flag if you opted that browser out.

Next steps

Need this done for you?

Padding does this work for growing companies, from the first diagnosis to a system that keeps working.

Digital Transformation

Get new tutorials

New tutorials, about twice a month.