Web SDK
Browser-side event tracking for web applications.
Installation
bash: npm install @vanta-dev/web
npm install @vanta-dev/webSetup
typescript: import { Vanta } from '@vanta-dev/web'
import { Vanta } from '@vanta-dev/web'
const vanta = new Vanta({
apiKey: 'vk_...'
})Sending events
typescript: await vanta.track({
await vanta.track({
event: 'page.view',
data: {
path: window.location.pathname
}
})The Web SDK automatically captures browser context (URL, device, browser, screen size) for every event.
Identifying users
typescript: await vanta.identify({
await vanta.identify({
userId: 'user_123',
properties: {
email: 'sarah@example.com'
}
})After calling identify, the user ID is attached to all subsequent events.
Page views
typescript: await vanta.page('Pricing')
await vanta.page('Pricing')Sends a page.view event with the current URL, path, search, hash, and document title.
Configuration
typescript: const vanta = new Vanta({
const vanta = new Vanta({
apiKey: 'vk_...',
apiUrl: 'https://vantapi.pancake.wtf', // optional
flushInterval: 10000, // ms between flushes
flushSize: 20 // events per batch
})