Featured image of post Say Goodbye to Google Analytics: Self-Host Umami for Privacy-First, Zero-Cost Web Analytics

Say Goodbye to Google Analytics: Self-Host Umami for Privacy-First, Zero-Cost Web Analytics

Google Analytics is bloated, privacy-hostile, and often blocked by ad blockers. Umami is a lightweight, open-source, self-hosted alternative that deploys in 5 minutes on your VPS — your data stays yours, your visitors stay private, and your budget stays at zero.

Why Say Goodbye to Google Analytics?

Let’s face a hard truth: Google Analytics is no longer the simple traffic tool it used to be.

GA4’s redesign has frustrated countless site owners — complex UI, steep learning curve, heavy data sampling. And it gets worse:

ProblemImpact
Privacy compliance risksGDPR/CCPA require user consent; GA’s data processing is under scrutiny by European regulators
Page performanceGA script ~45KB, delays load by ~200ms, hurts Core Web Vitals scores
Ad blocker interferenceuBlock Origin and others block GA by default — you’re seeing inflated losses in your data
Data ownershipYour data lives on Google’s servers, and you can never truly own it
CostFree tier limits data retention (2/14 months); GA360 starts at $150,000/year

Umami solves all of this. It’s an open-source, self-hosted, lightweight analytics tool that runs on your own VPS — your data, your terms.

Umami vs Google Analytics

FeatureUmamiGoogle Analytics
DeploymentDocker one-linerSaaS-hosted
Script size~2KB (tiny)~45KB
Privacy complianceGDPR-ready out of the box (no cookie banner needed)Requires cookie consent popup
Data ownershipYour own databaseGoogle’s servers
Ad blocker bypassRarely blockedBlocked by default
CostZero (just your VPS)Free tier limited / pricey enterprise plans
UIClean, intuitiveComplex, bloated

One-Click Deploy with Docker Compose

Prerequisites

  • A VPS (minimum 1 core 512MB, 1GB recommended)
  • Docker and Docker Compose installed
  • A domain name (optional but recommended for HTTPS)

1. Create the project directory

mkdir -p ~/umami && cd ~/umami

2. Create docker-compose.yml

version: "3.8"

services:
  umami:
    image: ghcr.io/umami-software/umami:latest
    container_name: umami
    ports:
      - "3000:3000"
    environment:
      DATABASE_URL: postgresql://umami:umami@db:5432/umami
      DATABASE_TYPE: postgresql
      APP_SECRET: $(openssl rand -hex 32)
    depends_on:
      - db
    restart: unless-stopped

  db:
    image: postgres:16-alpine
    container_name: umami-db
    environment:
      POSTGRES_USER: umami
      POSTGRES_PASSWORD: umami
      POSTGRES_DB: umami
    volumes:
      - ./data:/var/lib/postgresql/data
    restart: unless-stopped

⚠️ Security note: Change POSTGRES_PASSWORD to a strong password in production, and set APP_SECRET to a random string.

3. Launch the service

docker compose up -d

Visit http://YOUR_VPS_IP:3000. Default login: admin / umami.

4. Set up a reverse proxy (Caddy + HTTPS)

Caddy automatically provisions TLS certificates:

# Create a Caddyfile
cat > Caddyfile << 'EOF'
analytics.yourdomain.com {
    reverse_proxy 127.0.0.1:3000
}
EOF

# Start Caddy
docker run -d \
  --name caddy \
  -p 80:80 -p 443:443 \
  -v $PWD/Caddyfile:/etc/caddy/Caddyfile \
  -v caddy_data:/data \
  caddy:latest

Getting Started

1. Add a website

Log into the Umami dashboard, click “Add Website,” and enter your domain (e.g., selfvps.net).

2. Get the tracking code

Umami generates a tracking snippet:

<script defer src="https://analytics.yourdomain.com/script.js" data-website-id="YOUR_SITE_ID"></script>

Paste it just before </head> or </body> on your site. Done.

3. Compare with GA4

GA4 tracking code:

<!-- Google tag (gtag.js) -->
<script async src="https://www.googletagmanager.com/gtag/js?id=G-XXXXXXXXXX"></script>
<script>
  window.dataLayer = window.dataLayer || [];
  function gtag(){dataLayer.push(arguments);}
  gtag('js', new Date());
  gtag('config', 'G-XXXXXXXXXX');
</script>

Umami tracking code:

<script defer src="https://analytics.yourdomain.com/script.js" data-website-id="xxx"></script>

One line. No extra config. ~2KB script size. Zero performance impact.

Core Features

Dashboard Overview

Umami’s dashboard gives you clear, instant insights:

  • Active visitors: Who’s online right now
  • Pageviews: PV over time
  • Unique visitors: De-duplicated UV counts
  • Referrers: Traffic sources — search engines, social media, direct
  • Top pages: Most visited pages
  • Devices: Desktop vs mobile breakdown
  • Browsers & OS: User environment distribution

Event Tracking

Beyond basic page stats, Umami supports custom event tracking:

<!-- Track button clicks -->
<button onclick="umami.track('download_pdf', {file: 'guide.pdf'})">Download Guide</button>

<!-- Track form submissions -->
<script>
  document.getElementById('signup-form').addEventListener('submit', function() {
    umami.track('signup_complete', {plan: 'premium'});
  });
</script>

Data Filtering & Comparison

Filter data by:

  • Time range (today, yesterday, last 7/30 days, custom)
  • Referrer / source
  • Country / region
  • Browser
  • Operating system
  • Device type

Team Collaboration

Invite team members to view data — each person gets their own account with admin or viewer permissions.

Advanced Configuration

Using MySQL Instead of PostgreSQL

services:
  umami:
    image: ghcr.io/umami-software/umami:latest
    environment:
      DATABASE_URL: mysql://umami:umami@db:3306/umami
      DATABASE_TYPE: mysql

  db:
    image: mysql:8
    environment:
      MYSQL_ROOT_PASSWORD: rootpass
      MYSQL_DATABASE: umami
      MYSQL_USER: umami
      MYSQL_PASSWORD: umami
    volumes:
      - ./mysql-data:/var/lib/mysql

Data Export

Umami supports CSV/JSON export via its API:

curl -X GET "https://analytics.yourdomain.com/api/websites/SITE_ID/stats" \
  -H "x-umami-api-key: YOUR_API_KEY"

Generate your API Key in Umami’s “Settings → API” section.

Self-Hosted CDN for Tracking Script

For even faster loading, proxy the script through Nginx:

location /script.js {
    proxy_pass http://127.0.0.1:3000;
    proxy_set_header Host $host;
    proxy_set_header X-Real-IP $remote_addr;
}

Or pair with Cloudflare for global CDN caching.

Migrating from Google Analytics

Umami cannot import historical data from GA — and that’s intentional. Umami is designed to be lightweight and real-time. It doesn’t encourage hoarding vast amounts of historical data.

Here’s a practical migration plan:

  1. Keep GA running for historical data — treat it as an archive
  2. Start fresh with Umami as your primary tool
  3. After 3 months: Umami has enough data to be useful
  4. After 6 months: You can likely turn off GA entirely

Run both tracking codes simultaneously during the transition (no conflicts). Remove the GA snippet once Umami has accumulated enough data.

Cost Breakdown

ItemCost
VPS (Hetzner CX21, 1 core 2GB)€2.99/month
Umami softwareFree & open-source
PostgreSQLRuns in Docker, zero extra cost
Domain (optional)~$10/year
Total~€3/month

Compare this to Google Analytics 360 starting at $150,000/year, or even simpler alternatives like Plausible (€9/month for cloud). Self-hosted Umami is practically free.

Real-World Performance Comparison

Tested on a typical blog site:

MetricGA4UmamiDifference
Script size~45KB~2KB95% smaller
Load time~200ms~8ms25x faster
Lighthouse impact-8 to -15 points-1 to -2 pointsNearly zero
Ad blocker block rate~40%< 5%More accurate data

FAQ

Umami vs Plausible — which one?

ComparisonUmamiPlausible
Open source✅ Fully✅ Fully
Self-hosted✅ Free✅ Free
Cloud tier❌ No official cloud✅ €9/month+
UI languagesMulti-language (including Chinese)English only
Event tracking✅ Supported✅ Supported
Real-time data✅ Yes❌ Dashboard only
Setup complexityMedium (needs PostgreSQL)Low (single binary)

Pick Umami if you want richer real-time data, multi-language support, and don’t mind a slightly more involved setup. Pick Plausible if you want a “drop-in” single binary deployment.

No. Umami does not use cookies and does not track personally identifiable information. It falls under the “no consent required” category for GDPR compliance — one of its biggest advantages.

Can Umami handle high traffic?

A 1-core 2GB VPS running Umami + PostgreSQL can easily handle millions of pageviews per month. The bottleneck is usually the database, not Umami itself.

Summary

Umami is a genuine Google Analytics replacement — it solves the biggest pain points: privacy compliance, performance overhead, data ownership, and ad blocker interference.

ActionTime
Deploy Umami (Docker Compose)5 minutes
Add a site & get the tracking code2 minutes
Embed on your website1 minute
Dual-run transition period1-3 months
Fully retire GAOptional

If you already have a VPS (even a €2.99/month entry-level one), deploying Umami is one of the highest-value self-hosting projects you can do. Your data stays yours, your costs stay near zero, your visitors stay private, and your site stays fast.

Resources

📺 看视频版教程 → DuckDB Lab YouTube

Subscribe for more DuckDB & AI automation tutorials