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.

interface UseIgTrackProps {
  cartOrCheckoutToken?: string | null | Promise<string | null>;
  country?: string;
  currency?: string;
  location?: {
    pathname: string;
    search: string;
    hash: string;
    href: string;
    origin: string;
    hostname: string;
  };
}

const useIgTrack = (props: UseIgTrackProps) => void

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

useIgIsIntegration()

Returns true when the current session is in Integration Mode.

Last updated