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.
- Open your store in a private (incognito) window, open developer tools (F12), go to the Network tab and type
bzr.openai.cominto the filter box. - Load the page and click Accept on the cookie banner.
- Wait about 5 seconds. Click the requests and look at the payload: a list of
events, each with atype. You should seepage_viewed(or another event your setup sends on page load). Service messages whose type starts withopenai::oroai::do not count (at the time of writing the SDK sends these on its own; OpenAI does not document them). - Open the Console tab and run
Shopify.customerPrivacy.currentVisitorConsent(). After “Accept”,marketingshould be"yes". If it is empty or"no", the banner did not pass the choice to Shopify. If the console reports thatShopify.customerPrivacyis undefined, nothing on the page has loaded the Customer Privacy API, which usually means the banner is not connected to it. - 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
-
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.
-
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.
-
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.
-
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.
-
Check the custom pixel code. Shopify’s sandbox runs JavaScript only, so remove the
<script>and</script>tags from OpenAI’s snippet. Do not copyoaiq("consent", false)into a custom pixel: Shopify already starts the pixel only after consent, and if the code sets the pixel’s consent tofalsewith nothing setting it back totrue, 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
typethat matches the event, andamountandquantitymust be whole numbers. Addingdebug: trueto theinitcall while you test logs what the SDK does to the console. A pasted snippet in a custom pixel may also never seeopprefor may not keep the__opprefcookie, so test that as well: see ChatGPT Ads click ID lost on Shopify. -
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
visitorConsentCollectedevent 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
truefrom the start whenShopify.customerPrivacy.marketingAllowed()returnstrue. A common mistake is callingoaiq("consent", false)on every page load andoaiq("consent", true)only inside the banner’s click handler: visitors who accepted earlier then stay blocked. The pixel also keeps consentfalsewhen it finds a denial stored from an earlier visit, so a tester who once clicked “Reject” stays blocked until the code callsoaiq("consent", true). -
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.
-
Look at the Console for errors from
oaiq.min.jsor 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
- In a fresh private window with a European location: no measurement events before “Accept”, a
page_viewedevent within a few seconds after “Accept” on the same page, andcurrentVisitorConsent()showsmarketing: "yes". - Reload the page:
page_viewedis sent on load, without clicking anything. - 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. - 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
- OpenAI Developers, Measurement Pixel (installation snippet; consent commands; stored denial; blocked events are not replayed;
debugoption; integeramountandquantity): https://developers.openai.com/ads/measurement-pixel - OpenAI Developers, Supported Events (event names and data shapes): https://developers.openai.com/ads/supported-events
- OpenAI Developers, Conversion Tracking (Monitoring Events,
pixel_sdkchannel): https://developers.openai.com/ads/conversion-tracking - OpenAI on GitHub, Ads Measurement Pixel GTM template (no consent field): https://github.com/openai/ads-measurement-pixel-gtm-template
- Stape, OpenAI Ads Pixel tag for web GTM (third-party template; Consent Granted): https://stape.io/helpdesk/documentation/openai-ads-pixel-tag
- Shopify.dev, About web pixels (in consent regions, app pixel callbacks run after consent and earlier events are replayed; sandboxes): https://shopify.dev/docs/apps/build/marketing/pixels
- Shopify.dev, Customer Privacy API (
currentVisitorConsent,marketingAllowed,visitorConsentCollected): https://shopify.dev/docs/api/customer-privacy - Shopify.dev, Pixel privacy (a pixel loads only with every permission it declares as required): https://shopify.dev/docs/api/web-pixels-api/pixel-privacy
- Shopify Help Center, Pixels overview (new pixels require Marketing and Analytics permissions by default): https://help.shopify.com/en/manual/promoting-marketing/pixels/overview
- Shopify Help Center, App pixels (View customer privacy): https://help.shopify.com/en/manual/promoting-marketing/pixels/app-pixels
- Shopify Help Center, Manage your custom pixels: https://help.shopify.com/en/manual/promoting-marketing/pixels/custom-pixels/manage
- Shopify Help Center, Create custom pixel code (JavaScript only): https://help.shopify.com/en/manual/promoting-marketing/pixels/custom-pixels/code
- Shopify Help Center, Testing custom pixels (Pixel Helper, awaiting consent): https://help.shopify.com/en/manual/promoting-marketing/pixels/custom-pixels/testing
- Shopify Help Center, Create a Google Tag Manager custom pixel (Tag Assistant limitation): https://help.shopify.com/en/manual/promoting-marketing/pixels/custom-pixels/gtm-tutorial
- Shopify Help Center, Configuring customer privacy settings: https://help.shopify.com/en/manual/privacy-and-security/privacy/customer-privacy-settings/privacy-settings
- Google Tag Manager Help, Tag Manager consent mode support: https://support.google.com/tagmanager/answer/10718549