Skip to main content
To add tinyanalytics to an Astro site, put the tracking snippet in a shared layout’s <head> and mark it is:inline. That tells Astro to leave the third-party script exactly as written instead of bundling it, so it loads on every page that uses the layout.

Before you start

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

Add the snippet to a shared layout

Add the tag to the <head> of the layout your pages share, for example src/layouts/Layout.astro:
src/layouts/Layout.astro
Keep is:inline on the tag. Without it, Astro processes and bundles the <script>, which changes how (and whether) the third-party tracker loads. is:inline guarantees the snippet ships as-is.
Replace YOUR_SITE_ID with your real site ID, and copy the full snippet from Settings → Tracking if you’ve toggled any options.

Single-page navigation

Most Astro sites serve real page loads, which are tracked with no extra setup. If you use Astro’s client-side View Transitions for in-app navigation, tinyanalytics records those route changes as pageviews by default (data-track-spa).

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 any platform

The universal method and other platforms.

Configure the tracking script

Every data-* option you can set.

Track custom events

Measure signups, clicks, and downloads.

Verify your setup

Confirm tracking works.