On this page
Initialize the SDK
Last updated
Call vt.init() once with your project token and recommended options. Run as early as possible in the page lifecycle.
Call vt.init() once with your project token. Run it as early as possible — in the inline script block, beforeInteractive in Next.js, or your app entry before paint. Calls before init() are no-ops; calls after queue until the SDK boots.
#Inline script
Add vt.init() in the same <script> block as the stub (or immediately after it):
<script>
/* … stub loader … */
vt.init('YOUR_PROJECT_TOKEN', {
api_host: 'https://www.vtilt.com',
autocapture: true,
capture_pageview: true,
capture_pageleave: true,
persistence: 'localStorage',
})
</script>html
#npm / pnpm
import { vt } from '@v-tilt/browser'
vt.init('YOUR_PROJECT_TOKEN', {
api_host: 'https://www.vtilt.com',
autocapture: true,
capture_pageview: true,
capture_pageleave: true,
persistence: 'localStorage',
})
// Optional: expose globally so window.vt examples in these docs work as-is
if (typeof window !== 'undefined') window.vt = vttypescript
The default snippet loads array.js (core only). Chat and session recording lazy-load separate files — see Script bundles.
#Recommended init options
| Option | Required | Typical value | Why you might change it |
|---|---|---|---|
autocapture | no | true | Disable for highly custom event tracking; pass an object to scope what's captured. |
capture_pageview | no | true | Disable when you handle pageviews manually (e.g. exotic SPA frameworks). |
capture_pageleave | no | true | $pageleave events power engagement metrics — keep on unless you have a reason to drop them. |
persistence | no | localStorage | Use cookie for cross-subdomain identity, or memory to disable client-side persistence. |
api_host | no | https://www.vtilt.com | Replace with your own origin if you reverse-proxy or self-host; omit for same-origin relative URLs. |
#Update config at runtime
vt.updateConfig(patch) changes SDK settings after init(). Top-level keys shallow-merge; nested chat deep-merges.
vt.updateConfig({ autocapture: false })
vt.updateConfig({
chat: {
bubble: { offset: { bottom: 88, right: 24 } },
},
})typescript
See Chat widget and Remote configuration for feature-specific options.
#Next steps
- Identify users on every authenticated page load — not only at login.
- Track events with
vt.capture()for domain actions. - Verify events in Debug View.