Overview
The MentiQ Analytics SDK provides multiple methods for tracking events, user interactions, and application behavior. Events are automatically enriched with context data including user information, session details, and page metadata.Basic Event Tracking
Track Custom Events
Thetrack() method is the primary way to send custom events:
The name of the event to track
Optional object containing event properties. Values can be strings, numbers, booleans, null, or undefined.
Page Views
Track page views manually or rely on automatic tracking:Optional page properties:
title: Page titleurl: Full URLpath: URL pathreferrer: Referrer URLsearch: Query string
Feature Tracking
Track Feature Usage
Monitor which features users are engaging with:Name of the feature being used
Optional properties describing the feature usage
Funnel Tracking
Start a Funnel
Begin tracking a user journey through a conversion funnel:Advance Funnel Steps
Track progress through funnel steps:Complete a Funnel
Mark a funnel as successfully completed:Abandon a Funnel
Track funnel abandonment with optional reason:Funnels automatically abandon after 5 minutes of inactivity and track a timeout reason.
Get Funnel State
Retrieve the current state of an active funnel:Performance Tracking
Automatic Performance Tracking
Enable automatic tracking of Core Web Vitals:- Load Time
- DOM Ready Time
- First Byte Time
- DNS Lookup Time
- First Paint
- First Contentful Paint
- Largest Contentful Paint
- First Input Delay
- Cumulative Layout Shift
- Time to Interactive
Manual Performance Tracking
Track custom performance metrics:Object containing performance metrics:
loadTime: Total page load time in msdomReady: DOM ready time in msfirstPaint: First paint time in msfirstContentfulPaint: FCP in mslargestContentfulPaint: LCP in msfirstInputDelay: FID in mscumulativeLayoutShift: CLS scoretimeToInteractive: TTI in ms
Error Tracking
Automatic Error Tracking
Enable automatic tracking of JavaScript errors:- JavaScript runtime errors
- Unhandled promise rejections
Manual Error Tracking
Track custom errors:Error object or error message string
Optional properties providing error context
Advanced Event Tracking
Funnel Step Tracking
Track specific funnel steps with index:Name of the funnel
Name of the current step
Zero-based index of the step
Optional step properties
Event Context
All events are automatically enriched with contextual information:- User Context: User ID, anonymous ID, email (if available)
- Session Context: Session ID, session duration, engagement score
- Page Context: URL, path, title, referrer
- Device Context: User agent, screen resolution, timezone, locale
- Library Context: SDK name and version
- Channel Context: Acquisition channel (UTM parameters, referrer analysis)
- Subscription Context: Subscription status, plan, MRR (if available)
Event Queue Management
Check Queue Size
Flush Events Manually
Send all queued events immediately:Clear Queue
Remove all queued events without sending:Best Practices
Events are batched and sent automatically based on
batchSize and flushInterval configuration. You can manually flush events with flush() when needed (e.g., before page unload).