Swetrix is a privacy-first, cookieless web analytics tool designed for developers and businesses seeking an alternative to Google Analytics. It provides real-time insights into pageviews, user sessions, geolocation, device types, traffic sources, and UTM campaigns—without tracking identifiers or requiring cookie banners. Built for those who value data ownership and compliance, Swetrix offers both a fully managed cloud service and a self-hostable Community Edition.
The platform is built with NestJS on the backend, using MySQL for account data and ClickHouse for high-performance analytics, with Redis for caching. The frontend uses React Router and Tailwind CSS, while the tracking script is a lightweight TypeScript module. It supports deployment via Docker and integrates with over 20 CMS and frameworks including WordPress, Next.js, Shopify, and WordPress. Users can export data via CSV or the Statistics API, and choose between cloud hosting (EU-based) or full self-hosting on their own infrastructure.
What You Get
- Cookieless Tracking - Tracks user behavior without cookies, localStorage, or fingerprinting, ensuring full GDPR compliance and eliminating the need for cookie banners.
- Real-Time Dashboard - Live visualizations of pageviews, unique visitors, bounce rate, and session duration with interactive charts powered by billboard.js.
- Custom Events & Goals - Define and track custom actions like SIGNUP, PURCHASE, or AI_CHAT_CREATED with configurable event properties and conversion goals.
- Session Analysis & User Flows - Visualize how users navigate between pages, identifying drop-off points and common journey paths across your site.
- Performance Monitoring - Measure real-user metrics including TTFB, DNS resolution, TLS handshake, and render time to detect and fix slow pages.
- Error Tracking - Automatically capture and aggregate client-side JavaScript errors with details on browser, device, page URL, and stack traces.
- UTM Campaign Tracking - Analyze traffic sources and ROI by tracking UTM parameters across marketing channels and campaigns.
- Funnels - Visualize conversion paths and identify where users drop off in multi-step processes like signups or purchases.
- Feature Flags & Experiments (Cloud) - Roll out features gradually and run A/B tests to optimize user experience and conversion rates.
- Revenue Analytics (Cloud) - Track MRR, churn, and other financial KPIs tied to user behavior and conversions.
- Ask AI (Cloud) - Query your analytics data using natural language to uncover trends and insights without writing SQL or navigating dashboards.
- Alerts & Notifications (Cloud) - Receive Slack, Telegram, or Discord alerts when key metrics cross thresholds like traffic spikes or error surges.
- Data Export & API Access - Export all analytics data to CSV or query it programmatically via the documented Statistics API.
- Built-in reCAPTCHA Alternative - Protect forms from bots using a privacy-friendly proof-of-work challenge instead of invasive CAPTCHAs.
- Self-Hosting with Docker - Deploy the full stack (NestJS API, MySQL, ClickHouse, Redis) on your own servers using provided Docker Compose files.
- Multi-Project & Team Management (Cloud) - Manage multiple websites under one organization, assign roles, and share dashboards with password protection or public links.
Common Use Cases
- Running a privacy-compliant blog - A blogger uses Swetrix to track pageviews and traffic sources without triggering GDPR cookie banners, ensuring compliance while gaining actionable insights.
- Monitoring e-commerce conversions - An online store owner tracks PURCHASE and SIGNUP events, sets up funnels to identify checkout drop-offs, and uses session analysis to improve UX.
- Optimizing a SaaS product - A startup runs A/B tests on new features using Swetrix’s experiment tool, monitors error rates across browsers, and uses AI to uncover why users churn after onboarding.
- Self-hosting analytics for compliance - A healthcare SaaS company deploys Swetrix on its own EU-based servers to ensure all user data never leaves their infrastructure, meeting strict data residency laws.
Under The Hood
Architecture
- Monolithic NestJS structure with tightly coupled modules, where controllers directly depend on services without clear abstraction boundaries
- Service layer lacks interface-based contracts and proper dependency injection, relying on hardcoded dependencies
- Data access logic is fragmented across TypeORM entities and service methods, violating separation of concerns
- Real-time features are implemented as isolated gateways with duplicated logic, not integrated with domain services
- Configuration constants are hardcoded globally, reducing flexibility and testability
- Frontend and backend are co-located without defined API contracts, creating brittle integration points
Tech Stack
- Node.js backend powered by NestJS with TypeORM for database operations and PostgreSQL as the primary store
- React frontend with TypeScript for type-safe components and state management
- Express.js used alongside NestJS for API routing and middleware
- Comprehensive testing ecosystem built on Jest with class-validator and class-transformer for data validation
- Docker-based containerization and GitHub Actions for CI/CD automation
- Client-side device detection via @ua-parser-js and custom middleware for real-time tracking
Code Quality
- Extensive test suite covering core functionality with realistic browser environment mocking
- Clear separation of concerns in test files following Arrange-Act-Assert patterns
- Robust error handling with custom error classes and defensive programming for edge cases
- Consistent naming and strong type safety enforced across the tracker library
- Strategic use of dependency injection and mocking ensures fast, deterministic tests
- Strong linting and automated testing practices with well-organized test directories and documented workflows
What Makes It Unique
- Native ClickHouse integration enables high-throughput real-time analytics without external dependencies
- Server-side Open Graph image generation using dynamic SVG templates to render project metrics directly in HTTP responses
- CLI admin tool built with Ink.js for terminal-based project management, eliminating web UI dependency
- Browser and OS icons resolved from local asset maps, reducing CDN reliance
- Zero-tracking analytics pipeline with in-memory processing and self-hosted databases, avoiding third-party cookies and user profiling
- Custom pageflow visualization that maps user journeys from session data without proprietary platform dependencies