Plausible
Privacy-first, cookieless web analytics — proxied through your Next.js app to bypass ad blockers.
Plausible is a lightweight, GDPR-compliant alternative to Google Analytics. No cookies, no consent banner needed, no personal data collection.
The template integrates Plausible via next-plausible, which proxies the tracking script through your own domain so ad blockers don't strip it.
Setup
- Sign up at plausible.io and add your site (e.g.,
my-directory.com) - Set the env var:
NEXT_PUBLIC_PLAUSIBLE_DOMAIN=my-directory.comUse the exact domain you registered in Plausible — not www. prefixed, not a URL, just the hostname.
- Redeploy. Analytics start collecting immediately.
If the var is empty, the tracking script isn't rendered at all.
Self-hosted Plausible
If you run your own Plausible instance (e.g., at stats.my-directory.com), also set:
PLAUSIBLE_CUSTOM_DOMAIN=https://stats.my-directory.comThe proxy routes your site's tracking requests through this host instead of plausible.io. Leave empty to use the hosted plausible.io.
What's tracked by default
- Page views (automatic)
- Outbound link clicks (via Plausible's script)
Custom events (vote, submit, sign-up) are not instrumented out of the box. See Voting for an example of wiring one up.
Adding custom events
"use client"
import { usePlausible } from "next-plausible"
export function MyButton() {
const plausible = usePlausible()
return (
<button onClick={() => plausible("Clicked CTA")}>
Click me
</button>
)
}Events appear in the Plausible dashboard under Goals.
Removing Plausible
If you prefer another analytics provider (or none at all):
- Remove
NEXT_PUBLIC_PLAUSIBLE_DOMAINfrom your env - In next.config.mjs, remove the
withPlausibleProxy(...)wrapper and thenext-plausibleimport - In app/layout.tsx, remove the
<PlausibleProvider>block and its import bun remove next-plausible
Common issues
No events showing — Make sure NEXT_PUBLIC_PLAUSIBLE_DOMAIN matches exactly the domain registered in Plausible. Check the browser network tab for requests to /_plausible/... — they should return 200.
Events blocked by ad blockers — You're not using the proxy. Confirm the withPlausibleProxy wrapper is in next.config.mjs and the script loads from your own domain (not plausible.io).
Self-hosted instance not recognized — PLAUSIBLE_CUSTOM_DOMAIN must include the protocol (https://) and no trailing slash.