Overview
TheuseOnboardingTracker hook creates an OnboardingTracker instance that helps track user progress through onboarding flows. It provides methods for starting, completing, skipping steps, and monitoring overall progress.
Usage
Parameters
The analytics instance from
useAnalytics(). Returns null if analytics is not available.Configuration object for the onboarding flow
Array of onboarding stepsEach step has:
name(string): Unique identifier for the stepindex(number): Order of the step (0-based)required(boolean, optional): Whether step is required for completion
Whether to automatically track step progression (not currently implemented)
Returns
Returns an
OnboardingTracker instance with the following methods, or null if analytics is unavailable.Methods
start()
Start the onboarding process and track the “onboarding_started” event. Signature:start(properties?: Record<string, any>): void
"onboarding_started"
total_steps: Number of steps in the flow- Any additional properties passed
completeStep()
Mark a step as completed and track progress. Signature:completeStep(stepName: string, properties?: Record<string, any>): void
"onboarding_step_completed"
step_name: Name of the completed stepstep_index: Index of the steprequired: Whether the step was requiredsteps_completed: Total steps completed so fartotal_steps: Total steps in the flowprogress: Completion percentage (0-100)time_since_start: Milliseconds since onboarding started- Any additional properties passed
skipStep()
Skip an optional step (only works for non-required steps). Signature:skipStep(stepName: string, reason?: string): void
"onboarding_step_skipped"
step_name: Name of the skipped stepstep_index: Index of the stepreason: Reason for skipping (defaults to “not_specified”)steps_completed: Steps completed so fartotal_steps: Total steps in the flow
complete()
Mark the entire onboarding flow as complete. Signature:complete(properties?: Record<string, any>): void
"onboarding_completed"
steps_completed: Total steps completedtotal_steps: Total steps in the flowcompletion_rate: Percentage of steps completed (0-100)duration_ms: Total time in millisecondsduration_seconds: Total time in seconds- Any additional properties passed
abandon()
Mark onboarding as abandoned and track where the user dropped off. Signature:abandon(reason?: string): void
"onboarding_abandoned"
step_name: Current step where user abandonedstep_index: Index of current stepsteps_completed: Steps completed before abandoningtotal_steps: Total steps in flowprogress: Completion percentage when abandonedduration_ms: Time spent before abandoningreason: Reason for abandoning (defaults to “not_specified”)
getProgress()
Get current onboarding progress. Signature:getProgress(): ProgressObject
isStepCompleted()
Check if a specific step has been completed. Signature:isStepCompleted(stepName: string): boolean
reset()
Reset the tracker to initial state. Signature:reset(): void
Type Definitions
OnboardingConfig
OnboardingStep
Examples
Multi-Step Wizard
Progress Bar Display
Conditional Step Logic
Automatic Completion
When all steps are completed (via
completeStep()), the tracker automatically calls complete() to track the “onboarding_completed” event.Notes
The tracker maintains state in memory. If you need persistence across page refreshes, store progress in localStorage or your backend.
Related Hooks
- useAnalytics - Required to get the analytics instance
- useSessionTracking - Track session metrics during onboarding