204 lines
7.8 KiB
Markdown
204 lines
7.8 KiB
Markdown
---
|
|
title: GoatCounter
|
|
created: 2026-06-07
|
|
updated: 2026-06-07
|
|
type: app
|
|
tags: [catalogue, web-analytics, privacy, self-hosted, analytics, go, golang, sqlite, postgresql, minimal]
|
|
confidence: high
|
|
contested: false
|
|
sources: [https://selfh.st/apps/?tag=web-analytics]
|
|
---
|
|
|
|
# 🐐 GoatCounter
|
|
|
|
> Analytics web **privacy-first** écrit en Go, ultra-léger et **single-binary** — un script de 1.5 Ko, parfait pour blogs, sites personnels et petits projets.
|
|
> Source : [selfh.st](https://selfh.st/apps/?tag=web-analytics)
|
|
|
|
## 📋 Métadonnées
|
|
|
|
| Métadonnée | Valeur |
|
|
| :--- | :--- |
|
|
| **Site web** | [goatcounter.com](https://www.goatcounter.com/) |
|
|
| **GitHub** | [github.com/arp242/goatcounter](https://github.com/arp242/goatcounter) |
|
|
| **License** | EUPL-1.2 (ou AGPL-3.0 pour les patches) |
|
|
| **Langage** | Go (single binary) / SQLite ou PostgreSQL |
|
|
| **Étoiles** | 259 |
|
|
| **Dernière MAJ** | 2026-05 |
|
|
| **Catégorie** | [[cat-web-analytics]] |
|
|
|
|
## 📝 Description
|
|
|
|
**GoatCounter** est une plateforme d'**analyse web open source** et **privacy-first** développée par **Martin Tournoij** (arp242). Sa philosophie est simple : fournir des **statistiques utiles sans la complexité ni la lourdeur éthique** de Google Analytics, dans un **binaire Go unique** facile à déployer.
|
|
|
|
Points forts : **script de tracking ultra-léger** (~1.5 Ko, comparable à Plausible), **aucun cookie**, **conformité RGPD native** (pas de bandeau de consentement requis), **stockage en SQLite** (par défaut, parfait pour les petits sites) ou **PostgreSQL** (pour les sites à fort trafic), **single binary** sans dépendance — pas de Node.js, pas de PHP, pas de runtime tiers.
|
|
|
|
Fonctionnalités clés : **tableau de bord par site** avec visiteurs uniques, pages vues, sources, pays, navigateurs, **tracking des événements personnalisés** (clics, soumissions de formulaires), **intégration Stripe** pour e-commerce, **API JSON** complète, **partage de dashboards** (lien public en lecture seule), **export CSV** des données, **téléchargement / upload de configuration**, **anti-adblock bypass** intégré (le script se charge même avec adblock), **personnalisation** via thèmes, **sites illimités** dans une seule instance.
|
|
|
|
GoatCounter propose aussi un **service cloud officiel** (`codeberg.org` en fait l'hébergeur historique ; la société fournit un service payant). L'UI est volontairement **sobre et lisible**, avec un mode sombre bien pensé. Le projet est **actif et maintenu**, avec des releases fréquentes.
|
|
|
|
## 🚀 Installation
|
|
|
|
### Option 1 : Docker Compose (SQLite)
|
|
|
|
```yaml
|
|
# docker-compose.yml
|
|
version: '3.8'
|
|
|
|
services:
|
|
goatcounter:
|
|
image: arp242/goatcounter:latest
|
|
container_name: goatcounter
|
|
restart: unless-stopped
|
|
ports:
|
|
- "8080:8080"
|
|
environment:
|
|
GOATCOUNTER_LISTEN: "0.0.0.0:8080"
|
|
GOATCOUNTER_PUBLIC_URL: "https://gc.example.com"
|
|
GOATCOUNTER_DOMAIN: "gc.example.com"
|
|
GOATCOUNTER_ADMIN_EMAIL: "admin@example.com"
|
|
GOATCOUNTER_ADMIN_PASSWORD: changez-moi
|
|
GOATCOUNTER_DB: "sqlite:///data/goatcounter.db"
|
|
GOATCOUNTER_TLS: "auto"
|
|
volumes:
|
|
- ./data:/data
|
|
networks:
|
|
- goat-net
|
|
healthcheck:
|
|
test: ["CMD", "wget", "--spider", "-q", "http://localhost:8080/"]
|
|
interval: 30s
|
|
timeout: 5s
|
|
retries: 3
|
|
|
|
networks:
|
|
goat-net:
|
|
driver: bridge
|
|
```
|
|
|
|
> Variante **PostgreSQL** : remplacer `GOATCOUNTER_DB` par `postgres://user:***@db:5432/goatcounter` et ajouter un service `db` (postgres:16-alpine).
|
|
|
|
Lancement :
|
|
|
|
```bash
|
|
docker compose up -d
|
|
# Accéder à https://localhost:8080
|
|
# Lancer le setup initial :
|
|
docker compose exec goatcounter goatcounter db create-site \
|
|
-email admin@example.com -password changeme -domain example.com
|
|
```
|
|
|
|
### Option 2 : Installation manuelle (binaire Go)
|
|
|
|
```bash
|
|
# Télécharger le binaire
|
|
wget https://github.com/arp242/goatcounter/releases/download/v2.10.0/goatcounter-v2.10.0-linux-amd64.tar.gz
|
|
tar xzf goatcounter-v2.10.0-linux-amd64.tar.gz
|
|
sudo mv goatcounter /usr/local/bin/
|
|
|
|
# Créer un user dédié
|
|
sudo useradd -r -m -d /var/lib/goatcounter -s /bin/bash goatcounter
|
|
|
|
# Lancer en mode dev / service
|
|
sudo -u goatcounter goatcounter serve -listen 127.0.0.1:8080 \
|
|
-public-url https://gc.example.com \
|
|
-db 'sqlite:/var/lib/goatcounter/goatcounter.db' \
|
|
-tls auto
|
|
```
|
|
|
|
Configuration **systemd** (`/etc/systemd/system/goatcounter.service`) :
|
|
|
|
```ini
|
|
[Unit]
|
|
Description=GoatCounter analytics
|
|
After=network.target
|
|
|
|
[Service]
|
|
User=goatcounter
|
|
Group=goatcounter
|
|
ExecStart=/usr/local/bin/goatcounter serve \
|
|
-listen 127.0.0.1:8080 \
|
|
-public-url https://gc.example.com \
|
|
-db 'sqlite:/var/lib/goatcounter/goatcounter.db' \
|
|
-tls auto
|
|
Restart=on-failure
|
|
RestartSec=5
|
|
|
|
[Install]
|
|
WantedBy=multi-user.target
|
|
```
|
|
|
|
```bash
|
|
sudo systemctl daemon-reload
|
|
sudo systemctl enable --now goatcounter
|
|
```
|
|
|
|
## ⚙️ Configuration
|
|
|
|
- **GOATCOUNTER_LISTEN** : adresse d'écoute (par défaut `0.0.0.0:8080`).
|
|
- **GOATCOUNTER_PUBLIC_URL** : URL publique, **obligatoire** pour HTTPS auto-généré.
|
|
- **GOATCOUNTER_DOMAIN** : domaine principal géré par l'instance.
|
|
- **GOATCOUNTER_DB** : `sqlite:///path/db.db` ou `postgres://...`.
|
|
- **GOATCOUNTER_ADMIN_EMAIL** / **GOATCOUNTER_ADMIN_PASSWORD** : identifiants du premier admin.
|
|
- **GOATCOUNTER_TLS** : `auto` (Let's Encrypt intégré), `acme`, ou `none` (derrière un reverse proxy).
|
|
- **GOATCOUNTER_BOT_REGEX** : regex pour identifier les bots (par défaut, vaste pattern).
|
|
- **GOATCOUNTER_IGNORE_BOTS** : `true` (recommandé) pour exclure les bots des stats.
|
|
- **Snippet de tracking** :
|
|
|
|
```html
|
|
<script data-goatcounter="https://gc.example.com/count"
|
|
async src="//gc.example.com/count.js"></script>
|
|
```
|
|
|
|
- **Sites multiples** : GoatCounter supporte nativement plusieurs domaines depuis une seule instance.
|
|
- **Événements personnalisés** : envoyer un hit avec `?event=...&val=...`.
|
|
|
|
## 🔄 Alternatives
|
|
|
|
**Open source** :
|
|
- [[app-umami]] — plus complet, base PostgreSQL
|
|
- [[app-plausible]] — privacy-first, Elixir
|
|
- [[app-ackee]] — minimaliste, Node.js + MongoDB
|
|
- [[app-matomo]] — analytics PHP complet
|
|
- [[app-open-web-analytics]] — PHP traditionnel
|
|
- [[app-rybbit]] — TypeScript moderne
|
|
- [[app-litlyx]] — TypeScript simple
|
|
- [[app-swetrix]] — TypeScript Plausible-like
|
|
- [[app-vince]] — Go minimaliste
|
|
|
|
**Propriétaire (SaaS)** :
|
|
- **Google Analytics 4** — leader du marché
|
|
- **GoatCounter Cloud** — service payant officiel (à partir de 5 $/mois)
|
|
- **Plausible Cloud** — payant
|
|
- **Fathom Analytics** — simple
|
|
- **Simple Analytics** — design
|
|
- **Pirsch** — allemand RGPD
|
|
- **Umami Cloud** — service officiel Umami
|
|
|
|
## 🔒 Sécurité
|
|
|
|
- **Changer immédiatement** le mot de passe admin créé lors du `db create-site`.
|
|
- Activer **HTTPS** via Let's Encrypt (`GOATCOUNTER_TLS=auto`) ou reverse proxy.
|
|
- **GoatCounter a un mode CSRF strict** : garder `GOATCOUNTER_ALLOW_ORIGIN` cohérent avec `GOATCOUNTER_DOMAIN`.
|
|
- En production, **lier à 127.0.0.1** et exposer via reverse proxy (Nginx, Caddy, Traefik).
|
|
- **Sauvegardes SQLite** : copie du fichier `.db` (mode `VACUUM INTO 'backup.db'` recommandé), idéalement quotidienne.
|
|
- En PostgreSQL : `pg_dump` quotidien.
|
|
- Mettre à jour régulièrement — releases fréquentes, suivre le repo.
|
|
- **Rate limiting** : GoatCounter dispose d'un rate limit natif sur `/count`, surveiller les logs.
|
|
- **fail2ban** sur l'API admin recommandé.
|
|
- Restreindre l'accès admin via **IP allowlist** ou VPN.
|
|
|
|
## 📚 Ressources
|
|
|
|
- [Site officiel](https://www.goatcounter.com/)
|
|
- [Documentation](https://www.goatcounter.com/docs/)
|
|
- [GitHub arp242/goatcounter](https://github.com/arp242/goatcounter)
|
|
- [API reference](https://www.goatcounter.com/api.html)
|
|
- [Anti-adblock strategy](https://www.goatcounter.com/help/visitor-info)
|
|
|
|
## 🔗 Pages Liées
|
|
|
|
- [[cat-web-analytics]]
|
|
- [[recettes-docker-compose]]
|
|
- [[app-umami]]
|
|
- [[app-plausible]]
|
|
- [[app-ackee]]
|