Scripts2026年4月10日·1 分钟阅读

Plausible Analytics — Privacy-First Google Analytics Alternative

Plausible is an open-source, cookie-free web analytics tool that provides essential traffic insights while respecting visitor privacy. GDPR/CCPA compliant by design.

SC
Script Depot · Community
快速使用

先拿来用,再决定要不要深挖

这里应该同时让用户和 Agent 知道第一步该复制什么、安装什么、落到哪里。

Add one script tag to your website:

<script defer data-domain="yourdomain.com" src="https://plausible.io/js/script.js"></script>

Or self-host with Docker:

git clone https://github.com/plausible/hosting.git
cd hosting
docker compose up -d

Open http://localhost:8000 — register and add your first site.

介绍

Plausible Analytics is an open-source, privacy-first web analytics platform designed as a lightweight alternative to Google Analytics. It provides all essential website traffic insights in a clean, simple dashboard — without cookies, without personal data collection, and fully compliant with GDPR, CCPA, and PECR out of the box.

With 24.6K+ GitHub stars and AGPL-3.0 license, Plausible has become the go-to choice for privacy-conscious website owners who want actionable analytics without the complexity and privacy concerns of Google Analytics.

What Plausible Does

Plausible focuses on essential web analytics without bloat:

  • Traffic Overview: Unique visitors, page views, bounce rate, visit duration — all in one dashboard
  • Source Attribution: See where your traffic comes from (search engines, social media, referral sites, campaigns)
  • Page Analytics: Most visited pages, entry pages, exit pages with real-time data
  • Location Data: Country and city-level breakdown without IP tracking (uses timezone-based approximation)
  • Device Analytics: Browser, OS, and screen size breakdown
  • Goal & Event Tracking: Custom events, revenue tracking, and conversion funnels
  • UTM Campaign Tracking: Full UTM parameter support for marketing campaigns

Why Privacy-First Matters

┌─────────────────────────────────┐
│  Google Analytics               │
│  ✗ 45KB script                 │
│  ✗ Sets cookies                │
│  ✗ Tracks across sites         │
│  ✗ Requires cookie banner      │
│  ✗ Data sent to Google         │
└─────────────────────────────────┘

┌─────────────────────────────────┐
│  Plausible Analytics            │
│  ✓ <1KB script                 │
│  ✓ No cookies                  │
│  ✓ No cross-site tracking      │
│  ✓ No consent banner needed    │
│  ✓ Data stays with you         │
└─────────────────────────────────┘

Plausible achieves accurate analytics without cookies by using a hash of the visitor's IP address + User-Agent for daily unique identification. This hash is rotated daily and never stored, making it impossible to track individual users.

Self-Hosting Guide

Prerequisites

  • Docker and Docker Compose
  • A server with 2GB+ RAM
  • A domain with DNS configured

Setup

git clone https://github.com/plausible/hosting.git
cd hosting

# Configure
cp .env.example .env
# Edit .env:
# BASE_URL=https://analytics.yourdomain.com
# SECRET_KEY_BASE=$(openssl rand -base64 48)

# Start
docker compose up -d

ClickHouse Backend

Plausible uses ClickHouse for analytics data storage, providing:

  • Sub-second query performance on millions of events
  • Efficient columnar compression (10-20x less storage than row-based DBs)
  • Time-series optimized aggregations

Reverse Proxy (Nginx)

server {
    listen 443 ssl;
    server_name analytics.yourdomain.com;

    location / {
        proxy_pass http://127.0.0.1:8000;
        proxy_set_header Host $host;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header X-Forwarded-Proto $scheme;
    }
}

Advanced Features

Custom Event Tracking

<script>
  // Track button clicks
  document.getElementById('signup-btn').addEventListener('click', function() {
    plausible('Signup', { props: { plan: 'pro' } });
  });

  // Track revenue
  plausible('Purchase', { revenue: { currency: 'USD', amount: 29.99 } });
</script>

API Access

# Get site stats
curl "https://plausible.io/api/v1/stats/realtime/visitors?site_id=yourdomain.com" 
  -H "Authorization: Bearer YOUR_API_KEY"

# Get breakdown by page
curl "https://plausible.io/api/v1/stats/breakdown?site_id=yourdomain.com&period=30d&property=event:page" 
  -H "Authorization: Bearer YOUR_API_KEY"

Plausible vs Alternatives

Feature Plausible Google Analytics Umami Fathom
Open Source Yes (AGPL-3.0) No Yes (MIT) No
Cookie-free Yes No Yes Yes
Script size <1KB 45KB 2KB 5KB
Self-hosted Yes No Yes No
Real-time Yes Delayed Yes Yes
ClickHouse Yes Proprietary No No
Revenue tracking Yes Yes No Yes

常见问题

Q: 没有 cookie 怎么统计独立访客? A: Plausible 使用访客 IP + User-Agent 的每日轮换哈希值来识别唯一访客,该哈希不会被存储,且每天自动重置,无法用于跨天追踪。

Q: 自托管的服务器配置要求是什么? A: 最低 2GB RAM,推荐 4GB+。对于日访问量 10 万以内的站点,1 核 2GB 即可流畅运行。ClickHouse 会占用较多内存用于查询缓存。

Q: 可以从 Google Analytics 迁移数据吗? A: Plausible 提供 GA 数据导入工具,支持从 Google Analytics(UA 和 GA4)导入历史数据。

来源与致谢

讨论

登录后参与讨论。
还没有评论,来写第一条吧。

相关资产