MCPSERV.CLUB
GoatCounter

GoatCounter

Self-Hosted

Privacy-friendly web analytics for self-hosted sites

Active(75)
5.2kstars
1views
Updated Sep 6, 2025

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/http library is used with a small router (github.com/go-chi/chi) for clean route handling.
  • Templating: Go’s html/template package powers the dashboard, ensuring safe rendering without external dependencies.
  • Metrics & Logging: The application writes logs in JSON to stdout and exposes a Prometheus‑style /metrics endpoint 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 sessions link.
  • 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 /data for 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/visit endpoint.
  • 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

AspectGoatCounter
PrivacyNo persistent identifiers, no cookies required.
PerformanceLightweight binary (~10 MB), minimal network payload (~3.5 KB).
LicensingMIT‑style open source, no vendor lock‑in.
FlexibilityMultiple ingestion methods (JS, pixel, API, log import).
CostZero 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

Weekly Views

Loading...
Support Us

Featured Project

$30/month

Get maximum visibility with featured placement and special badges

Repository Health

Loading health data...

Information

Category
data-analysis
License
NOASSERTION
Stars
5.2k
Technical Specs
Pricing
Open Source
Database
Multiple
Docker
Community
Supported OS
LinuxWindowsmacOSBSDDocker
Author
arp242
arp242
Last Updated
Sep 6, 2025