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 oppref by 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.

  1. Open a private (incognito) window, open developer tools (F12) on Network, and tick Preserve log so redirects stay visible.
  2. 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.)
  3. 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 contain oppref=test123?
  4. 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.
  5. Go to Application > Cookies (Chrome) or Storage > Cookies (Firefox), select your store’s domain and look for __oppref. It should hold test123. You should also see __obref, the pixel’s browser reference.
  6. Filter the Network tab by bzr.openai.com and open a request: the payload should carry oppref with your test value.
  7. 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_created event should still carry oppref. 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

  1. Point your ads at the final address. Your primary domain is set under Settings > Domains; your other domains, including the .myshopify.com address, 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.
  2. 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=test123 through a VPN in each of your main markets and check that the click ID survives.
  3. 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.
  4. 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).
  5. Make sure the pixel runs on the landing page after consent. The pixel can only read oppref while 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”.
  6. 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.cookie interface instead of document.cookie. OpenAI’s pixel reads oppref from the address and keeps it in first-party cookies by itself. So a pasted OpenAI snippet in a custom pixel may never see oppref, or may not be able to keep __oppref on 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 oppref and 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_created arrives without it.
    • OpenAI’s documentation describes no way to hand the pixel an oppref value 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).
  7. Do not withdraw consent for visitors who already agreed. OpenAI documents that oaiq("consent", false) removes both pixel cookies, __oppref included. 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. Pass true from the start when Shopify’s Shopify.customerPrivacy.marketingAllowed() returns true.
  8. Check that your consent app does not delete the cookie. After “Accept”, __oppref should stay.
  9. 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 __oppref cookie, 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 as oppref with the order event, and the __obref cookie value as user.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

  1. Repeat the test above with the exact ad URL: no redirect drops ?oppref=test123, and after accepting cookies __oppref holds test123.
  2. Open another page of the store: __oppref is still there, and the pixel’s requests still carry oppref.
  3. In a test order, order_created carries oppref (or your server sends it with the order).
  4. 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

More OpenAI guides