Lokale Analytics ohne Cookies für deine Website (selbstgehostet)
Um die Besucher*innenzahlen meiner Website zu messen wollte ich ungern Google Analytics oder ähnliche Dienste nutzen. Diese würden wieder eine Menge an rechtlichen Verpflichtungen nach sich ziehen. Dazu würden Datenschutztexte zählen, die ich ständig aktuell halten müsste.
Als dann Ghost 6.0 angekündigt wurde und lokale Analytics gleich mit, war ich natürlich froh und habe geduldig gewartet. Dann kam es endlich raus und die Enttäuschung war groß: Das Setup ist denkbar umständlich und schwer mit einem zusätzlichen Cloud-Anbieter, an den man sich binden würde.
Ich habe also nach Alternativen gesucht und bin zum Schluss bei Plausible gelandet. Die Community Edition ist kostenlos und einfach in Docker zu hosten.
Die Installationsanleitung findest du hier:
Hier ist meine compose:
services:
plausible_db:
image: postgres:16-alpine
restart: always
volumes:
- db-data:/var/lib/postgresql/data
environment:
- POSTGRES_PASSWORD=REDACTED
healthcheck:
test: ["CMD-SHELL", "pg_isready -U postgres"]
start_period: 1m
plausible_events_db:
image: clickhouse/clickhouse-server:24.12-alpine
restart: always
volumes:
- event-data:/var/lib/clickhouse
- event-logs:/var/log/clickhouse-server
- ./clickhouse/logs.xml:/etc/clickhouse-server/config.d/logs.xml:ro
# This makes ClickHouse bind to IPv4 only, since Docker doesn't enable IPv6 in bridge networks by default.
# Fixes "Listen [::]:9000 failed: Address family for hostname not supported" warnings.
- ./clickhouse/ipv4-only.xml:/etc/clickhouse-server/config.d/ipv4-only.xml:ro
# This makes ClickHouse consume less resources, which is useful for small setups.
# https://clickhouse.com/docs/en/operations/tips#using-less-than-16gb-of-ram
- ./clickhouse/low-resources.xml:/etc/clickhouse-server/config.d/low-resources.xml:ro
ulimits:
nofile:
soft: 262144
hard: 262144
environment:
- CLICKHOUSE_SKIP_USER_SETUP=1
healthcheck:
test: ["CMD-SHELL", "wget --no-verbose --tries=1 -O - http://127.0.0.1:8123/ping || exit 1"]
start_period: 1m
plausible:
image: ghcr.io/plausible/community-edition:v3.0.1
restart: always
command: sh -c "/entrypoint.sh db createdb && /entrypoint.sh db migrate && /entrypoint.sh run"
depends_on:
plausible_db:
condition: service_healthy
plausible_events_db:
condition: service_healthy
volumes:
- plausible-data:/var/lib/plausible
ulimits:
nofile:
soft: 65535
hard: 65535
environment:
- TMPDIR=/var/lib/plausible/tmp
# required: https://github.com/plausible/community-edition/wiki/configuration#required
- BASE_URL=${BASE_URL}
- SECRET_KEY_BASE=${SECRET_KEY_BASE}
# optional: https://github.com/plausible/community-edition/wiki/configuration#optional
# registration: https://github.com/plausible/community-edition/wiki/configuration#registration
- TOTP_VAULT_KEY
- DISABLE_REGISTRATION
- ENABLE_EMAIL_VERIFICATION
# web: https://github.com/plausible/community-edition/wiki/configuration#web
- HTTP_PORT
- HTTPS_PORT
# databases: https://github.com/plausible/community-edition/wiki/configuration#database
- DATABASE_URL
- CLICKHOUSE_DATABASE_URL
# Google: https://github.com/plausible/community-edition/wiki/configuration#google
- GOOGLE_CLIENT_ID
- GOOGLE_CLIENT_SECRET
# geolocation: https://github.com/plausible/community-edition/wiki/configuration#ip-geolocation
- IP_GEOLOCATION_DB
- GEONAMES_SOURCE_FILE
- MAXMIND_LICENSE_KEY
- MAXMIND_EDITION
# email: https://github.com/plausible/community-edition/wiki/configuration#email
- MAILER_ADAPTER
- MAILER_EMAIL
- MAILER_NAME
- SMTP_HOST_ADDR
- SMTP_HOST_PORT
- SMTP_USER_NAME
- SMTP_USER_PWD
- SMTP_HOST_SSL_ENABLED
- POSTMARK_API_KEY
- MAILGUN_API_KEY
- MAILGUN_DOMAIN
- MAILGUN_BASE_URI
- MANDRILL_API_KEY
- SENDGRID_API_KEY
volumes:
db-data:
event-data:
event-logs:
plausible-data:
Die .env für SMTP-Versand:
BASE_URL=https://deinedomain.com
SECRET_KEY_BASE=Geheim
HTTP_PORT=%der Port auf dem der Docker Container laufen soll (default ist 8000)
#HTTPS_PORT=444
#MAILER_ADAPTER
MAILER_EMAIL=webmaster@dersysadmin.de
MAILER_NAME
SMTP_HOST_ADDR=smtp.deinanbieter.de
SMTP_HOST_PORT=587
SMTP_USER_NAME=webmaster@deinewebsite.de
SMTP_USER_PWD="deinsmtppasswort"
services:
plausible:
ports:
- 8000:${HTTP_PORT}
Ich nutze für mich nginx (certbot-bereinigt).
Die config sieht wie folgt aus:
server {
server_name deinewebsite.de;
location / {
proxy_pass http://localhost:8000;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $host;
# proxy_redirect off;
}
location /live/websocket {
proxy_pass http://localhost:8000;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "Upgrade";
}
}
Dann noch einmal certbot drüber laufen lassen und dann kannst du dich schon anmelden und deine Analytics lokal nutzen 🎉