> ## Documentation Index
> Fetch the complete documentation index at: https://tinyanalytics.io/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Astro Analytics Integration

> Add tinyanalytics to an Astro site by placing the tracking snippet in a shared layout's head with is:inline so Astro leaves the third-party tag untouched.

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](/docs/tinyanalytics-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`:

```astro src/layouts/Layout.astro theme={null}
---
const { title } = Astro.props;
---
<html lang="en">
  <head>
    <meta charset="utf-8" />
    <title>{title}</title>
    <script is:inline defer src="https://dash.tinyanalytics.io/script.js"
      data-site-id="YOUR_SITE_ID"></script>
  </head>
  <body>
    <slot />
  </body>
</html>
```

<Warning>
  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.
</Warning>

<Tip>
  Replace `YOUR_SITE_ID` with your real site ID, and copy the full snippet from **Settings → Tracking** if you've toggled any options.
</Tip>

## 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](/docs/configure-tinyanalytics-tracking-script#track-single-page-apps) 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](/docs/verify-tinyanalytics-installation) for the full check.

<Check>
  Your install is working when your own visit appears in **Realtime** in your dashboard.
</Check>

## Related

<Columns cols={2}>
  <Card title="Install on any platform" icon="puzzle-piece" href="/docs/integrations/install-website-analytics">
    The universal method and other platforms.
  </Card>

  <Card title="Configure the tracking script" icon="sliders" href="/docs/configure-tinyanalytics-tracking-script">
    Every `data-*` option you can set.
  </Card>

  <Card title="Track custom events" icon="hand-pointer" href="/docs/custom-event-tracking">
    Measure signups, clicks, and downloads.
  </Card>

  <Card title="Verify your setup" icon="circle-check" href="/docs/verify-tinyanalytics-installation">
    Confirm tracking works.
  </Card>
</Columns>


## Related topics

- [Angular Analytics Integration](/docs/integrations/angular-analytics.md)
- [Gatsby Analytics Integration](/docs/integrations/gatsby-analytics.md)
- [Vue Analytics Integration](/docs/integrations/vue-analytics.md)
