Fathom Lite

A simple, self-hosted website analytics tool built with Go and Preact that lets you understand your traffic without handing data to third parties.

8Kstars
382forks
MIT License
Go

Fathom Lite is the open-source predecessor to the commercial Fathom Analytics service — a privacy-respecting alternative to Google Analytics that you can run entirely on your own infrastructure. Built with Go for the backend and Preact for the dashboard frontend, it compiles to a single binary that embeds all its assets, making deployment as simple as running one executable.

The analytics pipeline works by injecting a small JavaScript snippet into your pages. The tracker collects hostname, pathname, referrer, and new-visitor signals and pushes them to a background aggregator that batch-writes hourly site, page, and referrer statistics into a relational database. Because all data stays on your server, you retain full control and have no obligations to third-party data processors.

Fathom Lite is no longer receiving new features — the team’s development focus has shifted to the hosted Fathom Analytics product — but the project is actively maintained for security patches and bug fixes. It suits developers and small teams who want a no-frills analytics dashboard without the operational complexity of a full-featured platform.

Supported databases include SQLite (zero-config default), MySQL, and PostgreSQL. Deployment options range from a bare binary on Linux to a pre-built Docker image, and production setups can add Let’s Encrypt TLS and GZIP compression through simple command-line flags.

What You Get

  • Self-hosted analytics server - A single Go binary that embeds the full dashboard frontend and serves both the tracker endpoint and the analytics UI from one process, deployable on any Linux server or via Docker.
  • Lightweight JavaScript tracker - A minimal tracker snippet that records hostname, pathname, referrer, new-visitor status, and screen-width class without fingerprinting or invasive profiling techniques.
  • Real-time visitor dashboard - A Preact-powered dashboard showing live visitor counts, hourly and daily pageview charts, top pages, and top referrers with date-range filtering and grouping options.
  • Multi-database support - Runs against SQLite for zero-config local setups, MySQL, or PostgreSQL, switchable via environment variables without code changes.
  • Multi-site management - Register and switch between multiple tracked websites from a single Fathom Lite installation, each with its own tracking ID and isolated stats.
  • Bot and spam filtering - Respects Do Not Track headers and uses User-Agent parsing plus a community-maintained referrer spam blacklist to exclude bots, scrapers, and spam referrers from your metrics.
  • Docker deployment - Official multi-stage Dockerfile producing a slim Alpine image; a pre-built image is available on Docker Hub for one-command deployment.
  • Let’s Encrypt TLS - Built-in support for automatic TLS certificate provisioning via the --lets-encrypt flag, removing the need for a separate reverse proxy for HTTPS.

Common Use Cases

  • Personal blog or portfolio site - A developer self-hosts Fathom Lite on a $5 VPS to track which articles get the most traffic and where readers come from, without relying on Google Analytics or displaying cookie banners.
  • Agency analytics for client sites - A small web agency runs one Fathom Lite instance to monitor traffic for several client websites simultaneously, each isolated under its own tracking ID, while keeping client data off third-party servers.
  • Privacy-sensitive SaaS dashboard - A startup uses Fathom Lite to understand how users navigate their internal admin panel, keeping usage data away from advertising platforms and satisfying data-residency requirements.
  • Educational or nonprofit sites - A university department or NGO with strict data protection policies self-hosts Fathom Lite to comply with institutional IT rules while still gaining basic traffic insights.
  • Developer learning project - A Go developer studies the codebase to understand how to build a full-stack web application — REST API, session management, database migrations, embedded static assets, and a Preact frontend — in a single repository.
  • Low-traffic production monitoring - An indie maker deploys Fathom Lite alongside their side project to track launch-day traffic spikes and referral sources with minimal infrastructure overhead.

Under The Hood

Architecture Fathom Lite follows a layered but pragmatic structure: a thin CLI entry point delegates to an HTTP server, which wires together a REST API, a background pageview collector, and a periodic aggregator. The datastore.Datastore interface provides clean dependency injection between the API layer and the SQL backend, enabling the aggregator and API handlers to remain testable in isolation. The pageview collector runs as a goroutine with channel-based buffering, persisting pageviews in batches of 100 or every 1,000 milliseconds — a deliberate tradeoff that sacrifices strict durability for reduced write pressure on low-resource servers. Frontend assets are embedded into the binary at build time via Packr2, resulting in a single self-contained executable. The architecture is genuinely monolithic — there is no service mesh, queue, or micro-service boundary — which is appropriate for the project’s scope and makes the deployment story unusually simple.

Tech Stack The backend is written in Go 1.19 and uses the standard net/http package with Gorilla Mux for routing and Gorilla Sessions for cookie-based authentication. Database access goes through sqlx with sql-migrate handling schema migrations for all three supported drivers: SQLite3, MySQL, and PostgreSQL. The frontend is built on Preact 8 with D3.js 5 for charting and Pikaday for the date picker, bundled by Browserify and Gulp 4 with Babel for transpilation. The production Docker image uses a multi-stage build combining a Node.js Alpine image for asset compilation and a Go image for binary compilation, producing a final Alpine image under 30 MB. Logrus handles structured logging and goreleaser automates cross-platform binary releases.

Code Quality The codebase includes a meaningful test suite covering the aggregator’s referrer parsing, the API’s collection endpoint, authentication flows, and HTTP handler behavior — a solid foundation given the project’s size. Error handling is explicit throughout: functions return error values that callers log and propagate rather than silently swallowing. The datastore.Datastore interface is the strongest architectural quality signal, decoupling business logic from SQL implementation and making the data layer swappable. Naming is consistent and idiomatic Go. The main weakness is the legacy frontend build chain — Browserify and Gulp 4 with Preact 8 are several generations behind current practice, and no type-checking or linting is applied to the JavaScript layer. GitHub Actions CI runs Go unit tests on push, but there is no end-to-end or integration test layer.

What Makes It Unique Fathom Lite’s defining characteristic is its radical simplicity of deployment: one binary, three supported databases, two flags for TLS and compression, and a Docker image under 30 MB. Most self-hosted analytics tools require multiple services or a Node.js runtime; Fathom Lite compiles everything — dashboard, tracker, API, and migrations — into a single Go binary that starts in milliseconds. Its buffered channel-based pageview collector is a thoughtful concurrency pattern that absorbs traffic spikes without requiring a separate message queue. The referrer spam blacklist sourced from the Matomo community provides built-in data quality that most simple analytics tools omit. These choices make it a rare example of a complete analytics stack that a single developer can understand end-to-end in an afternoon.

Self-Hosting

Fathom Lite is released under the MIT License, which is one of the most permissive open-source licenses available. You can use it commercially, modify it, distribute it, and sublicense it without any restriction — there are no copyleft obligations, no requirement to open-source modifications, and no attribution requirement beyond keeping the copyright notice in the source files. This makes it safe to embed in proprietary products or to fork for internal use.

Running Fathom Lite yourself means taking on full operational responsibility. You need a Linux server (or Docker host) with outbound access for Let’s Encrypt if you want TLS, and a database: SQLite works out of the box for low-traffic sites, while MySQL or PostgreSQL is recommended for production. The project provides no built-in backup mechanism — you are responsible for database snapshots, server uptime, dependency updates, and applying security patches from the repository. Since the project is in maintenance-only mode, security fixes do arrive but new features do not, so you should plan for a stable but frozen feature set.

Compared to the commercial Fathom Analytics hosted service, the self-hosted Lite version is missing several capabilities that matter at scale: the hosted product is cookie-free by design (Lite uses cookies for session tracking), includes a real-time API, supports custom events and ecommerce tracking, offers EU data isolation, provides email reports and CSV exports, manages up to 50 sites per account, and comes with email support and an SLA. If your analytics needs grow beyond basic pageview counts and referrer data, or if you would rather not maintain server infrastructure, the commercial hosted option addresses those gaps — though it carries a monthly cost based on pageview volume.

Join founders buildingwith open source

Opinionated takes, migration guides, cost-saving tips, and insights from the open source ecosystem.

Subscribe on Substack

No spam. Unsubscribe anytime.

Join 750+ subscribers
No spam. Unsubscribe anytime.

Search