Docs Analytics
Docs site events are already emitted from the UI via trackDocsEvent(...).
Route-level pageviews are also emitted from _app.tsx as page_view.
This page shows how to wire actual providers so those events land in telemetry.
Supported providers
- Plausible (
window.plausible) - Google Analytics / gtag (
window.gtag) - Generic GTM-style
dataLayerpushes - Optional self-hosted endpoint forwarding (
NEXT_PUBLIC_ANALYTICS_ENDPOINT)
Environment variables
Set one or both:
NEXT_PUBLIC_PLAUSIBLE_DOMAIN=docs.glincker.com
NEXT_PUBLIC_GA_ID=G-XXXXXXXXXX
NEXT_PUBLIC_ANALYTICS_ENDPOINT=https://your-api.example.com/docs-analyticsWhen set, scripts are auto-injected from apps/docs/theme.config.tsx.
When NEXT_PUBLIC_ANALYTICS_ENDPOINT is set, docs events/pageviews are forwarded from the client via sendBeacon fallbacking to fetch(..., { keepalive: true }).
Events currently emitted
page_view(on initial load and route changes)landing_quickstart_clickedlanding_playground_clickedlanding_docs_clickedlaunch_path_clickedquickstart_completedquickstart_playground_clickedplayground_template_openedoutbound_github_clickedoutbound_npm_clicked
Payload shape
Every event includes:
path(current pathname)- source/context fields where relevant (
source,destination,title,target)
page_view includes:
page_pathpage_locationpage_title
Endpoint-forwarded envelope shape:
type:eventorpage_vieweventNameforevententriespayloadsentAt(ISO timestamp)
Verify locally
- Start docs with env vars set.
- Open browser devtools network tab.
- Click landing and quickstart CTAs.
- Scroll Quickstart until “Next Steps” is visible (emits
quickstart_completedonce per session). - Confirm requests to Plausible or GA endpoints.