afterNavigate() can observe every completed route.
Do not add a raw Bily script tag alongside the SDK.
Install Bily
Add Bily to Svelte
For a Svelte application built with Vite, store the complete tracking URL in a public build variable..env
src/bily.ts
src/main.ts
window.location.href before sending a later PageView.
Add Bily to SvelteKit
Use a public static environment value when the URL belongs in the browser bundle..env
afterNavigate() runs when the component first mounts and after later SvelteKit navigations.
src/lib/BilyTracking.svelte
src/routes/+layout.svelte
<slot /> and add only <BilyTracking /> beside it.
The first afterNavigate() call starts the SDK, so the browser script owns the initial page. Every later callback sends at most one event for the final URL.
Track successful actions
src/lib/SubscribeButton.svelte
Replace a bundled URL
BothVITE_ and $env/static/public values are included in built browser assets. Rebuild and redeploy after Bily validates a customer subdomain and gives you a new complete URL.
Verify Svelte tracking
Confirm one initial page, one event per later URL, and no duplicate script.
Replace the tracking URL
Change the complete public value through one controlled deployment.