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

"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:

Last updated