> For the complete documentation index, see [llms.txt](https://docs.adpage.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.adpage.io/faq/marketing-optimization/how-do-i-enable-shopifys-customer-privacy-api-for-cookiebot.md).

# How do I enable Shopify’s Customer Privacy API for Cookiebot?

Pass Cookiebot consent choices to Shopify by adding a small snippet to your theme, so Shopify’s own tracking respects your visitors’ cookie preferences.

Enabling Shopify’s Customer Privacy API passes the consent choices visitors make in the Cookiebot banner on to Shopify, so Shopify’s own tracking respects them. The steps below follow Cookiebot’s own guide: [Enabling the Customer Privacy API](https://support.cookiebot.com/hc/en-us/articles/360006184253-Shopify-installation#:~:text=Enabling%20the%20Customer%20Privacy%20API).

1. In your Shopify admin, go to Online Store > Themes, click the three dots next to your live theme and choose Edit code. Under Snippets, add a new snippet.
2. Name the new snippet “cookie-consent” and click Done.

<figure><img src="https://2963651437-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F5eC7lwaeygB0xx6AOZcE%2Fuploads%2FfZy596pQV5gnXLp9aQF3%2Fimage.png?alt=media&amp;token=61935600-682d-4409-a021-f17ee6671538" alt=""><figcaption></figcaption></figure>

3. Open the empty cookie-consent.liquid file and paste in the following code:

```html
<script>

function feedback() {
  const p = window.Shopify.customerPrivacy;
  console.log(`Tracking ${p.userCanBeTracked() ? "en" : "dis"}abled`);
}
window.Shopify.loadFeatures(
  [
    {
      name: "consent-tracking-api",
      version: "0.1",
    },
  ],
  function (error) {
    if (error) throw error;
    if ("Cookiebot" in window)
      window.Shopify.customerPrivacy.setTrackingConsent({
        "analytics": false,
        "marketing": false,
        "preferences": false,
        "sale_of_data": false,
      }, () => console.log("Awaiting consent")
    );
  }
);

window.addEventListener("CookiebotOnConsentReady", function () {
  const C = Cookiebot.consent,
      existConsentShopify = setInterval(function () {
        if (window.Shopify.customerPrivacy) {
          clearInterval(existConsentShopify);
          window.Shopify.customerPrivacy.setTrackingConsent({
            "analytics": C["statistics"],
            "marketing": C["marketing"],
            "preferences": C["preferences"],
            "sale_of_data": C["marketing"],
          }, () => console.log("Consent captured"))
        }
      }, 100);
});
</script>
```

4. Save the snippet, then open the theme.liquid file in your theme code.
5. Directly below the line {{ content\_for\_header }}, add the following code:

```liquid
{% render 'cookie-consent' %}
```

6. Save the theme.liquid file.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.adpage.io/faq/marketing-optimization/how-do-i-enable-shopifys-customer-privacy-api-for-cookiebot.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

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.
