Skip to main content

Function: useAnalytics()

useAnalytics(): UseAnalyticsReturn
Defined in: react/index.ts:160 Component-level access to the analytics surface. Does not subscribe to React state — calls to track are pure side effects, so the hook is safe to call once per component without causing re-renders.

Returns

UseAnalyticsReturn

Example

const { track } = useAnalytics();
<button onClick={() => track("cta_clicked", { id: "hero" })}>Click</button>