
Swetrix: Cookieless, Privacy-First Open Source Web Analytics & Performance Tracking
Sovereign Web Metrics: Tracking Traffic and Performance Without Cookies
Legacy analytics platforms like Google Analytics 4 have become severe operational burdens: heavy tracking scripts that degrade Core Web Vitals, opaque data aggregation, and strict international privacy regulations requiring invasive, conversion-killing cookie consent banners. Swetrix offers a modern, fully open-source alternative designed specifically for privacy-first self-hosting.
By operating completely cookieless, Swetrix is 100% compliant with GDPR, CCPA, and PECR out of the box—eliminating the need for cookie banners entirely. Backed by the raw power of the ClickHouse columnar database, it processes millions of real-time page events with sub-second query latency.
What It Is
Swetrix is a unified web analytics and performance monitoring platform published under the AGPL-3.0 license. It unifies three core capabilities into a single lightweight dashboard: traffic acquisition and conversion metrics, Real User Monitoring (RUM) for Core Web Vitals (LCP, FID, CLS), and front-end JavaScript error tracking.
With a tracking snippet under 3 KB in size, Swetrix adds virtually zero overhead to page render times while ensuring you retain full ownership and portability of your analytics data.
Why You Have Not Heard Of It
While commercial SaaS alternatives often paywall advanced features like error logging or custom conversion funnels, Swetrix provides its entire feature set in its open-source community release. It has spread rapidly among developers who want a self-hosted engine capable of replacing both Google Analytics and basic Sentry error capture in a single clean interface.
How It Works
Swetrix utilizes a high-throughput, horizontally scalable architecture:
- Ultra-Lightweight Client Script: Measures interactions without storing persistent cookies or logging Personally Identifiable Information (PII). Session keys rotate deterministically every 24 hours, preventing cross-domain user tracking.
- Ingestion & Caching Pipeline: High-concurrency Node.js and Go microservices ingest telemetry events, validate payload schemas, and buffer writes via Redis queues.
- ClickHouse Columnar Engine: Stores immutable event records in compressed columnar formats, enabling complex multi-dimensional aggregations and custom funnel queries in milliseconds.
Running It
Deploying Swetrix on a VPS or homelab server is managed via Docker Compose:
services:
swetrix-api:
image: swetrix/api:latest
container_name: swetrix-api
restart: unless-stopped
ports:
- "4000:4000"
environment:
- CLICKHOUSE_HOST=clickhouse
- REDIS_HOST=redis
- DATABASE_URL=postgresql://swetrix:secret@postgres:5432/swetrix
depends_on:
- clickhouse
- redis
- postgres
clickhouse:
image: clickhouse/clickhouse-server:24-alpine
container_name: swetrix-clickhouse
restart: unless-stopped
volumes:
- ./clickhouse_data:/var/lib/clickhouse
redis:
image: redis:7-alpine
container_name: swetrix-redis
restart: unless-stopped
postgres:
image: postgres:16-alpine
container_name: swetrix-postgres
restart: unless-stopped
environment:
- POSTGRES_USER=swetrix
- POSTGRES_PASSWORD=secret
- POSTGRES_DB=swetrix
volumes:
- ./postgres_data:/var/lib/postgresql/data
Launch the stack:
docker compose up -d
Include the lightweight snippet in your web application’s <head>:
<script src="https://your-analytics-domain.com/swetrix.js" defer></script>
<script>
document.addEventListener('DOMContentLoaded', () => {
swetrix.init('YOUR_PROJECT_ID', { apiURL: 'https://your-analytics-domain.com/log' })
swetrix.trackViews()
})
</script>
What It Replaces
- Google Analytics 4: Eliminates GDPR compliance risks and cookie popups while providing clean, intuitive dashboards.
- Hosted Analytics SaaS (Plausible / Fathom): Provides identical privacy-respecting metrics hosted entirely on your own infrastructure.
- Standalone Front-End Error Loggers: Captures unhandled client-side runtime errors alongside traffic data without installing secondary telemetry SDKs.
Limitations
ClickHouse requires moderate memory allocations (recommended: 2–4 GB RAM minimum under sustained production load), making it best suited for dedicated VPS nodes rather than constrained micro-instances.
Who It Is For
- Privacy-focused businesses seeking absolute regulatory compliance without annoying cookie consent dialogs.
- Web developers optimizing Core Web Vitals and monitoring client-side script errors in production.
- Homelab operators and indie hackers who prioritize data ownership and minimal client overhead.
Conclusion
Swetrix demonstrates that actionable web metrics and strict user privacy are fully compatible. By combining cookieless tracking with the query performance of ClickHouse, it stands as the premier self-hosted analytics suite for modern web applications.