Install Statsdot on Astro
Updated October 17, 2026
Add the script to the <head> of your base layout, for example src/layouts/Layout.astro. Use is:inline so Astro leaves the tag as it is instead of bundling it:
<head>
<!-- ... -->
<script is:inline defer data-domain="yoursite.com" src="https://statsdot.com/js/script.js"></script>
</head>
Astro's view transitions change the address with the browser's history API, which Statsdot listens to, so every page counts.
To skip local development, the script already does nothing on localhost. For other environments, wrap it in {import.meta.env.PROD && (...)}.
Track events with data-statsdot-event="Signup" on a button, link or form, or window.statsdot.track('Signup') in your scripts. See Events and goals.