# 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.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://headless.intelligems.io/version-1.2.16/reference/hooks/track-hooks.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
