Fix guide · Shopify · medium · about 30 min
OpenAI Pixel fires before cookie consent on Shopify
For the finding “OpenAI Pixel fires before cookie consent”. Also for: Any website, WordPress, Webflow, Framer.
What this means
Your store shows a cookie banner, but the OpenAI Pixel (OpenAI calls it the ChatGPT Ads Measurement Pixel; it loads oaiq.min.js from bzrcdn.openai.com) sent events to OpenAI while the banner was still waiting for an answer.
Two facts combine on Shopify:
- The pixel assumes consent. OpenAI documents that it starts with consent set to
trueunless your code sets it tofalse, or it finds a denial stored from an earlier visit. A snippet pasted as it is measures from the first page load. - Shopify holds back only some code. Pixels under Settings > Customer events (app pixels and custom pixels) follow your customer privacy settings: where consent is required, they run only after the visitor has given the permissions the pixel needs. Code in your theme, Google Tag Manager (GTM) loaded from the theme, and scripts added by app embeds are not controlled by those settings; Shopify’s help says such pixels may need a third-party banner or custom logic to honor consent.
OpenAI does not make a Shopify app; the pixel arrives through a third-party ChatGPT Ads app, a custom pixel, theme code or GTM. An early-firing copy is usually in theme.liquid, a theme-loaded GTM container, an app embed, or a custom pixel set to not require permission.
Why it costs you money:
- If you advertise to people in the EU, sending marketing data before consent is a legal risk you probably did not intend to take. We report the technical behaviour only; we cannot tell you whether your setup is compliant.
- The banner and that copy of the pixel are not connected. When this is fixed in a hurry, the usual result is the opposite problem: the pixel stops sending anything and ChatGPT Ads lose their conversion data.
How to confirm it yourself
Our check runs from a browser in the EU. Shopify shows its cookie banner based on where the visitor is and on the regions set under Settings > Customer privacy (with automated settings, visitors in the EEA and the UK). 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. - Reload the page. Do not click the cookie banner.
- Click each request and look at its payload: a list of
events, each with atype. Apage_viewedor shopping event (for exampleitems_added) while the banner is open means the pixel measures before consent. Types starting withopenai::oroai::, and the configuration file frombzrcdn.openai.com, are the SDK’s housekeeping and do not count (OpenAI does not document these service messages). - Find out where the copy runs. In the Console tab, type
typeof oaiq."function"means the pixel is loaded on the page itself: theme code, an app embed or GTM loaded by the theme."undefined"while requests still leave means it runs in one of Shopify’s sandboxes, which are separate from the page: a custom pixel (a hidden frame) or an app pixel (a web worker).
Rely on the Network tab rather than cookies: a copy inside a custom pixel may not be able to write the pixel’s __obref cookie on your domain at all.
For custom pixels, Shopify’s Pixel Helper (click Test on the pixel under Settings > Customer events) shows “Pixel is awaiting consent” while the pixel waits.
How to fix
The goal: every copy of the OpenAI pixel either goes through Shopify’s customer privacy settings, or checks consent itself, or is removed.
-
Find every copy. Check:
- Settings > Customer events: app pixels from ChatGPT Ads apps (open the menu next to each one and choose View customer privacy) and custom pixels (open each one and look for
oaiqor your Pixel ID in the code). - Theme code: go to Online Store, open the menu of your current theme and click Edit code. Open
theme.liquidand search foroaiq.min.js,oaiq(andGTM-. Check the snippets it includes as well. - App embeds: Online Store > Edit theme > App embeds icon.
- Apps: every ChatGPT Ads app you installed, including ones you only tried. Shopify lists an app under Customer events only if it uses Shopify’s Web Pixels API; other apps show up in the theme or under app embeds.
- Your GTM container: OpenAI’s own GTM template, community templates such as Stape’s OpenAI Ads Pixel tag, and Custom HTML tags containing
oaiq.
- Settings > Customer events: app pixels from ChatGPT Ads apps (open the menu next to each one and choose View customer privacy) and custom pixels (open each one and look for
-
Keep one copy that Shopify controls, normally an app pixel or a custom pixel. Delete the OpenAI snippet from
theme.liquidand click Save, remove OpenAI tags from a theme-loaded GTM container, and turn off app embeds or app settings that add another copy. Theme code does not run on checkout pages anyway, so purchases need a Customer events pixel (or the Conversions API). A pasted OpenAI snippet in a custom pixel may never seeopprefor may not keep the__opprefcookie, so test it as described in ChatGPT Ads click ID lost on Shopify. -
If you use an app pixel, View customer privacy should show that it requires Marketing. Shopify loads an app pixel only when the visitor has given every permission the app declares as required; if it requires no marketing permission, raise it with the app’s developer. Test any app with the steps above; we do not rank or recommend them.
-
If you use a custom pixel, open it under Settings > Customer events. In the Customer privacy section, set Permission to Required and select Marketing. A custom pixel set to Not required runs whether or not the visitor has answered the banner. Save the pixel. You do not need
oaiq("consent", false)inside it: Shopify does not start the pixel before consent. Adding it without a matchingoaiq("consent", true)keeps the pixel silent. -
If you need GTM, Shopify recommends running it as a custom pixel rather than from
theme.liquid; step 4 then applies to the whole container. If GTM stays in the theme, the OpenAI tag needs Advanced Settings > Consent Settings > Require additional consent for tag to fire withad_storage, and something on the page must send Google consent updates to GTM. OpenAI’s GTM template does not call the pixel’s consent command, and its opt-out flag does not stop sending. Check it in GTM’s Preview mode. -
If you use a consent app instead of Shopify’s banner, check in its documentation that it is integrated with Shopify’s Customer Privacy API. Pixels under Customer events learn about the visitor’s choice only through that API.
-
Check Settings > Customer privacy. If you chose banner regions yourself instead of automated settings, make sure every region where you need consent is selected.
-
For code that must stay in the theme (a developer task), keep OpenAI’s loader but replace its
initcall with a consent check through Shopify’s Customer Privacy API. Visitors who accepted on an earlier visit start with consenttrue, so their stored click ID survives (OpenAI saysoaiq("consent", false)removes the pixel’s cookies):var started = false, granted = false; // Consent given on this page: switch it on and send the page view again, // because OpenAI does not replay events blocked while consent was false. function grant() { if (granted) return; granted = true; oaiq("consent", true); if (started) oaiq("measure", "page_viewed", { type: "contents" }); } window.Shopify.loadFeatures( [{ name: "consent-tracking-api", version: "0.2" }], function (error) { if (error) return; var allowed = granted || window.Shopify.customerPrivacy.marketingAllowed(); oaiq("consent", allowed); oaiq("init", { pixelId: "<YOUR-PIXEL-ID>" }); started = true; if (allowed) { granted = true; oaiq("measure", "page_viewed", { type: "contents" }); } } ); document.addEventListener("visitorConsentCollected", function (event) { if (event.detail.marketingAllowed) grant(); });The two flags keep the order right if the visitor accepts before Shopify has loaded the consent API:
initstill comes first, andpage_viewedis sent once. This example only handles granting consent. If a visitor withdraws consent later, your code also needs to calloaiq("consent", false).
Common causes
- The installation snippet was pasted unchanged into
theme.liquid. Withoutoaiq("consent", false)the pixel treats every visitor as consenting, and Shopify does not hold theme code back. - GTM is loaded from
theme.liquid, and its OpenAI tag has no consent requirement. - A custom pixel has Permission set to Not required.
- A ChatGPT Ads app adds the pixel through an app embed, or its app pixel does not require marketing permission.
- An app you tried earlier still adds its pixel next to the one you use now.
- A consent app is not connected to Shopify’s Customer Privacy API, or the banner regions leave out some countries.
How to verify the fix
- In a private window with a European location: no
page_viewedor other measurement events before you answer the banner, apage_viewedevent within a few seconds after you click “Accept” (on the same page), and none after “Reject” in a fresh private window. - For a custom pixel, the Pixel Helper shows “Pixel is awaiting consent” until you accept.
- Re-run the check on IsPixelWorking. The issue should be gone, and “OpenAI Pixel does not fire after consent” should not appear in its place.
Questions people ask
Is there an official OpenAI app for Shopify?
Not at the time of writing. Several third-party apps in the Shopify App Store install the OpenAI pixel; none is made by OpenAI. For any of them, check that its pixel is listed under Settings > Customer events and requires marketing permission, then test it as described above.
Sources
- OpenAI Developers, Measurement Pixel (installation snippet;
oaiq("consent", false | true); consent istrueby default unless set or a stored denial exists; blocked events are not replayed;oaiq("consent", false)removes the__opprefand__obrefcookies): https://developers.openai.com/ads/measurement-pixel - OpenAI on GitHub, Ads Measurement Pixel GTM template (no consent call; the opt-out flag does not block transport): https://github.com/openai/ads-measurement-pixel-gtm-template
- Stape, OpenAI Ads Pixel tag for web GTM (third-party template): https://stape.io/helpdesk/documentation/openai-ads-pixel-tag
- Shopify Help Center, Pixels overview (in consent-required markets, pixels run only with the required permissions): https://help.shopify.com/en/manual/promoting-marketing/pixels/overview
- Shopify Help Center, App pixels (only apps that use the Web Pixels API are listed; View customer privacy): https://help.shopify.com/en/manual/promoting-marketing/pixels/app-pixels
- Shopify Help Center, Manage your custom pixels (Permission Required / Not required): https://help.shopify.com/en/manual/promoting-marketing/pixels/custom-pixels/manage
- Shopify Help Center, Testing custom pixels (“Pixel is awaiting consent”): https://help.shopify.com/en/manual/promoting-marketing/pixels/custom-pixels/testing
- Shopify Help Center, Configuring customer privacy settings (automated settings, regions, manually installed pixels, third-party banners): https://help.shopify.com/en/manual/privacy-and-security/privacy/customer-privacy-settings/privacy-settings
- Shopify Help Center, Extend your theme with apps (app embeds): https://help.shopify.com/en/manual/online-store/themes/customizing-themes/apps
- Shopify Help Center, Google Tag Manager (use GTM through a custom pixel): https://help.shopify.com/en/manual/reports-and-analytics/google-analytics/google-tag-manager
- Shopify.dev, Layouts (
theme.liquidapplies to non-checkout pages): https://shopify.dev/docs/storefronts/themes/architecture/layouts - Shopify.dev, About web pixels (app pixels run in a web worker, custom pixels in a sandboxed frame): https://shopify.dev/docs/apps/build/marketing/pixels
- 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.dev, Customer Privacy API (
loadFeatures,marketingAllowed,visitorConsentCollected): https://shopify.dev/docs/api/customer-privacy - Google Tag Manager Help, Tag Manager consent mode support: https://support.google.com/tagmanager/answer/10718549