Astro

The Satsu.astro component from satsu-analytics/astro adds the tracker to the pages that render it. Put it in your base layout and every page is covered.

Setup

Run init

It signs you in, creates the site, writes the environment variable and adds the component to your base layout.

npx satsu-analytics init

Skip to Verify it works if init finished. To do it by hand, continue with the next steps.

Or install the package yourself

npm install satsu-analytics

Set the site ID

Create a site in the dashboard (Sites → your site → install) and put its ID into .env:

sh
PUBLIC_SATSU_SITE=YOUR_ID

The component falls back to PUBLIC_SATSU_SITE when you don't pass site.

Add the component

In your base layout, for example src/layouts/Layout.astro:

astro
---
import Satsu from "satsu-analytics/astro";
---
 
<html lang="en">
  <body>
    <slot />
    <Satsu />
  </body>
</html>

Verify it works

Run npm run dev. On localhost the tracker itself is not loaded; the component sends one dev ping per page load so the install check can confirm the setup, and it is never counted or shown in your stats. After you deploy, follow Verify it works to see the first real visit.

Next: track custom events and type them from your goals. Prefer no package? Put the script tag in your layout's <head>.