Overview
TheuseAnalytics hook (alias for useMentiqAnalytics) provides access to all core analytics tracking methods. It must be used within a MentiqAnalyticsProvider.
Usage
Returns
function
Track custom events with optional propertiesSignature:
(event: string, properties?: EventProperties) => voidfunction
Track page views with optional page propertiesSignature:
(properties?: PageProperties) => voidfunction
Identify users and update their traitsSignature:
(userId: string, properties?: UserProperties) => voidfunction
Reset the analytics instance and clear user dataSignature:
() => voidasync function
Manually flush queued events to the serverSignature:
() => Promise<void>function
Track custom errors or exceptionsSignature:
(error: string | Error, properties?: EventProperties) => voidAnalyticsInstance
Direct 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