Skip to main content
To add tinyanalytics to a React app built with Vite or Create React App, put the tracking snippet in your index.html. Because it’s a single-page app, one tag in the HTML shell covers every route — 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 snippet to index.html

Open the index.html at the root of your project (Vite) or in public/ (Create React App), and add the snippet inside <head>:
index.html
Replace YOUR_SITE_ID with your real site ID, and copy the full snippet from Settings → Tracking if you’ve toggled any options.
That’s it — the script loads once for the whole app and needs no changes as your app grows.

Client-side routing is tracked automatically

React apps change routes on the client (with React Router or similar), and tinyanalytics records each route change as a new pageview by default (data-track-spa). You don’t need to hook into your router. See Track single-page apps to change this behavior.

Verify

Run your app, 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 Next.js

A Next.js app instead.

Track custom events

Send events from your components.

Configure the tracking script

Every data-* option you can set.

Verify your setup

Confirm tracking works.