Overview
The MentiQ Analytics SDK provides comprehensive user identification capabilities, allowing you to track both anonymous and identified users, merge user profiles, and enrich user data with custom traits.User Identity Types
The SDK manages three types of user identifiers:- User ID: Unique identifier for logged-in users
- Anonymous ID: Automatically generated for all users
- Session ID: Unique identifier for each session
Anonymous Tracking
Anonymous tracking is automatic - no configuration needed:- Generated on first visit
- Stored in
localStorageasmentiq_anonymous_id - Persists across sessions and page reloads
- Included automatically with all events
Identifying Users
Basic User Identification
Callidentify() when a user logs in or signs up:
string
required
Unique identifier for the user (e.g., database ID, UUID)
Identification with User Traits
Enrich user profiles with additional information:string
required
Unique identifier for the user
UserProperties
Object containing user traits. Can include:
email: User email address (automatically detected from auth if not provided)name: User full namesubscription: Subscription properties (see Subscription Tracking)- Custom properties: Any additional user attributes
Managing User IDs
Set User ID
Set or update the user ID without sending an identify event:Get User ID
Retrieve the current user ID:Initialize with User ID
Set user ID during initialization:User Aliasing
Alias allows you to merge user identities, typically when transitioning from anonymous to identified:string
required
The new user ID (typically the logged-in user ID)
string
The previous user ID or anonymous ID. If omitted, uses the current user ID.
Automatic Aliasing Flow
Resetting User Identity
Reset user identity when logging out:- Clears the user ID
- Clears event queue
- Generates a new anonymous ID
- Starts a new session
- Preserves stored anonymous tracking
Automatic Email Detection
The SDK automatically detects user email from popular authentication providers:- NextAuth / Auth.js
- Supabase Auth
- Firebase Auth
- Clerk
- Auth0
- Stored in
localStorageasmentiq_user_email - Automatically included with all events
- Used for user attribution and segmentation
Manual Email Override
Manually set email to override auto-detection:Subscription Tracking
Track user subscription status for SaaS metrics:Subscription Properties
string
required
Subscription status:
"active", "trialing", "past_due", "canceled", "paused", "incomplete", "incomplete_expired", or "unpaid"string
Unique plan identifier
string
Human-readable plan name
string
Plan tier:
"free", "starter", "pro", "enterprise", etc.number
Monthly Recurring Revenue in cents (e.g., 2900 for $29.00)
number
Annual Recurring Revenue in cents
string
Currency code (e.g.,
"usd", "eur")string
Billing cycle:
"day", "week", "month", or "year"string
Payment provider:
"stripe", "paddle", "chargebee", "manual", or customAutomatic Subscription Detection
The SDK automatically detects subscriptions from:- Stripe.js
- Paddle.js
- Chargebee.js
PCI Compliance
The SDK automatically ensures PCI compliance:User Trait Enrichment
All events automatically include user traits:User Persistence
Storage Locations
User data is persisted in browser storage:Cross-Domain Tracking
For cross-domain tracking, manually pass user identifiers:Best Practices
Anonymous and identified user data is automatically merged when you call
alias(), preserving the complete user journey.