SvelteKit
Add the Lienks snippet to src/app.html.
Before you start
Create your site and copy its site ID first (see Quick start).
Add the snippet
Open src/app.html and add the snippet inside the <head>, before %sveltekit.head%:
<head>
<meta charset="utf-8" />
<script defer src="https://app.lienks.com/a.js" data-site="YOUR_SITE_ID"></script>
%sveltekit.head%
</head> Page views in your app
SvelteKit changes pages through the History API, so page changes are counted automatically. Page changes done with replaceState are not counted.
Track a custom event
Call window.lienks?.event('signup_clicked') wherever something should be counted. More in Custom events.
<button onclick={() => window.lienks?.event('signup_clicked')}>Sign up</button> In Svelte 4 the attribute is on:click.
In TypeScript projects, add Window to the global declarations in src/app.d.ts:
declare global {
interface Window {
lienks?: { event: (eventName: string) => void };
}
} Check that it works
Open your site. The first pageview shows up in the dashboard. If nothing arrives, see Troubleshooting.