Overview
Discover what makes GoatCounter powerful
GoatCounter is a lightweight, privacy‑first web analytics platform written in Go. It offers a minimalistic API surface that can be integrated via a single JavaScript snippet, an image‑based pixel, or direct HTTP requests from server middleware. The core idea is to provide meaningful traffic insights without tracking personal data, making it a suitable alternative for developers who want full ownership of their metrics while avoiding the complexity and data‑privacy concerns associated with Google Analytics or Matomo.
Language & Runtime
Database
Web Framework
Templating
Overview
GoatCounter is a lightweight, privacy‑first web analytics platform written in Go. It offers a minimalistic API surface that can be integrated via a single JavaScript snippet, an image‑based pixel, or direct HTTP requests from server middleware. The core idea is to provide meaningful traffic insights without tracking personal data, making it a suitable alternative for developers who want full ownership of their metrics while avoiding the complexity and data‑privacy concerns associated with Google Analytics or Matomo.
Technical Stack
- Language & Runtime: Go 1.20+ – the entire application is a single statically‑compiled binary that bundles its own HTTP server, template engine, and database driver.
- Database: SQLite is the default persistence layer. The schema is intentionally simple (four tables for visits, sites, referrers, and sessions) and the driver is compiled into the binary. For production workloads, developers can swap SQLite for PostgreSQL or MySQL by passing a DSN at runtime.
- Web Framework: The standard
net/httplibrary is used with a small router (github.com/go-chi/chi) for clean route handling. - Templating: Go’s
html/templatepackage powers the dashboard, ensuring safe rendering without external dependencies. - Metrics & Logging: The application writes logs in JSON to stdout and exposes a Prometheus‑style
/metricsendpoint for operational monitoring.
Core Capabilities
- Privacy‑Aware Session Tracking: Sessions are identified by a SHA‑256 hash of the user’s IP, User‑Agent, and timestamp, avoiding cookies or persistent identifiers. The algorithm is documented in the
sessionslink. - RESTful API: Endpoints for creating sites, querying statistics, and posting raw visits (
POST /api/visit) allow backend services to feed data directly. - Log Importer: A CLI tool (
goatcounter import) parses Nginx, Apache, Caddy, or CloudFront logs and bulk‑imports them into the database. It supports custom log formats via regex. - Custom Dimensions: Developers can send arbitrary key/value pairs in the API payload, which are stored as JSON blobs and exposed via the dashboard.
- Webhooks: Optional outbound webhooks can be configured to notify external services when thresholds are met (e.g., new daily visitors > 10 k).
Deployment & Infrastructure
- Self‑Hosting: A single binary runs on any OS with a Go runtime. Only a writable file system for the SQLite database (or an external DB) is required.
- Containerization: Official Docker images are available on Docker Hub, built from the release binaries. The image exposes port 8080 and mounts
/datafor persistence. - Scalability: While SQLite is sufficient for small to medium sites, the architecture supports sharding by running multiple instances behind a load balancer and aggregating metrics via the API. The stateless HTTP server can be horizontally scaled without shared state.
- Cloud Deployment: Runs natively on Kubernetes, ECS, or any VPS. The binary can be wrapped in a systemd service for high‑availability.
Integration & Extensibility
- Script Tag: The default integration is a single
<script>tag that posts JSON to the server asynchronously. - Image Pixel: For no‑JS environments, a 1×1 PNG can be requested with query parameters encoding the visit data.
- Middleware: Any language that can make HTTP requests (Python, Node.js, Ruby) can act as a proxy to GoatCounter’s
/api/visitendpoint. - Plugins: The codebase exposes a small interface for extending the import pipeline or adding new data sources, though no official plugin system exists yet. Community contributions are welcome via pull requests.
Developer Experience
- Configuration: Settings are driven by environment variables (
GC_SITE,GC_DB_URL, etc.) and a simple YAML file for advanced options. No complex configuration files are required. - Documentation: The README, API docs, and in‑code comments provide a clear developer path. The
docs/folder contains rationale, privacy details, and migration guides. - Community: GoatCounter is hosted on GitHub with an active issue tracker. Contributions are encouraged, and the project maintains a clear code of conduct.
- Testing: Unit tests cover core logic, and integration tests use a temporary SQLite database. CI runs on GitHub Actions.
Use Cases
- Personal Projects: Hobbyists can deploy a single instance to track traffic on blogs or portfolio sites without exposing user data.
- Enterprise Analytics: Companies that need GDPR‑compliant analytics can host GoatCounter on their own infrastructure, ensuring data never leaves the corporate network.
- Educational Platforms: Instructors can provide students with a hands‑on analytics system that respects privacy while teaching data collection fundamentals.
- API‑First Applications: Services that already expose an API can push visit data directly from their backend, bypassing client‑side scripts entirely.
Advantages
| Aspect | GoatCounter |
|---|---|
| Privacy | No persistent identifiers, no cookies required. |
| Performance | Lightweight binary (~10 MB), minimal network payload (~3.5 KB). |
| Licensing | MIT‑style open source, no vendor lock‑in. |
| Flexibility | Multiple ingestion methods (JS, pixel, API, log import). |
| Cost | Zero operational cost beyond hosting; no monthly fees. |
Developers who prioritize data ownership, simplicity, and compliance will find GoatCounter a compelling choice over more heavyweight analytics
Open SourceReady to get started?
Join the community and start self-hosting GoatCounter today
Related Apps in data-analysis
Uptime Kuma
Self-hosted uptime monitoring for all services
Apache Superset
Open‑source BI for fast, no‑code data exploration
Metabase
Easy open‑source business intelligence for everyone
Netron
Visualize AI models in any browser or desktop
Umami
Privacy‑focused, lightweight web analytics
PostHog
Open‑source product analytics and experimentation platform
Weekly Views
Repository Health
Information
Explore More Apps
Domain Locker
Central hub for managing and monitoring all your domain names
mStream
Your private music streaming server

RhodeCode
Unified source control for Git, Mercurial, and Subversion
TileServer GL
Serve vector and raster tiles with MapLibre rendering
HOMER 10
Carrier‑grade VoIP & RTC observability platform
Known
Open‑source social publishing for groups and individuals