Installation
Quick start
Add Outlit to your base layout:.env:
Alternative: inline script
Use an inline script if you prefer an inline setup:Tracking events
Track events in Astro components:With client directives
Use client directives for interactive components:Framework islands
React island
Vue island
Svelte island
Identifying users
Identify users after authentication:Auth state management
For apps with authentication, usesetUser() and clearUser() to sync user identity:
setUser() ensures the user identity persists across page navigations and is properly set when users return to your site already logged in.
View transitions
Track navigation with Astro’s View Transitions:API routes
Track events from API endpoints:SSR pages
For SSR pages, ensure tracking runs client-side:Content collections
Track interactions with content:Activation event
Track your value milestone as an ordinary event once it succeeds:Consent management
The defaultautoTrack: "auto" mode already keeps tracking off for visitors in regions that require opt-in consent (EEA, UK, Switzerland, or unknown); the example below uses autoTrack: false to wait for an explicit consent signal unless a previous opt-in is stored.
Handle user consent:
Environment variables
Configure environment variables:TypeScript support
Full TypeScript support is included:Next steps
Server-side tracking
Track events from your backend
Identity resolution
Learn how visits and events link to people
npm package
Full API reference
React integration
Use Outlit with React
