Skip to content
Inqetra
Documentation

Add analytics to Astro

Needs is:inline, or Astro bundles the script and drops the data-site attribute.

In the layout's head, so every page using that layout is covered. Astro ships zero JavaScript by default, which makes the one script you do add worth placing deliberately.

`is:inline` is the part that matters and the part that is easy to miss. Without it Astro treats the tag as a module to process and bundle, which drops the data-site attribute — the tracker then loads with no site to report to, and the symptom is indistinguishable from having no traffic yet.

src/layouts/Layout.astro
---
// src/layouts/Layout.astro
---
<html lang="en">
  <head>
    <slot name="head" />

    <!-- Inqetra -->
    <script is:inline defer src="https://collect.inqetra.com/inqetra.js" data-site="9f1c4b2e-7a30-4d51-b8c6-2e5a0d7f3c11"></script>
  </head>
  <body><slot /></body>
</html>

Worth knowing

9f1c4b2e-7a30-4d51-b8c6-2e5a0d7f3c11 is a placeholder. Yours is issued when you add a domain and is shown in the dashboard next to the snippet.

After it is in

Load a page and check the realtime view: it counts the last five minutes, so your own visit should appear within seconds. Then custom events covers naming the things that matter to you.