
Umami Analytics Self-Hosted: Privacy-Friendly Web Stats
Every time someone opens your website with Google Analytics on it, a small piece of their visit leaves for a server you don’t control, wrapped in cookies that force you to show a consent banner most people click away in annoyance. In return you get a dashboard so complicated that many small business owners only ever look at one number: how many visitors came yesterday. There is a simpler deal available. You can count your visitors yourself, on your own server, without cookies, with a dashboard you understand in thirty seconds. That is what Umami does, and in this guide we install it from zero on a fresh VPS.
Umami is an open source project, MIT licensed, with its official site at umami.is and the code at github.com/umami-software/umami . By the end of this tutorial you will have Umami running behind HTTPS on your own subdomain, the tracking script added to your sites, custom events for the clicks that matter (sign-ups, downloads, contact forms), plus backups and updates sorted out. We go step by step and explain every piece, so you don’t need to be a seasoned sysadmin to follow along.
Why replace Google Analytics at all?
Let’s first define the thing we are replacing. A web analytics tracker is a small JavaScript file that your web pages load. When a visitor opens a page, the script sends a short message to an analytics server: which page was opened, where the visitor came from, what browser and screen size they use. The server stores these messages and turns them into charts.
Google Analytics does this very well technically, but it brings three problems for a small European business:
- Cookies and consent. GA sets cookies to recognize returning visitors. Under EU rules (the ePrivacy directive together with GDPR), non-essential cookies require prior consent, which means a cookie banner. Many visitors refuse or ignore it, so your numbers end up incomplete anyway.
- Data leaving your control. Visitor data is processed by a third party outside your infrastructure. Several European data protection authorities have questioned these transfers over the past years, and explaining them in your privacy policy is not fun.
- Weight and complexity. The Google tag is a heavy script compared to what you actually need, and GA4 is a tool built for marketing teams, not for someone who wants to know which blog post performed well this month.
How self-hosting changes the picture
When you run umami analytics self hosted on your own VPS, the visitor’s browser talks only to your server. Umami does not set cookies, does not store IP addresses and does not build cross-site profiles. To tell unique visitors apart within a day, it computes a one-way hash from a few request details combined with a salt that rotates periodically, so the same person can’t be followed across days or across sites. The result: you still get unique visitors, page views, bounce rate and visit duration, but without personal data piling up in a database.
This makes GDPR compliance much easier. It doesn’t make it automatic: you should still mention the analytics tool in your privacy policy, and if you are unsure whether you need a consent banner in your specific situation, ask your lawyer or data protection officer. But you start from a far better position, and the data physically stays on a server in Romania.
What Umami is, in plain words
Umami is a web application written in JavaScript (Next.js) that stores its data in a PostgreSQL database. It has two jobs: receive the small messages sent by the tracking script, and show you a dashboard built from them.
In the dashboard you get, for each website:
- Visitors, visits and page views, with bounce rate and average visit time.
- Pages, referrers and UTM campaigns, so you know which content works and where traffic comes from.
- Browsers, operating systems, devices and countries. The country is resolved from the IP at the moment of the visit, then the IP is thrown away.
- A realtime view of who is on the site right now.
- Custom events for button clicks, form submissions and downloads, with optional properties.
- Share links, so you can give a client a read-only public dashboard without creating an account for them.
- Multiple websites and users from one installation, which is handy for agencies and freelancers.
The tracking script itself weighs only a couple of kilobytes, so it does not slow your pages down.
How the pieces fit together
Before running commands, let’s look at what we are building. We will use Docker, a tool that runs applications in containers. A container is an isolated package that contains the application and everything it needs, so it runs the same way on any server and does not mix its files with your system. Docker Compose lets us describe several containers (here: Umami and PostgreSQL) in one text file and start them together.
A port is a numbered door on a server through which network traffic arrives: 80 for HTTP, 443 for HTTPS, 22 for SSH. Umami listens on port 3000, but we will not open that port to the internet. Instead, a reverse proxy called Caddy receives public HTTPS traffic on port 443, takes care of the TLS certificate automatically, and forwards requests to Umami internally. Finally, a volume is a storage area managed by Docker that survives container restarts and upgrades: that is where PostgreSQL keeps your statistics.
What you need
- A VPS with Debian 13 or Ubuntu 24.04, with at least 1 GB of RAM (2 GB is more comfortable) and around 10 GB of free disk space.
- A sudo user you can log in with over SSH (not root directly).
- A domain name where you can add DNS records, for example
example.com. We will use the subdomainanalytics.example.comin this guide: replace it with your own everywhere. - About 30 minutes and a website (or several) where you can edit the HTML or the theme header.
Here is the whole procedure at a glance:
Step 1: Point a subdomain at your VPS
In your domain’s DNS panel, create an A record named analytics pointing to the public IPv4 address of your VPS (you find it in the DreamServer client area). If your VPS also has IPv6, add an AAAA record too. DNS changes usually propagate within minutes, but can take up to an hour.
Check it from your own computer or from the VPS:
getent hosts analytics.example.com
The output should show your VPS IP address. If it shows nothing or a different IP, wait a bit and try again before continuing: Caddy needs a correct DNS record to obtain the TLS certificate in Step 5.
Step 2: Install Docker and the Compose plugin
First we bring the system up to date and install a few small tools we need later (curl to download, openssl to generate random secrets):
sudo apt update && sudo apt upgrade -y
sudo apt install -y ca-certificates curl openssl
Then we install Docker Engine with the official convenience script from Docker, which adds Docker’s own package repository and installs the engine together with the Compose v2 plugin:
curl -fsSL https://get.docker.com -o get-docker.sh
sudo sh get-docker.sh
sudo usermod -aG docker $USER
The last command adds your user to the docker group, so you can run Docker commands without typing sudo every time. Group changes take effect at the next login, so log out of SSH and log back in, then verify:
docker --version
docker compose version
You should see two version lines, for example Docker version 28.x and Docker Compose version v2.x. Note the command is docker compose with a space: that is the current Compose v2. The old docker-compose with a hyphen is deprecated.
Step 3: Create the Umami project
We keep everything for Umami in one folder in your home directory. Inside it we create a .env file holding two secrets: the database password and the APP_SECRET, a random string Umami uses to sign login sessions.
mkdir -p ~/umami && cd ~/umami
echo "POSTGRES_PASSWORD=$(openssl rand -hex 24)" > .env
echo "APP_SECRET=$(openssl rand -hex 32)" >> .env
chmod 600 .env
cat .env
openssl rand -hex generates random characters from 0-9 and a-f only. That is deliberate: the database password ends up inside a connection URL, and special characters like @ or / would break it. chmod 600 makes the file readable only by your user. The cat output shows two lines with long random values; you don’t need to memorize them.
Now create the Compose file:
nano compose.yaml
Paste this content, then save with Ctrl+O, Enter and exit with Ctrl+X:
services:
umami:
image: ghcr.io/umami-software/umami:postgresql-latest
container_name: umami
restart: unless-stopped
init: true
ports:
- "127.0.0.1:3000:3000"
environment:
DATABASE_URL: postgresql://umami:${POSTGRES_PASSWORD}@db:5432/umami
DATABASE_TYPE: postgresql
APP_SECRET: ${APP_SECRET}
TRACKER_SCRIPT_NAME: stats.js
DISABLE_TELEMETRY: "1"
depends_on:
db:
condition: service_healthy
healthcheck:
test: ["CMD-SHELL", "curl -fs http://localhost:3000/api/heartbeat || exit 1"]
interval: 30s
timeout: 5s
retries: 5
db:
image: postgres:16-alpine
container_name: umami-db
restart: unless-stopped
environment:
POSTGRES_DB: umami
POSTGRES_USER: umami
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD}
volumes:
- umami-db-data:/var/lib/postgresql/data
healthcheck:
test: ["CMD-SHELL", "pg_isready -U umami -d umami"]
interval: 10s
timeout: 5s
retries: 5
volumes:
umami-db-data:
What each part does:
serviceslists the two containers.umamiis the application,dbis PostgreSQL. Inside the Compose network they find each other by name, which is why the database address is simplydb:5432.ports: "127.0.0.1:3000:3000"publishes Umami only on the local loopback address. Only programs on the VPS itself (Caddy) can reach it. This matters because Docker manages its own firewall rules and a port published on all interfaces would bypassufw.${POSTGRES_PASSWORD}and${APP_SECRET}are read automatically from the.envfile in the same folder, so no secret is written incompose.yaml.TRACKER_SCRIPT_NAME: stats.jsadds a neutral name for the tracker script. Some ad blockers block files calledscript.jscoming from known analytics tools; a neutral name improves accuracy. The default name keeps working too.DISABLE_TELEMETRYstops Umami from sending anonymous usage pings to its developers.depends_onwithservice_healthymakes Umami wait until PostgreSQL is actually ready, not just started.volumescreates a named volume where PostgreSQL stores data, so it survives restarts and upgrades.
About image tags: postgresql-latest follows the newest release built for PostgreSQL, which is convenient for a first install. In production we prefer to pin an exact version tag (listed on the project’s GitHub releases page) so an update only happens when you decide. Major Umami versions can change how images are tagged, so if a tag ever stops working, compare with the docker-compose.yml in the official repository. For PostgreSQL we pin the major version 16 on purpose: jumping between PostgreSQL major versions needs a dump and restore, so never change that number casually.
Step 4: Start Umami and check it is healthy
docker compose up -d
Docker downloads the two images (a few hundred megabytes in total), creates the network and the volume, then starts the containers in the background (-d means detached). On first start Umami creates its database tables, which takes up to a minute. Check the state:
docker compose ps
After a short while both containers should show Up and (healthy). To watch Umami’s logs live, run the command below and press Ctrl+C to stop watching (the container keeps running):
docker compose logs -f umami
You should see migration messages and then a line saying the server is ready on port 3000. Finally, ask Umami directly whether it is alive:
curl -s http://127.0.0.1:3000/api/heartbeat
A tiny JSON response such as {"ok":true} means the application is working. Let’s confirm the renamed tracker script is served too:
curl -sI http://127.0.0.1:3000/stats.js | head -n 1
The first line should contain 200.
Step 5: HTTPS with Caddy and the firewall
Caddy is a web server that obtains and renews free TLS certificates from Let’s Encrypt on its own, with a configuration of three lines. It is available in the official Debian and Ubuntu repositories:
sudo apt install -y caddy
sudo nano /etc/caddy/Caddyfile
Delete everything already in the file (the default welcome page config) and replace it with:
analytics.example.com {
encode gzip zstd
reverse_proxy 127.0.0.1:3000
}
This says: for requests to analytics.example.com, compress responses and forward them to Umami on localhost port 3000. Caddy also passes the real visitor IP to Umami in the X-Forwarded-For header, which Umami uses only to detect the country before discarding it. Validate and reload:
sudo caddy validate --config /etc/caddy/Caddyfile
sudo systemctl reload caddy
validate should end with Valid configuration. Now the firewall. ufw (Uncomplicated Firewall) blocks every incoming port except those we allow. Allow SSH first, or you will lock yourself out:
sudo apt install -y ufw
sudo ufw allow OpenSSH
sudo ufw allow 80/tcp
sudo ufw allow 443/tcp
sudo ufw enable
sudo ufw status
Port 80 stays open because Let’s Encrypt uses it to verify you own the domain, and Caddy uses it to redirect visitors to HTTPS. Open https://analytics.example.com in your browser: you should see the Umami login page with a valid padlock.
Step 6: Log in, secure the account and add your first website
Umami creates a default account with username admin and password umami. Log in and change that password immediately: open your profile (in the settings area) and set a long, unique password. Anybody who knows Umami knows the default credentials, so leaving them in place is the most common and most dangerous mistake.
Next, go to Settings, Websites and click Add website. Enter a name (for example “Company site”) and the domain (example.com, without https://). After saving, open the website’s settings and find the Tracking code tab. Umami shows you a ready-to-paste snippet containing your unique website ID, a long identifier that tells Umami which site a page view belongs to.
If you manage sites for clients, you can also create extra users with view-only rights under Settings, Users, or generate a share URL that opens a public, read-only dashboard.
Adding the Umami tracking script to your sites
The snippet looks like this (your ID will differ):
<script defer src="https://analytics.example.com/stats.js" data-website-id="0c1a2b3c-4d5e-6f70-8a9b-0c1d2e3f4a5b"></script>
Place it inside the <head> section of every page. The defer attribute tells the browser to download the script without blocking page rendering, so visitors notice nothing. A few useful extra attributes you can add to the same tag:
data-domains="example.com,www.example.com"counts visits only when the page runs on those domains. This keeps your local development or staging copies out of the statistics.data-do-not-track="true"respects the Do Not Track setting of the visitor’s browser.data-auto-track="false"disables automatic page view tracking, for when you want to send everything manually from JavaScript.
Where to paste it on popular platforms
- Plain HTML sites: paste the tag in the
<head>of your template or of each page. - WordPress: use your theme’s option for header scripts, or any plugin that inserts code in the
<head>. Avoid editing theme files directly, because a theme update would erase your change. - Hugo and other static generators: add it to your head partial, ideally only in production builds:
{{ if hugo.IsProduction }}
<script defer src="https://analytics.example.com/stats.js" data-website-id="YOUR-WEBSITE-ID"></script>
{{ end }}
- Single page applications (React, Vue, Next.js): include the script once in the main HTML layout. Umami follows client-side navigation automatically, so route changes are counted as page views.
Open your site in a browser, then look at the Realtime view in Umami: your visit should appear within seconds.
Excluding your own visits
You probably don’t want your own clicks inflating the numbers. In the browser you use for your site, open the developer console (F12), go to the Console tab, and run:
localStorage.setItem('umami.disabled', 1)
Umami will now ignore visits from that browser on that domain. Repeat it for each domain and browser you use.
Tracking custom events
Page views tell you where people go. Events tell you what they do: click “Buy”, download a PDF, submit the contact form. Umami offers two ways to send them.
The no-code way: HTML attributes
Add a data-umami-event attribute to any button or link. Every click is then recorded under that event name:
<button data-umami-event="signup-click">Create account</button>
<a href="/files/price-list.pdf" data-umami-event="download-price-list">Download prices</a>
You can attach properties with extra attributes named data-umami-event- followed by the property name:
<button data-umami-event="signup-click" data-umami-event-plan="pro" data-umami-event-position="header">
Start Pro plan
</button>
In the dashboard, the Events section shows how often signup-click happened, and you can break it down by plan or position.
The JavaScript way
For things that are not simple clicks, such as a form that was submitted successfully after validation, call the tracker from your own code:
if (window.umami) {
umami.track('contact-form-sent', { source: 'footer' });
}
The if (window.umami) check prevents errors when the script did not load, for example because a visitor’s ad blocker stopped it. Without the check, a blocked tracker could break the rest of your JavaScript.
Naming advice
Choose short, lowercase names with hyphens (newsletter-subscribe, not User Subscribed To Newsletter!!), keep them consistent across your sites, and write them down in a small list. Umami limits event names to around 50 characters. Never put personal data such as email addresses or names into event properties: it would defeat the whole point of a privacy-friendly setup.
How much server does Umami need?
Umami is light. On a small site with a few thousand visits per day, the whole stack idles at a few hundred megabytes of RAM and uses almost no CPU between requests. The database grows slowly: plain page views take little space, so even years of history for a typical small business site stay well within a modest disk.
You can check the real numbers on your own VPS at any time:
docker stats --no-stream
This prints one line per container with its current CPU and memory usage. If you later track many busy sites with hundreds of thousands of daily page views, give PostgreSQL more RAM and fast storage first: the database is where the work happens.
Backups and updates
Backing up your statistics
Your data lives in the PostgreSQL volume. The safest way to back it up is a logical dump with pg_dump, which produces a portable SQL file:
mkdir -p ~/umami/backups
cd ~/umami
docker compose exec -T db pg_dump -U umami umami | gzip > ~/umami/backups/umami-$(date +%F).sql.gz
ls -lh ~/umami/backups
To run it automatically every night at 03:30 and keep 14 days of backups, open your crontab with crontab -e and add these two lines (replace youruser with your username; the % sign must be escaped as \% inside crontab):
30 3 * * * cd /home/youruser/umami && /usr/bin/docker compose exec -T db pg_dump -U umami umami | gzip > /home/youruser/umami/backups/umami-$(date +\%F).sql.gz
45 3 * * * find /home/youruser/umami/backups -name '*.sql.gz' -mtime +14 -delete
Copy the backups off the server regularly too (to another machine or object storage). A backup that lives only on the server it protects is not really a backup. To restore a dump into an empty database:
gunzip -c ~/umami/backups/umami-2026-11-10.sql.gz | docker compose exec -T db psql -U umami umami
Updating Umami
cd ~/umami
docker compose pull
docker compose up -d
docker image prune -f
pull downloads newer images, up -d recreates only the containers whose image changed, and Umami applies any database migrations on start. image prune removes old, unused images to free disk space. Take a backup before updating, and read the release notes before major version jumps.
Troubleshooting: common mistakes
- No visits appear in the dashboard. Check, in order: the
data-website-idmatches the one in Umami, the script URL opens in your browser,data-domains(if used) includes the exact domain, and you did not disable tracking for yourself with thelocalStoragetrick. Open the browser’s Network tab and look for the request tostats.jsand the follow-up request to/api/send. - Caddy shows a 502 Bad Gateway. Caddy runs, but Umami does not answer. Run
docker compose psanddocker compose logs umamiin~/umami. Often the container is still starting or the database connection failed. - No HTTPS certificate. The DNS record does not point to your VPS yet, or port 80 is blocked. Check with
getent hosts,sudo ufw status, andsudo journalctl -u caddy --no-pager -n 50. - Password authentication failed for user umami. You changed
POSTGRES_PASSWORDin.envafter the first start. PostgreSQL reads that variable only when it initializes an empty volume. Either put the original value back, or change the password inside the database withALTER USER. - Your site has a Content Security Policy and the browser console shows a blocked script. Add
https://analytics.example.comto bothscript-srcandconnect-src. - Numbers lower than Google Analytics. Some visitors block every analytics script, and Umami does not count bots. Differences of 10 to 30 percent between tools are normal. Run both side by side for a couple of weeks before switching off GA.
- Port 3000 is already in use. Another app occupies it. Change the left side of the mapping, for example
"127.0.0.1:3010:3000", and point Caddy at127.0.0.1:3010.
Security notes
- Change the default
admin/umamipassword on day one, and give each person their own account instead of sharing one. - Never publish Umami or PostgreSQL on all interfaces. Keep
127.0.0.1:in front of the port mapping and never add aports:section to thedbservice. Docker inserts its own firewall rules, soufwalone will not protect a port published as3000:3000. - Protect your secrets. The
.envfile holds the database password and theAPP_SECRET; keep it atchmod 600, out of Git repositories and out of screenshots. - Keep everything updated: the OS with
sudo apt update && sudo apt upgrade, the containers withdocker compose pull. Consider enablingunattended-upgradesfor security patches. - Harden SSH: use key-based login, disable password authentication, and keep port 22 open only if you need it from everywhere.
- Privacy is a process, not a checkbox. Don’t send personal data in event properties or page URLs (for example
?email=parameters), mention Umami in your privacy policy, and define how long you keep the statistics.
So, should you switch?
If you want honest numbers about your website, without cookie banners for analytics, without sending visitor data to a third party, and with a dashboard you understand at first glance, Umami is one of the best tools available today. It installs in about half an hour, runs comfortably on a small VPS, and the custom events cover what most small businesses and developers need to measure. If you rely heavily on advertising integrations or very advanced marketing attribution, keep in mind Umami deliberately does less, and that is precisely the point.
You can run everything in this guide on a VPS from our Romanian data center, so your analytics data stays in the EU on infrastructure we operate ourselves. And if you prefer to have Umami installed, secured, backed up and kept up to date for you, our server administration team can take care of it end to end.
Frequently asked questions
Do I still need a cookie banner with Umami?
Umami itself sets no cookies and stores no IP addresses, so for the analytics part many site owners in the EU run it without a consent banner. Your site may still need one for other tools (embedded videos, chat widgets, advertising pixels). For a definitive answer for your business, check with your legal advisor.
Can one Umami installation track several websites?
Yes. Add each site under Settings, Websites; each gets its own website ID and its own dashboard. One installation comfortably handles dozens of small sites.
Can I import my old Google Analytics data?
Not directly. Export the reports you care about from Google Analytics before you close the property, keep them as files, and let Umami start collecting from the day you install it. Running both in parallel for a few weeks helps you compare.
Will ad blockers block Umami?
Some will, especially for scripts named script.js from known analytics domains. Serving the tracker from your own subdomain with a neutral name like stats.js reduces this noticeably, but no analytics tool can count a visitor who blocks all scripts, and that is their right.
Is self-hosted Umami different from Umami Cloud?
The core features are the same. Umami Cloud is the paid hosted service from the developers. Self-hosting means you run it yourself: no subscription and full control over where the data lives, in exchange for handling updates and backups, which this guide shows you how to do.