# Pack Digital

{% hint style="danger" %}
**Client-side Rendering is currently available**

We are currently only compatible with **SWC** minification (the default). The **Terser** minification with Pack Digital will **error out** during the build process.
{% endhint %}

### Environment Variables

Add the following to your `.env` file:

```dotenv
NEXT_PUBLIC_INTELLIGEMS_ORG_ID=<Intelligems-ID>
NEXT_PUBLIC_SHOPIFY_STOREFRONT_ACCESS_TOKEN=<Storefront-API-Token>
```

### Provider Integration

The `IntelligemsPackProvider` component stores Intelligems data in React Context so hooks and components can access it throughout your app.

```tsx
import { IntelligemsPackProvider } from "@intelligems/headless/pack";

export default function MyApp({ Component, pageProps }: AppProps) {
  return (
    <>
      <IntelligemsPackProvider
        organizationId={process.env.NEXT_PUBLIC_INTELLIGEMS_ORG_ID}
        storefrontApiToken={
          process.env.NEXT_PUBLIC_SHOPIFY_STOREFRONT_ACCESS_TOKEN
        }
        activeCurrencyCode="USD" // Must be provided
        antiFlicker={true}
      >
        ...
      </IntelligemsPackProvider>
    </>
  );
}
```

### Page Views Tracking

`useIgTrack` is a client-side hook tracking page views.

To provide accurate analytics ensure it is configured with valid parameters:

* `cartOrCheckoutToken`
* `currency`
* `country`

```tsx
import React from "react";

import {
  IntelligemsPackProvider,
  useIgTrack,
} from "@intelligems/headless/pack";

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

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

  return null;
};

export default function App({ children }) {
  return (
    <IntelligemsPackProvider
      organizationId={process.env.NEXT_PUBLIC_INTELLIGEMS_ORG_ID}
      storefrontApiToken={
        process.env.NEXT_PUBLIC_SHOPIFY_STOREFRONT_ACCESS_TOKEN
      }
      antiFlicker={true}
    >
      <StoreProvider>
        <IntelligemsTracker />
        {children}
      </StoreProvider>
    </IntelligemsPackProvider>
  );
}
```


---

# 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/integration-guides/pack-digital.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.
