Skip to main content
To add tinyanalytics to a Docusaurus site, add the tracking script to the scripts array in docusaurus.config.js. Docusaurus injects it into every page, and client-side navigation between docs pages is tracked automatically.

Before you start

  • A tinyanalytics site. If you don’t have one yet, follow the Quickstart.
  • Your site’s numeric site ID, from Settings → Tracking in your dashboard.

Add the script in docusaurus.config.js

Add an entry to the top-level scripts array:
docusaurus.config.js
Replace YOUR_SITE_ID with your real site ID. If you’ve toggled options in Settings → Tracking, add each one as another "data-..." key in the same object.

Client-side navigation is tracked automatically

Docusaurus is a single-page app that renders navigation on the client, and tinyanalytics records each page change as a new pageview by default (data-track-spa). See Track single-page apps to change this.

Verify

Build or deploy your site, open it in a browser, then check Realtime in your dashboard for your visit. See Verify your setup for the full check.
Your install is working when your own visit appears in Realtime in your dashboard.

Install on VitePress

Another docs framework.

Configure the tracking script

Every data-* option you can set.

Track custom events

Measure clicks and downloads.

Verify your setup

Confirm tracking works.