Add cookie-free, GDPR-compliant analytics to your SvelteKit app in under 2 minutes. No consent banner required. Uses +layout.svelte with afterNavigate to capture every client-side navigation.
No credit card required and setup in minutes
Replace YOUR_SITE_ID with your Beam site ID from the dashboard.
<!-- src/routes/+layout.svelte -->
<script>
import { onMount } from 'svelte'
import { afterNavigate } from '$app/navigation'
onMount(() => {
// Inject the Beam script once on first browser load
const script = document.createElement('script')
script.defer = true
script.src = 'https://beam-privacy.com/js/beam.js'
script.setAttribute('data-site-id', 'YOUR_SITE_ID')
document.head.appendChild(script)
})
// Fire a pageview on every SvelteKit client-side navigation
afterNavigate(({ to }) => {
window.beam?.track?.('pageview', { path: to?.url.pathname ?? window.location.pathname })
})
</script>
<slot />
onMount runs once on initial browser load. afterNavigate fires after every SvelteKit client-side route transition — keeping Top Pages accurate across your entire app without a full page reload.
<!-- src/app.html -->
<!DOCTYPE html>
<html lang="%sveltekit.lang%">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width" />
%sveltekit.head%
<script
defer
src="https://beam-privacy.com/js/beam.js"
data-site-id="YOUR_SITE_ID">
</script>
</head>
<body data-sveltekit-preload-data="hover">
<div style="display: contents">%sveltekit.body%</div>
</body>
</html>
This approach works for mostly server-rendered SvelteKit sites where full-page navigations are the norm. For SPAs with client-side routing, use the +layout.svelte approach above to capture route changes.
Use this checklist after publish so you know tracking is actually live in production.
Beam is cookie-free by design — no consent UI to build, no GDPR overhead for your SvelteKit app.
onMount keeps Beam out of server-side rendering entirely, so your SvelteKit SSR output is never affected.
afterNavigate captures every client-side navigation in SvelteKit so your Top Pages report is complete and accurate.
No PII, no fingerprinting, no ad-tech — just page-level metrics your team can act on without a consent banner.
Start free, validate your first pageview, and then scale when traffic grows.