Back to articles
Technology Insight

Building a Self-Hosted 'Static Site Analytics & Privacy-First Tracking' Foundation on VPS with Umami and ClickHouse

May 26, 2026

Introduction: The Changing Landscape of Web Analytics

In the digital business landscape, data is a critical asset. However, the traditional methods of gathering web analytics are facing unprecedented challenges. Regulatory frameworks like GDPR, CCPA, and PECR have shifted the power dynamic back to the consumer, making data privacy a non-negotiable standard rather than a legal afterthought. Meanwhile, the impending depreciation of third-party cookies and the widespread adoption of ad-blockers mean that traditional tools like Google Analytics 4 (GA4) are often yielding incomplete or heavily sampled data.

For businesses operating static sites, Jamstack architectures, or corporate blogs, these challenges introduce a frustrating trade-off: comply with privacy laws by implementing disruptive cookie consent banners, or lose visibility into user behavior. Fortunately, a third path exists. By building a self-hosted, privacy-first tracking infrastructure on a Virtual Private Server (VPS) using Umami Analytics backed by a ClickHouse database, organizations can achieve 100% data ownership, compliance by design, and blazingly fast performance.

Why Choose a Self-Hosted, Privacy-First Stack?

Before diving into the technical architecture, it is important to understand why enterprise and mid-market companies are migrating away from centralized analytics SaaS providers. The motivations span compliance, performance, and data fidelity.

  • Absolute Data Ownership: When you use a third-party SaaS provider, your users' behavioral data resides on their servers. Self-hosting ensures that every pageview, referral link, and custom event remains securely within your own infrastructure boundary.
  • GDPR/CCPA Compliance without Banners: Umami does not collect any personally identifiable information (PII) and anonymizes all tracking data. It operates entirely without cookies, meaning you can legally dismantle intrusive cookie consent banners, drastically improving your landing page conversion rates.
  • Bypassing Ad-Blockers: Centralized analytics scripts (like Google Tag Manager or GA4) are routinely blocked by privacy-focused browsers (Brave, Safari) and browser extensions. Serving your tracking script from your own domain via a reverse proxy restores visibility into this lost traffic.
  • Infrastructure Performance: Static websites are built for speed. Loading heavy third-party tracking scripts degrades your Core Web Vitals. Umami’s tracking script is incredibly lightweight (under 2KB), ensuring your site remains optimized for search engines.

The Architecture: Umami and ClickHouse on a VPS

An enterprise-grade self-hosted analytics solution requires a robust backend capable of handling sudden traffic spikes without crashing or introducing query latency. While Umami supports traditional relational databases like PostgreSQL and MySQL, pairing it with ClickHouse elevates the stack to a production-ready infrastructure.

What is Umami?

Umami is an open-source, privacy-focused alternative to Google Analytics. It features a beautiful, intuitive dashboard that presents essential metrics—such as unique visitors, page views, bounce rates, geolocations, and device types—without cluttering the user interface. It also supports custom event tracking, allowing businesses to measure form submissions, button clicks, and e-commerce conversions easily.

What is ClickHouse?

ClickHouse is an open-source, high-performance columnar database management system designed explicitly for Online Analytical Processing (OLAP). Unlike traditional row-oriented databases that struggle when querying millions of log rows, ClickHouse processes data linearly by columns. This architectural choice enables it to execute complex analytical queries across billions of rows in milliseconds, utilizing fractionally less hardware resource.

Combining Umami's elegant UI with ClickHouse's raw processing power gives businesses an enterprise-scale analytics machine for the cost of a basic entry-level VPS.

Step-by-Step Deployment Blueprint

Setting up this stack involves provisioning a VPS, configuring Docker Compose for orchestration, connecting Umami to ClickHouse, and securing the traffic using a reverse proxy with SSL certifications.

Step 1: Preparing Your VPS Environment

To begin, you will need a standard Ubuntu-based VPS. For moderate traffic (up to a few million pageviews per month), a server with 2 vCPUs and 4GB of RAM is highly recommended, as ClickHouse requires sufficient memory allocations for optimal column indexing. Install Docker and the Docker Compose plugin on your system to manage the multi-container setup seamlessly.

Step 2: Configuring the Docker Compose Stack

We will orchestrate three primary components: the ClickHouse server container, the Umami application instance, and an Nginx or Caddy container to act as our reverse proxy. Create a docker-compose.yml file structuring these dependencies. Ensure that the ClickHouse container mounts a persistent volume to prevent data loss during server reboots, and define secure environmental variables for database authentication.

Step 3: Initializing ClickHouse and Umami

When running the stack for the first time, Umami automatically detects the ClickHouse dialect and runs its initialization scripts to set up the necessary database schemas. Within ClickHouse, tables are configured using the ReplacingMergeTree engine, which allows for efficient data deduplication and rapid aggregation over timestamped event records.

Step 4: Setting Up the Reverse Proxy and SSL

To ensure that the tracking data is securely transmitted and that your analytics dashboard is accessible via HTTPS, configure your reverse proxy to route a subdomain (e.g., analytics.yourcompany.com) to the internal port where Umami is running. Automatically generate Let's Encrypt certificates to encrypt all data in transit via TLS 1.3.

Integrating the Tracking Script with Your Static Site

Once your Umami instance is operational, logging into the dashboard allows you to create a new website profile. Umami generates a unique tracking script that looks similar to this:

Because you are deploying a static site (whether built with Next.js, Hugo, Astro, or Gatsby), copy this script tag directly into the component of your global layout layout. Because the script is loaded asynchronously (async) and deferred (defer), it will execute completely out-of-band, ensuring it never blocks the critical rendering path of your webpage.

Optimizing for Longevity: Maintenance and Scaling

While a self-hosted analytics platform frees you from monthly subscription bills, it does shift the operational maintenance responsibility to your internal team. To guarantee the platform runs smoothly for years to come, implement the following best practices:

  1. Automated Backups: Set up a cron job on your VPS to periodically back up the ClickHouse data directories to an external object storage bucket (such as AWS S3 or Backblaze B2).
  2. Log Rotation and Data Retention: Configure ClickHouse data retention policies to automatically drop or archive granular event data that is older than 90 or 180 days if your business only requires aggregated monthly reports for long-term historical analysis.
  3. Monitoring Server Resources: Use lightweight monitoring tools to keep track of CPU utilization, disk I/O, and memory exhaustion to anticipate when you might need to scale up your VPS resources.

Conclusion: Taking Control of Your Business Intelligence

Building a self-hosted, privacy-first tracking foundation with Umami and ClickHouse represents a major strategic upgrade for any digital business. It honors the privacy preferences of your modern customer base, completely side-steps the complexities of global privacy compliance audits, and drastically improves website performance compared to bloated legacy suites. Most importantly, it places the absolute ownership of your business intelligence exactly where it belongs: in your hands.

Building a Self-Hosted 'Static Site Analytics & Privacy-First Tracking' Foundation on VPS with Umami and ClickHouse | DPTCloud