Add cookie-free, GDPR-compliant analytics to your Svelte app in under 2 minutes. No consent banner required. Uses onMount to safely inject the Beam script in the browser only.
No credit card required and setup in minutes
Replace YOUR_SITE_ID with your Beam site ID from the dashboard.
<!-- src/App.svelte -->
<script>
import { onMount } from 'svelte'
onMount(() => {
// onMount only runs in the browser — safe for SSR-aware Svelte builds
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)
})
</script>
<slot />
Svelte's onMount lifecycle only runs in the browser, never during server-side rendering. This keeps document and window always available when Beam initialises.
<!-- index.html (Vite + Svelte) -->
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<script
defer
src="https://beam-privacy.com/js/beam.js"
data-site-id="YOUR_SITE_ID">
</script>
</head>
<body>
<div id="app"></div>
<script type="module" src="/src/main.ts"></script>
</body>
</html>
For plain Vite + Svelte projects (without SvelteKit), placing the script in index.html is the simplest approach — no component logic needed.
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 Svelte app.
Beam's script is tiny and deferred, so it adds no noticeable impact to Svelte's already-lean bundle.
Using onMount ensures Beam only runs in the browser — no server-side errors or hydration mismatches.
See top pages, referrers, countries, and devices without the complexity of GA-style report sprawl.
Start free, validate your first pageview, and then scale when traffic grows.