Installation
Initialization
Initialize the tracker once at app startup, typically in your entry point:Configuration options
string
required
Your organization’s public key from Settings → Website Visitors.
string
default:"https://app.outlit.ai"
The API endpoint for sending events. Override for self-hosted or proxy setups.
boolean
default:"true"
Automatically track pageviews on navigation.
boolean
default:"true"
Automatically capture form submissions.
string[]
Additional field names to exclude from form capture.
number
default:"5000"
How often to send batched events (in milliseconds).
boolean | "auto"
default:"\"auto\""
Controls when tracking starts.
"auto" (default) asks the Outlit edge endpoint whether the visitor’s region requires opt-in consent: tracking enables automatically outside the EEA, UK, and Switzerland, and stays off in those regions or when the region can’t be determined. The check fails closed — on a network error or timeout, tracking stays off. true enables tracking immediately on init; false waits for enableTracking(). A persisted opt-in or opt-out decision always takes precedence, and nothing is written to cookies or localStorage until tracking is enabled.boolean
default:"true"
Automatically identify users when they submit forms containing an email field. Extracts email and name using field name heuristics. Set to
false to call identify() manually. See Auto-identify for details.boolean
default:"true"
Track engagement metrics (active time on page). Emits engagement events on page exit and SPA navigation capturing how long users actively engaged with each page.
number
default:"30000"
Idle timeout in milliseconds for engagement tracking. After this period of no user interaction, the user is considered idle and active time stops accumulating.
boolean
default:"true"
Track booking events from calendar embeds (Cal.com, Calendly). Fires a calendar event when bookings are detected.
Consent management
The defaultautoTrack: "auto" mode already keeps tracking off for visitors in the EEA, UK, and Switzerland (or when the region is unknown). Have your consent management platform call enableTracking() when the user accepts — that call is what records opt-in consent.
To wait for enableTracking() instead — unless a previous opt-in is already stored — initialize with autoTrack: false:
Check tracking status
API reference
outlit.init(options)
Initialize the tracker. Must be called before other methods.
outlit.track(eventName, properties?)
Track a custom event.
string
required
A descriptive name for the event. Use
snake_case.Record<string, string | number | boolean | null>
Additional data to attach to the event.
outlit.identify(options)
Identify the current visitor. Links their anonymous history to a known profile.
string
The visitor’s email address. Primary identifier.
string
Your internal user ID (from Supabase, Auth0, etc.).
Record<string, string | number | boolean | null>
Additional properties about the user.
string
Your system-owned customer/account/workspace ID. Send this when the visitor belongs to a known account.
Record<string, string | number | boolean | null>
Additional properties about the customer/account profile.
outlit.setUser(identity)
Set the current user identity. Ideal for SPA applications where you know the user’s identity after authentication. Can be called before tracking is enabled—the identity is queued and applied when enableTracking() is called.
Both
setUser() and identify() link the visitor to a known profile. The difference is setUser() can be called before tracking is enabled (identity is queued), while identify() requires tracking to be enabled first.outlit.clearUser()
Clear the current user identity. Call this when the user logs out.
Activation event
Track your value milestone as an ordinary event once it succeeds:outlit.getInstance()
Get the singleton tracker instance.
outlit.enableTracking()
Enable tracking after consent. This is the call a consent tool makes to grant opt-in — it’s only needed when autoTrack: false was set, or when autoTrack: "auto" resolved to a region that requires consent.
outlit.disableTracking()
Disable tracking and flush any pending events. Use this when a user declines or revokes consent.
outlit.isTrackingEnabled()
Check if tracking is currently enabled.
TypeScript support
The package is written in TypeScript and includes full type definitions:Framework examples
Next.js (App Router)
Vue.js
Svelte
Advanced usage
Manual flush
Force immediate sending of queued events:Shutdown
Shut down gracefully the tracker (flushes remaining events):Access visitor ID
Get the current visitor’s ID for server-side correlation (returnsnull until tracking is enabled):
Engagement tracking
Engagement tracking captures how long users actively spend on each page. It’s enabled by default and works automatically.How it works
- Active time is tracked when the page is visible and the user is interacting (mouse movement, clicks, scrolling, typing)
- Idle detection pauses active time after 30 seconds of no interaction (configurable via
idleTimeout) - Engagement events are automatically sent when the user navigates to a new page or leaves the site
Engagement data
Each engagement event includes:Disabling engagement tracking
Next steps
React integration
Use the React provider and hooks
Server-side tracking
Track events from your backend
