Overview
TheuseAnalytics hook (alias for useMentiqAnalytics) provides access to all core analytics tracking methods. It must be used within a MentiqAnalyticsProvider.
Usage
Returns
Track custom events with optional propertiesSignature:
(event: string, properties?: EventProperties) => voidTrack page views with optional page propertiesSignature:
(properties?: PageProperties) => voidIdentify users and update their traitsSignature:
(userId: string, properties?: UserProperties) => voidReset the analytics instance and clear user dataSignature:
() => voidManually flush queued events to the serverSignature:
() => Promise<void>Track custom errors or exceptionsSignature:
(error: string | Error, properties?: EventProperties) => voidDirect access to the full analytics instance with all methods and propertiesProvides access to advanced methods like
getSessionId(), getUserId(), trackFeatureUsage(), and subscription tracking.Type Definitions
EventProperties
PageProperties
UserProperties
Notes
This hook must be used within a
MentiqAnalyticsProvider. It will throw an error if used outside the provider context.Related Hooks
- useErrorTracking - Track JavaScript errors and exceptions
- useSessionTracking - Access session data and metrics
- usePerformanceTracking - Track performance metrics