Skip to main content
To add tinyanalytics to a VitePress site, add the tracking script to the head array in your VitePress config. It loads on every page, and client-side navigation 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 .vitepress/config

Add an entry to the head array in .vitepress/config.js (or config.ts):
.vitepress/config.js
Replace YOUR_SITE_ID with your real site ID. Each head entry is [tag, attributes]; add any other data-* options as more keys in the attributes object.

Client-side navigation is tracked automatically

VitePress 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 Docusaurus

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.