Docs

Svelte & SvelteKit

One script tag covers the whole app, including client-side navigations. Takes about two minutes.

SvelteKit

Add the script inside the <head> of src/app.html (the app template shared by every route):

<script defer src="http://localhost:3000/analytics.js" data-website-id="YOUR_TRACKING_ID"></script>

Svelte (Vite)

Add the same tag to the index.html in your project root, just before </head>:

<script defer src="http://localhost:3000/analytics.js" data-website-id="YOUR_TRACKING_ID"></script>

Client-side routing

Nothing else to do. SvelteKit and Svelte Router navigations are tracked automatically.

Track custom events

Call the global function from any component:

window.lumen?.("Signup", { plan: "pro" });

Verify

Reload your site and open the site's real-time view in your dashboard. The pageview should appear within seconds. If not, see Troubleshooting.