Skip to content

Install Statsdot on SvelteKit

Updated October 18, 2026

Add the script to the <head> of src/app.html, next to %sveltekit.head%:

<head>
  <meta charset="utf-8" />
  %sveltekit.head%
  <script defer data-domain="yoursite.com" src="https://statsdot.com/js/script.js"></script>
</head>

SvelteKit changes pages with the browser's history API, which Statsdot listens to, so every client-side navigation counts as a pageview. Nothing else to configure.

The script does nothing on localhost, so development visits are not counted. For a staging domain, only add the site you want to measure in Statsdot: hits from other domains are ignored.

Track events with data-statsdot-event="Signup" on a button, link or form, or window.statsdot?.track('Signup') in a component. See Events and goals.