Integrations
Svelte (Vite, client-side)
Add Databuddy once and every page and route change in your Svelte app is recorded. Using SvelteKit? Follow the SvelteKit guide.
Add Databuddy
Your Client ID is in the dashboard under your website's Settings → General. Navigation through the History API is tracked automatically, so svelte-routing needs no extra code.
Track hash routes
Routers that use #/ URLs, such as svelte-spa-router, need hash changes turned on:
Track an event
<script>
import { track } from "@databuddy/sdk";
</script>
<button onclick={() => track("plan_selected", { plan: "pro" })}>
Choose Pro
</button>track() works with either install. Calls made before the tracker loads wait for it.
Track clicks without code
Turn on attributes: true in autocapture, or data-track-attributes on the script tag, then name elements:
<a href="/pricing" data-track="pricing_link_click" data-location="header">View pricing</a>Each click sends a pricing_link_click event with location: "header".
Related
How is this guide?