Skip to main content

useAnalytics

The useAnalytics hook can be used to access a Provider's track function. It's useful in situations where analytics isn't provided by default such as mounting a component, other lifecycle methods, or with custom behavior.

The following example shows how to use the hook to track when a component mounts.

In these examples

is a component internal to this documentation that provides an analytics Provider.

Result
Loading...
Live Editor

Tracking show/hide in a Modal

Result
Loading...
Live Editor