Overview
The init functions provide a simplified API for using MentiQ Analytics without managing an Analytics instance directly. These functions operate on a shared default instance.Initialization
init
Initialize MentiQ Analytics with your configuration and return the Analytics instance.Configuration object for the Analytics instance
The initialized Analytics instance
Example
getInstance
Get the default Analytics instance.The default Analytics instance, or null if not initialized
Example
Core Tracking
track
Track a custom event using the default instance.Name of the event to track
Additional properties to attach to the event
Example
Make sure to call
init() before using track() or you’ll see a warning in the console.page
Track a page view using the default instance.Additional properties to attach to the page view
Example
identify
Identify a user using the default instance.Unique identifier for the user
User traits and properties
Example
alias
Alias a user ID to another ID using the default instance.New user ID
Previous user ID (optional)
Example
reset
Reset the analytics state using the default instance.Example
flush
Manually flush the event queue using the default instance.Promise that resolves when flush is complete
Example
Session Recording
startRecording
Start session recording using the default instance.Example
stopRecording
Stop session recording using the default instance.Example
pauseRecording
Pause session recording using the default instance.Example
resumeRecording
Resume session recording using the default instance.Example
isRecordingActive
Check if recording is currently active using the default instance.True if recording is active, false otherwise
Example
Feature Tracking
trackFeatureUsage
Track usage of a specific feature using the default instance.Name of the feature
Additional properties
Example
Funnel Tracking
startFunnel
Start tracking a conversion funnel using the default instance.Name of the funnel
Additional properties
Example
advanceFunnel
Advance to the next step in a funnel using the default instance.Name of the funnel
Name of the current step
Additional properties
Example
completeFunnel
Mark a funnel as completed using the default instance.Name of the funnel
Additional properties
Example
abandonFunnel
Mark a funnel as abandoned using the default instance.Name of the funnel
Reason for abandonment
Additional properties
Example
trackFunnelStep
Track a specific funnel step using the default instance.Name of the funnel
Name of the step
Index of the step (0-based)
Additional properties
getFunnelState
Get the current state of a funnel using the default instance.Name of the funnel
Current funnel state or null if funnel not found
Session & Engagement
getActiveSession
Get detailed session metrics using the default instance.Current session data or null if not initialized
Example
calculateEngagementScore
Calculate the current engagement score using the default instance.Engagement score from 0-100, or 0 if not initialized
Example
Subscription Tracking
trackSubscriptionStarted
Track when a subscription starts using the default instance.Subscription properties
Example
trackSubscriptionUpgraded
Track when a subscription is upgraded using the default instance.trackSubscriptionDowngraded
Track when a subscription is downgraded using the default instance.trackSubscriptionCanceled
Track when a subscription is canceled using the default instance.trackSubscriptionPaused
Track when a subscription is paused using the default instance.trackSubscriptionReactivated
Track when a subscription is reactivated using the default instance.trackTrialStarted
Track when a trial starts using the default instance.trackTrialConverted
Track when a trial converts using the default instance.trackTrialExpired
Track when a trial expires using the default instance.trackPaymentFailed
Track when a payment fails using the default instance.trackPaymentSucceeded
Track when a payment succeeds using the default instance.getSubscriptionData
Get stored subscription data using the default instance.Subscription data or null if not available
calculateChurnRisk
Calculate churn risk using the default instance.Churn risk metrics or null if not initialized