📊 Privacy-Respecting Analytics Guide
This guide covers analytics options that respect user privacy and comply with regulations like GDPR.
Philosophy
This template does not include analytics by default because:
- 🔒 Privacy first: Users should opt-in to tracking
- 🌍 GDPR compliance: Cookie consent is complex
- 🎯 Your choice: Different projects have different needs
Comparison of Options
| Service | Type | Cookies | GDPR | Cost | Complexity |
|---|---|---|---|---|---|
| Plausible | SaaS/Self-host | ❌ No | ✅ Compliant | €9/mo or free (self-host) | Low |
| Umami | Self-hosted | ❌ No | ✅ Compliant | Free | Medium |
| Simple Analytics | SaaS | ❌ No | ✅ Compliant | $9/mo | Low |
| Goat Counter | SaaS/Self-host | ❌ No | ✅ Compliant | Free tier | Low |
| Fathom | SaaS | ❌ No | ✅ Compliant | $14/mo | Low |
| Google Analytics | SaaS | ✅ Yes | ⚠️ Requires consent | Free | Medium |
Option 1: Plausible Analytics
Plausible is a lightweight, privacy-focused alternative to Google Analytics.
Features
- ✅ No cookies, no consent banner needed
- ✅ GDPR, CCPA, PECR compliant
- ✅ Lightweight script (~1KB)
- ✅ Open source (self-hostable)
Setup (SaaS)
Step 1: Create Account
Sign up at plausible.io and add your site.
Step 2: Install Plugin
npm install docusaurus-plugin-plausible
Step 3: Configure
docusaurus.config.js
plugins: [
[
'docusaurus-plugin-plausible',
{
domain: 'your-docs-site.com',
},
],
],
Setup (Self-Hosted)
Use the headTags approach:
docusaurus.config.js
headTags: [
{
tagName: 'script',
attributes: {
defer: 'true',
'data-domain': 'your-docs-site.com',
src: 'https://your-plausible-instance.com/js/script.js',
},
},
],
Option 2: Umami
Umami is a simple, fast, privacy-focused analytics solution.
Features
- ✅ 100% open source
- ✅ Self-hosted (full data ownership)
- ✅ No cookies
- ✅ GDPR compliant
- ✅ Real-time dashboard
Setup
Step 1: Deploy Umami
Deploy using Docker, Vercel, Railway, or other platforms. See Umami docs.
Step 2: Add Tracking Script
docusaurus.config.js
headTags: [
{
tagName: 'script',
attributes: {
async: 'true',
defer: 'true',
'data-website-id': 'YOUR_WEBSITE_ID',
src: 'https://your-umami-instance.com/script.js',
},
},
],
Docker Compose Example
docker-compose.yml
version: '3'
services:
umami:
image: ghcr.io/umami-software/umami:postgresql-latest
ports:
- "3000:3000"
environment:
DATABASE_URL: postgresql://umami:umami@db:5432/umami
DATABASE_TYPE: postgresql
HASH_SALT: your-random-salt-here
depends_on:
- db
db:
image: postgres:15-alpine
environment:
POSTGRES_DB: umami
POSTGRES_USER: umami
POSTGRES_PASSWORD: umami
volumes:
- umami-db:/var/lib/postgresql/data
volumes:
umami-db:
Option 3: Simple Analytics
Simple Analytics is a privacy-first analytics service.