Promise<Context>.
User identification
Event tracking
Page tracking
analytics.page() on route changes:
Documentation Index
Fetch the complete documentation index at: /llms.txt
Use this file to discover all available pages before exploring further.
Identify users, track events, and manage identity with the browser SDK.
Promise<Context>.
// Identify with user ID only
analytics.identify('user@example.com')
// Identify with traits
analytics.identify('user@example.com', {
first_name: 'John',
last_name: 'Doe',
email: 'user@example.com',
plan: 'premium',
created_at: new Date().toISOString()
})
// With options and callback
analytics.identify(
'user@example.com',
{ email: 'user@example.com' },
{},
() => {
console.log('User identified successfully')
}
)
analytics.track('button_clicked')
analytics.track('purchase_completed', {
product_id: '123',
product_name: 'Widget',
price: 29.99,
currency: 'USD',
quantity: 1
})
analytics.track('signup_completed', { method: 'email' }, {}, () => {
console.log('Event tracked successfully')
})
analytics.page()
analytics.page('Home')
analytics.page('Docs', 'Getting Started')
analytics.page('Product Detail', {
product_id: '123',
category: 'Electronics',
url: window.location.href,
referrer: document.referrer
})
analytics.page() on route changes:
window.addEventListener('popstate', () => {
analytics.page()
})
analytics.screen('Dashboard', {
user_type: 'premium'
})
analytics.group('company-123', {
name: 'Acme Inc',
plan: 'enterprise',
employees: 100
})
analytics.alias('user@example.com', 'anon-123')
analytics.reset()
function handleLogout() {
analytics.reset()
// ... rest of logout logic
}