Screen tracking
Track page transitions in your Svelte app so Screeb can evaluate URL-based and page-level targeting rules for messages and surveys.
Automatic trackingโ
Screeb automatically detects URL changes in the browser. For most Svelte and SvelteKit apps, no additional setup is needed because navigation events update window.location, which Screeb monitors.
Manual event tracking per routeโ
If you want to trigger specific Screeb events on route transitions, track page views from a layout component:
<!-- +layout.svelte -->
<script lang="ts">
import { afterNavigate } from "$app/navigation";
import { useScreeb } from "@screeb/sdk-svelte";
const { eventTrack } = useScreeb();
afterNavigate(({ to }) => {
eventTrack("page_viewed", {
path: to?.url.pathname,
});
});
</script>
<slot />