> For the complete documentation index, see [llms.txt](https://docs.zigpoll.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.zigpoll.com/cookie-consent.md).

# Cookie Consent

Gate Zigpoll on your visitor's cookie consent, on Shopify or any other platform

Zigpoll stores a small amount of data in the visitor's browser — a page-view counter, a session counter, the referring site, the landing page, and any campaign parameters on the URL — and uses it to decide which survey to show. In regions that require opt-in consent, that data should only be collected once the visitor has agreed.

Zigpoll handles this automatically on Shopify, and gives you a JavaScript API to drive it from any other consent manager.

When consent is denied, Zigpoll is entirely absent: nothing is written to the browser, nothing about the visitor is sent to Zigpoll's servers, and the survey script is never loaded. When consent is granted the survey appears immediately, with no page reload.

## Shopify — automatic

If you use the Zigpoll app embed on Shopify, this is already handled. Zigpoll reads Shopify's [Customer Privacy API](https://shopify.dev/docs/api/customer-privacy) and only collects data when `analyticsProcessingAllowed()` is true. It also listens for the `visitorConsentCollected` event, so a visitor who accepts partway through their session gets the survey right away, and one who withdraws consent stops being tracked immediately.

This works with any Shopify consent app — Pandectes, Consentmo, Cookiebot and others — because Zigpoll reads the consent decision from Shopify rather than from the app. That matters, because Shopify does not guarantee the order in which app embeds load.

{% hint style="warning" %}
**Configure your consent regions in Shopify.** Go to **Settings → Customer privacy** in your Shopify admin and set the regions that require consent.

Until you do, Shopify reports that analytics processing is allowed, and Zigpoll — along with every other app that respects the Customer Privacy API — will treat visitors as consenting until your banner records a decision.
{% endhint %}

### Showing surveys without waiting for consent

If you would rather your surveys show to every visitor — before a consent decision, and to visitors who decline — you can say so in the dashboard under **Settings → General → Cookie Consent**: choose **Show surveys to everyone** and click **Save Changes**.

With that setting on, Zigpoll treats consent as granted on your storefront: surveys appear immediately and Zigpoll stores its page-view and session counters in the visitor's browser as it normally would. You are the data controller for your store, so make sure this is covered by your privacy policy. The default, **Wait for consent (recommended)**, is the right choice for most stores.

To read the setting, Zigpoll makes one small request before consent — only on a page where Shopify has reported that analytics is not allowed. It carries your store's identity and nothing about the visitor: no page URL, no counters, no cookies. On a store that has not opted in, that request is the only thing that happens, and Zigpoll stays absent exactly as described above.

Anything your page sets itself — `requireConsent`, `analyticsConsent`, `respectGPC` — still takes precedence over the dashboard setting. Changes take effect on your storefront within a few minutes.

## Survey links and shared surveys

Consent gating applies to surveys embedded in your storefront. It does not apply to surveys opened from a [survey link](/survey-links.md) or [public link](/public-link.md), which are hosted on Zigpoll's own domain and only load because the respondent chose to open them.

## Inline embeds and named surveys

A page that names a specific survey is not gated either. That covers the inline embed snippet — a survey you place on a specific page, such as a returns or contact form — and the "show on click" and "load programmatically" snippets: anything that sets `window.Zigpoll.pollId`. You put that survey on that page deliberately, and a visitor who has declined cookies can still use a form you put in front of them.

This applies to every Zigpoll survey on that page, not just the named one, and holds even if the visitor later declines your banner on it. If you would rather those surveys wait for consent like everything else, opt back in **before** the Zigpoll script tag:

```html
<script>
  window.Zigpoll = window.Zigpoll || {};
  window.Zigpoll.gateEmbeds = true;
</script>
```

`requireConsent`, `respectGPC` and an explicit `analyticsConsent` still take precedence over this exemption.

## Any other platform

Use the JavaScript API. It works on WordPress, BigCommerce, custom storefronts, and on Shopify if you would rather drive Zigpoll from your own consent manager than from Shopify's.

### 1. Lock Zigpoll before it loads

Set `requireConsent` **before** the Zigpoll script tag. Zigpoll will do nothing at all until you tell it otherwise.

```html
<script>
  window.Zigpoll = window.Zigpoll || {};
  window.Zigpoll.requireConsent = true;
</script>
<!-- your existing Zigpoll embed code goes here -->
```

### 2. Tell Zigpoll the decision

Call `consent()` from your consent manager's callback, whenever the decision is made or changed.

```javascript
window.Zigpoll.consent('granted');
window.Zigpoll.consent('denied');
```

It also accepts a Google Consent Mode style object, so you can forward what your consent manager already gives you:

```javascript
window.Zigpoll.consent({ analytics: 'granted' });
window.Zigpoll.consent({ analytics_storage: 'granted' });
```

Call it as often as you like, in either direction. Granting starts Zigpoll without a page reload. Denying stops it and removes the data Zigpoll stored.

On Shopify, calling `consent()` — or declaring `analyticsConsent` — tells Zigpoll that you are driving consent, and it stops listening to Shopify's Customer Privacy API for the rest of the page. Your decision is not overturned by the visitor's next click on a Shopify consent banner.

### Setting the decision up front

If you already know the answer when the page renders — for example your consent manager wrote it to a cookie on a previous visit — you can declare it instead of calling a function:

```html
<script>
  window.Zigpoll = window.Zigpoll || {};
  window.Zigpoll.analyticsConsent = 'denied';   // or 'granted'
</script>
```

Use `consent()` for anything that happens after the page loads.

## Examples

### Cookiebot

```javascript
window.addEventListener('CookiebotOnAccept', function () {
  window.Zigpoll.consent(Cookiebot.consent.statistics ? 'granted' : 'denied');
});
window.addEventListener('CookiebotOnDecline', function () {
  window.Zigpoll.consent('denied');
});
```

### OneTrust

```javascript
OneTrust.OnConsentChanged(function () {
  var groups = window.OnetrustActiveGroups || '';
  /* C0002 is OneTrust's default Performance/Analytics category. */
  window.Zigpoll.consent(groups.indexOf('C0002') !== -1 ? 'granted' : 'denied');
});
```

### Google Consent Mode / dataLayer

```javascript
window.dataLayer = window.dataLayer || [];
window.dataLayer.push({
  event: 'zigpoll_consent_ready',
  eventCallback: function () {
    window.Zigpoll.consent({ analytics_storage: 'granted' });
  }
});
```

### WordPress Consent API

```javascript
document.addEventListener('wp_listen_for_consent_change', function (e) {
  var changed = e.detail;
  if (changed.statistics) {
    window.Zigpoll.consent(changed.statistics === 'allow' ? 'granted' : 'denied');
  }
});
```

## Blocking the script instead

If your consent manager blocks scripts by category rather than calling an API, you can categorize Zigpoll's script tag directly and skip the JavaScript entirely. Zigpoll belongs in the **statistics / analytics** category.

Cookiebot:

```html
<script type="text/plain" data-cookieconsent="statistics"
        src="//cdn.zigpoll.com/static/js/main.js"></script>
```

OneTrust:

```html
<script type="text/plain" class="optanon-category-C0002"
        src="//cdn.zigpoll.com/static/js/main.js"></script>
```

This works, but the API is preferable where you have the choice: a blocked script cannot start when the visitor later accepts, so those visitors see no survey until they load a new page.

## Global Privacy Control

Zigpoll can treat a [Global Privacy Control](https://globalprivacycontrol.org/) signal as a denial. This is off by default, because GPC is primarily a "do not sell or share" signal rather than an analytics one, some browsers send it for every visitor, and Shopify already accounts for it in its own privacy settings.

```javascript
window.Zigpoll.respectGPC = true;
```

## Checking your setup

`getConsentState()` returns `'unknown'`, `'allowed'` or `'denied'`:

```javascript
window.Zigpoll.getConsentState();
```

To confirm it's working, open your browser's developer tools:

* **Network** — decline consent and reload. There should be no request to `api.zigpoll.com` other than, on Shopify, a single `consent-policy` lookup that carries only your store's identity — and no `/shim`, `/data` or `embed.js`.
* **Application → Local Storage** — there should be no `zigpoll-` keys.
* Accept consent. The survey should appear without reloading the page.

If Zigpoll runs when you expect it not to, check that `requireConsent` is set **before** the Zigpoll script tag. Set afterwards, it has no effect.

## What happens to data already collected

If a visitor grants consent and later withdraws it, Zigpoll stops immediately and removes the counters, referrer, landing page and campaign parameters it stored in the browser.

Their session counter starts again from zero if they consent again later, so a returning customer will look like a new visitor. This is a deliberate consequence of honouring the withdrawal.

To delete survey responses that have already been submitted, see [Removing Participant Data](/tutorials/removing-participant-data.md).


---

# 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 dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.zigpoll.com/cookie-consent.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
