Skip to main content

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.
AnalyticsConfig
required
Configuration object for the Analytics instance
Analytics
The initialized Analytics instance

Example

getInstance

Get the default Analytics instance.
Analytics | null
The default Analytics instance, or null if not initialized

Example

Core Tracking

track

Track a custom event using the default instance.
string
required
Name of the event to track
any
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.
any
Additional properties to attach to the page view

Example

identify

Identify a user using the default instance.
string
required
Unique identifier for the user
any
User traits and properties

Example

alias

Alias a user ID to another ID using the default instance.
string
required
New user ID
string
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<void>
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.
boolean
True if recording is active, false otherwise

Example

Feature Tracking

trackFeatureUsage

Track usage of a specific feature using the default instance.
string
required
Name of the feature
any
Additional properties

Example

Funnel Tracking

startFunnel

Start tracking a conversion funnel using the default instance.
string
required
Name of the funnel
any
Additional properties

Example

advanceFunnel

Advance to the next step in a funnel using the default instance.
string
required
Name of the funnel
string
required
Name of the current step
any
Additional properties

Example

completeFunnel

Mark a funnel as completed using the default instance.
string
required
Name of the funnel
any
Additional properties

Example

abandonFunnel

Mark a funnel as abandoned using the default instance.
string
required
Name of the funnel
string
Reason for abandonment
any
Additional properties

Example

trackFunnelStep

Track a specific funnel step using the default instance.
string
required
Name of the funnel
string
required
Name of the step
number
required
Index of the step (0-based)
any
Additional properties

getFunnelState

Get the current state of a funnel using the default instance.
string
required
Name of the funnel
any
Current funnel state or null if funnel not found

Session & Engagement

getActiveSession

Get detailed session metrics using the default instance.
any
Current session data or null if not initialized

Example

calculateEngagementScore

Calculate the current engagement score using the default instance.
number
Engagement score from 0-100, or 0 if not initialized

Example

Subscription Tracking

trackSubscriptionStarted

Track when a subscription starts using the default instance.
any
required
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.
any
Subscription data or null if not available

calculateChurnRisk

Calculate churn risk using the default instance.
any
Churn risk metrics or null if not initialized

Example

Complete Example