Skip to content
Inqetra
Documentation

Add analytics to SvelteKit

The app template, not a component — it is the one file every route renders into.

The tag goes in src/app.html, the template every route renders into — not in a component. A component mounts and unmounts with its route, and the tracker only wants loading once.

Put it after %sveltekit.head% so SvelteKit's own tags come first. Client-side navigation needs nothing extra: the tracker patches the History API itself, so a route change is recorded without you calling anything.

src/app.html
<!-- The app template every route renders into. -->
<head>
  %sveltekit.head%

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

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.