> ## Documentation Index
> Fetch the complete documentation index at: https://www.pagent.ai/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# consentmanager

> Pass your visitors' consentmanager consent to pagent.

pagent loads early and reacts to your visitors' consent: it reports pseudonymous data before consent and stores its persistent cookies only after an **opt-in**. Two cookies are set without it: `_pgnt-seed`, which keeps test groups stable for a day, and `_pgnt-opt-in`, which stores the visitor's choice. List them in your cookie declaration. Your cookie banner tells pagent about the visitor's choice through two commands. See the [consent guide](https://www.pagent.ai/docs/guides/integration/consent.md) for how pagent handles consent, including the strict option that holds back all data until opt-in.

## 1. Add pagent as a vendor

In consentmanager, add pagent as a custom vendor under **Vendors**, assigned to the purpose you use for analytics. Note its ID from the ID column, for example `c123`.

## 2. Keep consentmanager from blocking pagent

With automatic blocking, mark the pagent snippet with `data-cmp-ab="1"`, so it loads before the page shows:

```html theme={"dark"}
<script
  data-cmp-ab="1"
  src="https://cdn.pagent.ai/js/sdk.js"
  data-client-key="YOUR_CLIENT_KEY">
</script>
```

## 3. Pass the consent to pagent

Add this script after the consentmanager and pagent scripts, with your vendor ID. It runs when the visitor's choice is known, on every page load and whenever it changes:

```html theme={"dark"}
<script data-cmp-ab="1">
  (function () {
    window._pgnt = window._pgnt || [];

    var PAGENT_VENDOR = "c123"; // your pagent vendor ID from step 1

    function sendConsent() {
      var data = window.__cmp("getCMPData");
      if (!data) return;

      // Where GDPR doesn't apply, this treats the visitor as opted in. Change it if your policy differs.
      var given = !data.gdprApplies || !!(data.vendorConsents && data.vendorConsents[PAGENT_VENDOR]);

      window._pgnt.push({ kind: given ? "opt-in" : "opt-out" });
    }

    if (typeof window.__cmp === "function") {
      window.__cmp("addEventListener", ["consent", sendConsent, false], null);
    }
  })();
</script>
```

## Check it worked

1. Open your site in a private window and accept pagent.
2. In your browser's developer tools, check that pagent's cookies starting with `_pgnt` appear.
3. Reopen the privacy settings, decline pagent, and check that they're removed again, except `_pgnt-seed` and `_pgnt-opt-in`, which now reads `false`.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.