Source: https://usedataowl.com/docs/astro
Markdown source: https://usedataowl.com/docs/astro.md
Description: Add <4KB privacy-first web analytics, revenue tracking, and error monitoring to your Astro website with full support for Astro View Transitions.

# How to Add Lightweight Web Analytics to Astro Sites

Paste the script into the `<head>` of your shared layout, usually `src/layouts/Layout.astro`. Add `is:inline` so Astro doesn't bundle it. Pages that use view transitions are tracked too.

```astro title="src/layouts/Layout.astro"
<script is:inline
  defer
  data-website-id="YOUR_SITE_ID"
  src="https://usedataowl.com/js/script.cookies.js"
></script>
```

> Replace `YOUR_SITE_ID` with your site ID from the dashboard.

## Verify installation

After you deploy:

- Visit your live website.
- Open the **Realtime** page of your [DataOwl dashboard](/dashboard). Your visit shows up within a second, and the setup page says "Receiving events".

> DataOwl ignores localhost so you don't count your own development traffic. Add `data-allow-localhost="true"` to the tag to test locally. More options are in the [script configuration reference](/docs/script-configuration).
