# Track Hooks

## `useIgTrack()`

Required to gather analytics data. This hook runs client-side and is exported from the framework-specific entry points (for example, `@intelligems/headless/next-clientside`, `@intelligems/headless/next-clientside-app-directory`, `@intelligems/headless/gatsby`, `@intelligems/headless/pack`, and `@intelligems/headless/hydrogen`).

It wires up:

* Page view tracking
* Cart attribute updates via `useIgCart`
* Custom events setup via `useIgCustomEvents`
* GA4 variation tracking via `useIgGaTrack`

The host site should provide each prop in whichever way best suits the site integration.

<pre class="language-typescript"><code class="lang-typescript"><strong>interface UseIgTrackProps {
</strong>  cartOrCheckoutToken?: string | null | Promise&#x3C;string | null>;
  country?: string;
  currency?: string;
  location?: {
    pathname: string;
    search: string;
    hash: string;
    href: string;
    origin: string;
    hostname: string;
  };
}

<strong>const useIgTrack = (props: UseIgTrackProps) => void
</strong></code></pre>

`location` is only used by the Hydrogen hook to override `window.location`.

## `useIgGaTrack()`

Optional standalone hook for GA4 variation tracking if you are not using `useIgTrack()`.

## `useIgCustomEvents()`

Optional standalone hook for initializing `window.igEvents` if you are not using `useIgTrack()`.

## `useIgIntegrations()`

Use this hook to send variation assignments to supported analytics integrations (Clarity, Hotjar, Heatmap).

```typescript
import type { HeadlessSupportedIntegration } from "@intelligems/ig-types";

useIgIntegrations(["Clarity", "Hotjar"]);
```

## `useIgIsIntegration()`

Returns `true` when the current session is in Integration Mode.
