Skip to main content
Version: Svelte SDK

How Screeb works

Tag loadingโ€‹

When setScreebContext is called with shouldLoad: true (the default), it calls Screeb.load() immediately when your app boots in the browser. This injects the Screeb tag script into the DOM and connects to Screeb's servers.

Initializationโ€‹

Initialization (Screeb.init()) links the current browser session to a channel and optionally to a user identity. If autoInit: true is set in the provider config, this happens automatically after loading.

If autoInit is false (the default), you must call init() manually:

const { init } = useScreeb();
await init("<YOUR-CHANNEL-ID>", "<USER-ID>");

Targeting engineโ€‹

Once initialized, Screeb continuously evaluates targeting rules in the background. When a rule matches (e.g. "user visited the pricing page 3 times"), the corresponding survey or message is triggered automatically โ€” no code needed on your side for standard targeting.

User identityโ€‹

Screeb assigns an anonymous ID to every session. If you call identity(userId), subsequent sessions for the same user are linked together, enabling user-level analytics and more precise targeting.

Identity updatesโ€‹

If the user logs in or logs out after initialization, call identity(newId) or identityReset() from a component:

<script lang="ts">
import { useScreeb } from "@screeb/sdk-svelte";

const { identity, identityReset } = useScreeb();

async function onLogin(userId: string) {
await identity(userId);
}

async function onLogout() {
await identityReset();
}
</script>

Methodsโ€‹

All Screeb methods are available via the useScreeb() context helper. They return Promises and reject with a descriptive message if called before initialization.