Docs
CLI + CI
Docs Analytics

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 dataLayer pushes
  • 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-analytics

When 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_clicked
  • landing_playground_clicked
  • landing_docs_clicked
  • launch_path_clicked
  • quickstart_completed
  • quickstart_playground_clicked
  • playground_template_opened
  • outbound_github_clicked
  • outbound_npm_clicked

Payload shape

Every event includes:

  • path (current pathname)
  • source/context fields where relevant (source, destination, title, target)

page_view includes:

  • page_path
  • page_location
  • page_title

Endpoint-forwarded envelope shape:

  • type: event or page_view
  • eventName for event entries
  • payload
  • sentAt (ISO timestamp)

Verify locally

  1. Start docs with env vars set.
  2. Open browser devtools network tab.
  3. Click landing and quickstart CTAs.
  4. Scroll Quickstart until “Next Steps” is visible (emits quickstart_completed once per session).
  5. Confirm requests to Plausible or GA endpoints.