Fix guide · Shopify · medium · about 30 min

OpenAI Pixel not firing after cookie consent on Shopify

For the finding “OpenAI Pixel does not fire after consent”. Also for: Any website, WordPress, Webflow, Framer.

What this means

The OpenAI Pixel (the ChatGPT Ads Measurement Pixel) is on your Shopify store, but after cookies were accepted, no events were sent to OpenAI. As far as ChatGPT Ads can tell, this page has no visitors.

Why it costs you money:

  • ChatGPT Ads cannot see page views or purchases from this page, so reported conversions are too low and your cost per conversion looks worse than it is.
  • Conversion-optimized campaigns learn from these events. Without them, they optimize on little or nothing.

How sure we are: if our checker found and accepted your cookie banner, this is reported as critical. If we did not find a banner we could operate, it is reported as high: the pixel may be waiting for a banner we did not recognize. Test it yourself before changing anything.

On Shopify, the chain looks like this. The banner records the visitor’s choice through Shopify’s Customer Privacy API. Shopify then starts the pixels under Settings > Customer events that have the permissions they need. For app pixels, Shopify documents that it replays the events that already happened on the page, so a page_viewed should arrive right after “Accept”, without a reload. Code in your theme gets no such replay: OpenAI says events blocked while the pixel’s consent is false are not replayed, so theme code has to send the page view again itself. If nothing arrives, a link in this chain is broken.

How to confirm it yourself

Our check runs from a browser in the EU. Shopify shows its banner based on where the visitor is (with automated settings, in the EEA and the UK), so if you are elsewhere, use a VPN with a European location or ask a colleague in the EU.

  1. Open your store in a private (incognito) window, open developer tools (F12), go to the Network tab and type bzr.openai.com into the filter box.
  2. Load the page and click Accept on the cookie banner.
  3. Wait about 5 seconds. Click the requests and look at the payload: a list of events, each with a type. You should see page_viewed (or another event your setup sends on page load). Service messages whose type starts with openai:: or oai:: do not count (at the time of writing the SDK sends these on its own; OpenAI does not document them).
  4. Open the Console tab and run Shopify.customerPrivacy.currentVisitorConsent(). After “Accept”, marketing should be "yes". If it is empty or "no", the banner did not pass the choice to Shopify. If the console reports that Shopify.customerPrivacy is undefined, nothing on the page has loaded the Customer Privacy API, which usually means the banner is not connected to it.
  5. Click to another page. If events appear only there, the pixel starts one page too late, and you lose the first page of every new visit, which is usually the page your ad points to.

A note on typeof oaiq in the Console: on Shopify, "undefined" does not mean the pixel is missing. App pixels and custom pixels run in Shopify’s sandboxes, separate from the page, so oaiq exists only there. "function" means a copy runs on the page itself (theme code, an app embed or GTM loaded by the theme).

For custom pixels, Shopify’s Pixel Helper (click Test on the pixel under Settings > Customer events) shows whether the pixel is still waiting for consent, and marks events whose code threw an error with a red dot.

How to fix

  1. Check that the banner records the choice. After clicking “Accept”, reload: the banner should not come back. If two banners appear (Shopify’s and a consent app’s), keep one and turn the other off.

  2. If you use a consent app, check its settings or documentation for its integration with Shopify’s Customer Privacy API. Pixels under Customer events learn about consent only through that API. Without the integration, they keep waiting in regions where Shopify requires consent.

  3. Check that “Accept” grants what the pixel needs. Under Settings > Customer events, open the menu next to your ChatGPT Ads app’s pixel and choose View customer privacy; for a custom pixel, open it and check the Customer privacy section. A pixel runs only when the visitor has given every permission it requires. By default, new pixels require Marketing and Analytics; if your banner’s choices never grant one of the required permissions, the pixel never starts. The console check above shows what was granted.

  4. Check that the pixel is connected and configured. A custom pixel that shows a Connect button is not connected. For an app, open its settings and check that your Pixel ID is entered and the events you expect are switched on. OpenAI does not make a Shopify app, so follow the documentation of the third-party app you use.

  5. Check the custom pixel code. Shopify’s sandbox runs JavaScript only, so remove the <script> and </script> tags from OpenAI’s snippet. Do not copy oaiq("consent", false) into a custom pixel: Shopify already starts the pixel only after consent, and if the code sets the pixel’s consent to false with nothing setting it back to true, it never sends an event. Send events from Shopify’s customer events:

    // OpenAI's loader, without the script tags
    (function (w, d, s, u) {
      if (w.oaiq) return;
      var q = function () {
        q.q.push(arguments);
      };
      q.q = [];
      w.oaiq = q;
      var js = d.createElement(s);
      js.async = true;
      js.src = u;
      var f = d.getElementsByTagName(s)[0];
      f.parentNode.insertBefore(js, f);
    })(window, document, "script", "https://bzrcdn.openai.com/sdk/oaiq.min.js");
    
    oaiq("init", { pixelId: "<YOUR-PIXEL-ID>" });
    
    analytics.subscribe("page_viewed", (event) => {
      oaiq("measure", "page_viewed", { type: "contents" }, { event_id: event.id });
    });

    The event data needs a type that matches the event, and amount and quantity must be whole numbers. Adding debug: true to the init call while you test logs what the SDK does to the console. A pasted snippet in a custom pixel may also never see oppref or may not keep the __oppref cookie, so test that as well: see ChatGPT Ads click ID lost on Shopify.

  6. If the pixel is in theme code behind a consent check, make sure the check also reacts when consent is given on the current page, not only to consent that existed when the page loaded. Shopify’s Customer Privacy API publishes a visitorConsentCollected event when consent changes:

    document.addEventListener("visitorConsentCollected", function (event) {
      if (event.detail.marketingAllowed) {
        oaiq("consent", true);
        oaiq("measure", "page_viewed", { type: "contents" });
      }
    });

    For returning visitors, pass true from the start when Shopify.customerPrivacy.marketingAllowed() returns true. A common mistake is calling oaiq("consent", false) on every page load and oaiq("consent", true) only inside the banner’s click handler: visitors who accepted earlier then stay blocked. The pixel also keeps consent false when it finds a denial stored from an earlier visit, so a tester who once clicked “Reject” stays blocked until the code calls oaiq("consent", true).

  7. If GTM sends the OpenAI tag:

    • GTM as a custom pixel: Shopify notes that Google Tag Assistant does not detect tags inside a custom pixel, so test with the Network tab instead. The custom pixel’s permissions (step 3) decide when GTM can run.
    • GTM in theme.liquid: the OpenAI tag often has only a page view trigger, which runs once, before the visitor clicks “Accept”. Add a trigger for the data layer event your consent setup pushes when consent is given (GTM Preview shows its name), keep the tag’s consent requirement, and make sure it cannot fire twice on the same page. With Stape’s OpenAI Ads Pixel template, check its Consent Granted field; OpenAI’s own GTM template has no consent field.
  8. Look at the Console for errors from oaiq.min.js or your own code, then save your changes and publish GTM if you changed it.

Common causes

  • A consent app is not integrated with Shopify’s Customer Privacy API, so Shopify never learns that the visitor accepted.
  • Two banners are active, and the visitor answers the one Shopify does not listen to.
  • The pixel requires a permission that the banner’s “Accept” does not grant.
  • A custom pixel contains HTML tags, a code error or a leftover oaiq("consent", false), or is not connected.
  • Theme code switches consent on after “Accept” but does not send the page view again.
  • A GTM tag fires only on the initial page view, before consent, and never again on that page.

How to verify the fix

  1. In a fresh private window with a European location: no measurement events before “Accept”, a page_viewed event within a few seconds after “Accept” on the same page, and currentVisitorConsent() shows marketing: "yes".
  2. Reload the page: page_viewed is sent on load, without clicking anything.
  3. If you have access to OpenAI’s Advertiser API, the recent-events endpoint described in the general guide shows browser events with the channel pixel_sdk.
  4. Re-run the check on IsPixelWorking. The issue should be gone, and “OpenAI Pixel fires before cookie consent” should not appear in its place.

Sources

Guides for your consent tool