SvelteKit renders every page from one template, src/app.html, which makes it one of the easiest frameworks to instrument. The tag goes there once and covers server-rendered, prerendered and client-navigated pages alike.
What you get
- Every page counted. SvelteKit changes pages through the History API, which the script follows. Preloading a link on hover is not a pageview; only the navigation is.
- Form goals that survive
use:enhance. A<form>withdata-reveata-goalcounts its goal on submit, enhanced forms included. - Revenue attribution from form actions and endpoints that create checkouts.
- Any adapter: Node, Vercel, Netlify, Cloudflare or static.
How to install it
In src/app.html, paste the snippet in <head>, before %sveltekit.head%:
<head>
<script defer data-website-id="ws_your_tracking_id" src="https://reveata.com/js/script.js"></script>
%sveltekit.head%
</head>The template is described in SvelteKit's project structure docs (opens in a new tab). With TypeScript, declare reveata?: (command: string, ...args: unknown[]) => void on Window in src/app.d.ts.
Goals
<button onclick={() => window.reveata?.('goal', 'start_trial', { plan: 'pro' })}>Start free trial</button>
<form method="POST" use:enhance data-reveata-goal="newsletter">…</form>See custom goals for properties.
Linking payments to visits
When a form action creates the checkout, send window.reveata.metadata() with the form in hidden inputs named reveata_visitor_id and reveata_session_id, then copy them into the checkout metadata in the action. For Stripe, that is the Checkout Session's metadata (Stripe Checkout attribution); other providers take the same keys in their custom data (connect a payment provider). The action can also read Reveata's _dt_v and _dt_s cookies directly.