# Track Page Views

* For best analytics, this hook requires the following data to be passed in. This should be determined in whatever way necessary for your store:
  * Cart or Checkout Token
  * Country
  * Currency
* This hook runs client-side with an internal `useEffect()`.

Create a client component (for example, `app/intelligems-tracker.tsx`):

```tsx
"use client";

import React from "react";
import { useIgTrack } from "@intelligems/headless/next-clientside-app-directory";

export function IntelligemsTracker() {
  const { checkout } = React.useContext(StoreContext);

  useIgTrack({
    cartOrCheckoutToken: checkout?.id,
    currency: checkout?.totalTaxV2?.currencyCode,
    country: "US",
  });

  return null;
}
```

Then render it inside your provider wrapper:

```tsx
import { IntelligemsProvider } from "./intelligems-provider";
import { IntelligemsTracker } from "./intelligems-tracker";

export default function RootLayout({
  children,
}: {
  children: React.ReactNode;
}) {
  return (
    <html lang="en">
      <body>
        <IntelligemsProvider>
          <IntelligemsTracker />
          {children}
        </IntelligemsProvider>
      </body>
    </html>
  );
}
```
