Sveltekit

adding peasy to your Sveltekit project is straightforward. Simply add the snippet below to your main +layout.svelte file to include the peasy.js script in your project.

basic betup

in your main layout file, add the following code:

<svelte:head>
	<script src="https://cdn.peasy.so/peasy.js" data-website-id="<website_id>" async></script>
</svelte:head>

that's it! once the script is added, peasy will automatically start tracking user interactions. navigate through your app, and events will appear in your dashboard.

TypeScript support

to enable TypeScript support for peasy's script methods, add the following type declarations to your app.d.ts file:

// app.d.ts

declare global {
	interface Window {
		peasy?: {
			init: () => void;
			track: (event: string, data: Record<string, any>) => void;
			page: () => void;
			setProfile: (id: string, data: Record<string, unknown>) => void;
			disableTracking: () => void;
		};
	}
}

with this in place, you can now use the peasy object in your project with full TypeScript type hints.

try web analytics
you'll actually love.

sign up for peasy today. free to start and while below 3000 events per month, then $9 monthly.