Fix guide · Shopify · medium · about 30 min
ChatGPT Ads click ID (oppref) lost on Shopify
For the finding “Click ID from OpenAI ads is not stored”. Also for: Any website, WordPress, Webflow, Framer.
What this means
When someone clicks an ad in ChatGPT, the link to your store carries an attribution identifier in the oppref URL parameter. The OpenAI Pixel (the ChatGPT Ads Measurement Pixel) is supposed to read it from the landing page address, store it in a first-party cookie called __oppref (for 30 days), and send it with later events, so that a purchase on another page can still be tied to the ad click.
On your store, the click ID did not make it: it was not stored, or not sent with the pixel’s events.
Why it costs you money:
- Orders lose their link to the ChatGPT ad click, so ChatGPT Ads reports fewer conversions than your ads really brought.
- Conversion-optimized campaigns learn from fewer attributed conversions and may optimize toward the wrong results.
- If you send server events through the OpenAI Conversions API, OpenAI notes that the API does not capture
opprefby itself; your server has to pass it on.
On Shopify, two things decide whether the click ID survives: the redirects between the ad and the page, and where the pixel runs (theme code runs on the real page; pixels under Settings > Customer events run in Shopify’s sandboxes).
How to confirm it yourself
Our check opens your page in a browser in the EU as if the visitor arrived from a ChatGPT ad, accepts the cookie banner and looks for the click ID. If our report shows a redirect chain, start there: it often shows where the click ID was dropped.
- Open a private (incognito) window, open developer tools (F12) on Network, and tick Preserve log so redirects stay visible.
- Open the exact URL your ads use, with a made-up click ID added:
https://yourstore.com/products/example?oppref=test123. (This sends a normal page view to your own pixel. It does not create an ad click.) - If one of the first requests is a redirect (
301,302,307,308), click it and check its Location header. Does the new address still containoppref=test123? - Accept the cookie banner and wait a few seconds. Where consent is required, pixels under Customer events wait for it, so the cookie may appear only after you accept.
- Go to Application > Cookies (Chrome) or Storage > Cookies (Firefox), select your store’s domain and look for
__oppref. It should holdtest123. You should also see__obref, the pixel’s browser reference. - Filter the Network tab by
bzr.openai.comand open a request: the payload should carryopprefwith your test value. - Follow a buyer’s path: open another page, add a product to the cart, and place a test order with Shopify’s test payment gateway or Shopify Payments’ test mode. The
order_createdevent should still carryoppref. On Shopify, checkout pages are often tracked by a different copy of the pixel than the storefront, so check this step too.
If __oppref is missing, holds something else, or order_created has no oppref, the click ID is being lost.
How to fix
- Point your ads at the final address. Your primary domain is set under Settings > Domains; your other domains, including the
.myshopify.comaddress, redirect to it. Shopify’s documentation does not say whether every redirect keeps the query string, so use the exact final address in every ad (primary domain,https, and the market folder if you use one, for example/en-de), and test it as above. - Test automatic redirection for your markets. If automatic redirection is on (Online Store > Preferences), visitors may be sent to another domain or folder for their country. Open your ad URL with
?oppref=test123through a VPN in each of your main markets and check that the click ID survives. - Check Shopify URL redirects. Redirects under Content > Menus > View URL redirects only work for addresses that no longer exist, and Shopify notes that URLs with query strings might not work as expected. If an ad points to an old address, change the ad to the current page.
- Check redirects outside Shopify and in apps: registrar forwarding, link shorteners, link-in-bio pages, and apps that send visitors elsewhere (country selectors, A/B tests, age checks).
- Make sure the pixel runs on the landing page after consent. The pixel can only read
opprefwhile it is in the address. For app pixels, Shopify documents that after the visitor accepts, it replays the events that already happened on the page, so the landing page view still reaches the app. If the pixel does not fire after “Accept” at all, see “OpenAI Pixel does not fire after consent”. - Check where your pixel runs, and test it.
- Custom pixel (including GTM run as a custom pixel): Shopify documents that custom pixels run in a sandboxed frame whose address is the sandbox URL, not your page, and that pixel code there reaches the page’s cookies through Shopify’s
browser.cookieinterface instead ofdocument.cookie. OpenAI’s pixel readsoppreffrom the address and keeps it in first-party cookies by itself. So a pasted OpenAI snippet in a custom pixel may never seeoppref, or may not be able to keep__opprefon your store’s domain. Steps 5 to 7 of the test show whether this happens on your store. - App pixel from a ChatGPT Ads app: Shopify runs these in a web worker, where pixels that rely on the browser page (such as
window.document) do not work; the app has to read the address and cookies through Shopify’s interfaces. OpenAI does not make a Shopify app, so test whichever third-party app you use the same way, including a test order. - Theme code runs on the real page, so it sees
opprefand can write__oppref. But it does not run on checkout pages, so the purchase is sent by a Customer events pixel. If that pixel cannot read__oppref,order_createdarrives without it. - OpenAI’s documentation describes no way to hand the pixel an
opprefvalue from elsewhere. If your setup cannot pass the click ID to the purchase event, the documented way to pass it yourself is the Conversions API (step 9).
- Custom pixel (including GTM run as a custom pixel): Shopify documents that custom pixels run in a sandboxed frame whose address is the sandbox URL, not your page, and that pixel code there reaches the page’s cookies through Shopify’s
- Do not withdraw consent for visitors who already agreed. OpenAI documents that
oaiq("consent", false)removes both pixel cookies,__opprefincluded. If theme code calls it at the top of every page and switches consent back on a moment later, the stored click ID is deleted on every page after the landing page. Passtruefrom the start when Shopify’sShopify.customerPrivacy.marketingAllowed()returnstrue. - Check that your consent app does not delete the cookie. After “Accept”,
__opprefshould stay. - Pass the click ID to your server events. For the Conversions API, a developer reads the value on the landing page (from the URL or the
__opprefcookie, after consent) and keeps it with the visit, for example as a private cart attribute (its name starts with two underscores), which Shopify hides at checkout but shows on the order in your admin. The server then sends the original string unchanged asopprefwith the order event, and the__obrefcookie value asuser.obref.
Common causes
- Ads link to an address that goes through a redirect outside Shopify (registrar forwarding, a link shortener, a link-in-bio tool) that drops the query string.
- An app redirects visitors to another page or country version without keeping the query string.
- An ad points to an old address that relies on a URL redirect.
- The OpenAI pixel runs only in a custom pixel, where it does not see the real page address or cookies.
- The storefront copy stores
__oppref, but the checkout copy cannot read it, so purchases arrive without the click ID. oaiq("consent", false)runs on every page, so the cookie is removed again and again.
How to verify the fix
- Repeat the test above with the exact ad URL: no redirect drops
?oppref=test123, and after accepting cookies__opprefholdstest123. - Open another page of the store:
__opprefis still there, and the pixel’s requests still carryoppref. - In a test order,
order_createdcarriesoppref(or your server sends it with the order). - Re-run the check on IsPixelWorking. The issue should be gone, and the redirect chain in the report (if any) should keep the click ID.
Sources
- OpenAI Developers, Measurement Pixel (captures
oppreffrom the landing page URL, stores it in the first-party__opprefcookie for 30 days,__obrefbrowser reference, cookies used when consent is granted,oaiq("consent", false)removes both cookies): https://developers.openai.com/ads/measurement-pixel - OpenAI Developers, Conversions API (
opprefis not captured by the API, pass the original string;user.obreffrom the__obrefcookie): https://developers.openai.com/ads/conversions-api - Shopify.dev, About web pixels (app pixels run in a web worker; custom pixels run in a sandboxed frame and see the sandbox URL; app pixel events are replayed after consent): https://shopify.dev/docs/apps/build/marketing/pixels
- Shopify.dev, Web Pixels API
browser(browser.cookiereplacesdocument.cookieto reach the top frame’s cookies): https://shopify.dev/docs/api/web-pixels-api/standard-api/browser - Shopify.dev, Layouts (
theme.liquidapplies to non-checkout pages): https://shopify.dev/docs/storefronts/themes/architecture/layouts - Shopify.dev, Customer Privacy API (
marketingAllowed): https://shopify.dev/docs/api/customer-privacy - Shopify.dev, Cart API reference (private cart attributes are hidden at checkout and shown on the order in the admin): https://shopify.dev/docs/api/ajax/reference/cart
- Shopify Help Center, Change your primary domain (other domains redirect to the primary domain): https://help.shopify.com/en/manual/domains/domain-type/change-primary-domain
- Shopify Help Center, Set up automatic storefront redirection for your customers: https://help.shopify.com/en/manual/international/automatic-redirection
- Shopify Help Center, Creating and managing URL redirects (broken URLs only; query strings): https://help.shopify.com/en/manual/online-store/menus-and-links/url-redirect
- Shopify Help Center, Placing a test order: https://help.shopify.com/en/manual/checkout-settings/test-orders
More OpenAI guides
- OpenAI Pixel fires before cookie consent on Shopify
- OpenAI Pixel not firing after cookie consent on Shopify
- Repeated OpenAI event IDs drop ChatGPT Ads conversions
- Duplicate OpenAI Pixel events on Shopify
- OpenAI Pixel events have no event ID on Shopify
- OpenAI Pixel tracks a button on desktop but not on mobile
- Two OpenAI Pixel IDs on one site: when it's fine, how to fix
- OpenAI Conversions API deduplication: match the pixel event_id
- OpenAI Ads Pixel setup: install the ChatGPT Measurement Pixel
- How to set up the OpenAI Conversions API for ChatGPT Ads