OpenAI Ads Pixel and CAPI for Shopify: Complete Setup
There are two ways to get the OpenAI Ads pixel and Conversions API working on Shopify: a manual theme-plus-webhook build, or the free Comercio app installed in under 5 minutes. This guide covers both, plus verification and Shopify-specific errors.
When Shopify killed off checkout Additional Scripts, thousands of ad tracking setups broke overnight. Checkout now runs inside an isolated sandbox through the Web Pixels API, meaning any regular JavaScript pasted into your theme file stops dead in its tracks the moment a buyer taps checkout.
If you rely on a basic theme.liquid pixel snippet, your store might log catalog views and product clicks, but you will miss almost every single purchase.
To track conversions reliably on modern Shopify stores, you need a hybrid architecture: run the client-side pixel across your storefront and checkout sandbox for funnel signals, while piping verified orders through a server-side webhook to OpenAI's Conversions API (CAPI).
Here is how to set up both layers, wire click attribution into Shopify order notes, and make sure every dollar of ad-driven revenue registers in Ads Manager.
Why Shopify checkouts need server-side CAPI
On open platforms like WooCommerce or custom Node apps, you can drop tracking code anywhere. Shopify locks checkout down tight for security and speed, isolating third-party scripts in a web worker with limited DOM access.
While sandboxed Web Pixels can catch checkout_started and intermediate funnel actions, client-side tracking still suffers from browser privacy walls. If a customer buys via Apple Pay or a quick redirect through PayPal and closes their browser tab before the thank-you screen loads, the browser conversion event never dispatches.
OpenAI specifically recommends pairing the browser pixel with server CAPI for Shopify stores. The client pixel handles top-of-funnel browsing and grabs the campaign click token (oppref), while your backend dispatches a server-to-server order_created event the second Shopify issues an order invoice.
Manual setup across your store
A complete tracking integration requires three moving parts: a base pixel in your theme layout, a sandboxed custom pixel for checkout progression, and an orders/create webhook dispatching CAPI events for verified sales.
1. Adding the base pixel to theme.liquid
The client-side pixel tracks browsing across your homepage, collection templates, and product detail pages. Insert this loader near the top of <head> in your layout/theme.liquid template:
<head>
<script async src="https://bzrcdn.openai.com/sdk/oaiq.min.js"></script>
<script>
window.oaiq = window.oaiq || function () {
(window.oaiq.q = window.oaiq.q || []).push(arguments);
};
oaiq("init", { pixelId: "YOUR-PIXEL-ID" });
</script>
</head>
This snippet fires a page_viewed event on general page loads and captures the oppref query parameter on landing, tucking it into a first-party __oppref cookie for down-funnel attribution.
Because Shopify isolates checkout, remember that theme.liquid will not run once the customer steps into the payment flow.
2. Capturing checkout events with sandboxed Web Pixels
To capture checkout milestones like checkout_started, set up a Custom Pixel inside your Shopify Admin under Settings > Customer Events:
- Click Add custom pixel and name it "OpenAI Ads Checkout".
- Subscribe to Shopify customer events such as
checkout_startedandpayment_info_submitted. - In your pixel handler, initialize
oaiqwith your account ID and dispatch the event payload.
Because custom pixels execute inside an isolated worker sandbox, they only have access to parameters provided by the Customer Events API, such as line item totals, currency, and cart IDs.
3. Server-side purchase dispatch via orders/create webhook
To guarantee that 100% of confirmed orders reach OpenAI Ads regardless of ad blockers or browser crashes, register a webhook on the orders/create topic in Shopify Admin or through the Partner API.
Whenever an order finalizes, Shopify pings your server endpoint with the complete transaction payload. Your server then formats and posts a server-to-server order_created request directly to https://bzr.openai.com/v1/events:
curl -X POST "https://bzr.openai.com/v1/events?pid=<YOUR-PIXEL-ID>" \
-H "Authorization: Bearer <YOUR-CAPI-KEY>" \
-H "Content-Type: application/json" \
--data '{
"validate_only": false,
"events": [
{
"id": "shopify_order_1001",
"type": "order_created",
"timestamp_ms": 1753315200000,
"oppref": "<captured_click_token>",
"source_url": "https://yourstore.com/checkout/thank-you",
"action_source": "web",
"data": {
"type": "contents",
"amount": 8998,
"currency": "USD",
"contents": [
{ "id": "SKU-1001", "quantity": 1, "amount": 8998, "currency": "USD" }
]
}
}
]
}'
Keep these payload details in mind:
Monetary values must format as integers in minor currency units. For an $89.98 order in USD, pass 8998. Passing decimals like 89.98 will trigger an API validation error.
Timestamps must represent epoch milliseconds falling within the last 7 days.
Pass the click identifier (oppref) by reading it from the user's initial browser cookie and attaching it to the order cart attributes or note attributes during checkout.
Forwarding the click token (oppref)
The trickiest part of manual Shopify tracking is passing the client's oppref cookie into the backend webhook payload.
The cleanest technique is writing __oppref into a hidden cart attribute using client JavaScript before the shopper hits checkout:
fetch('/cart/update.js', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ attributes: { '_oppref': getCookie('__oppref') } })
});
When Shopify emits the orders/create webhook, attributes._oppref sits right inside the JSON payload, making it easy for your backend server to forward it to OpenAI for ad click attribution.
Event deduplication
To prevent duplicate conversion counts when both your sandboxed web pixel and your backend webhook report the purchase, share an identical order identifier:
Set event_id to shopify_order_{order.id} on the client pixel call.
Set id to shopify_order_{order.id} on the server CAPI call.
OpenAI reconciles the twin payloads using this matching key, merging them into a single verified conversion.
Automated setup with the Shopify app
If managing pixel sandboxes, webhook listeners, and edge workers is more infrastructure than you want to maintain, our free Shopify app, Pixel OpenAI Ads & ChatGPT Ads, handles the whole pipeline out of the box.
Setup takes under two minutes: install the app from the Shopify App Store, enter your Pixel ID from Ads Manager, and hit save. The app injects storefront scripts, configures Customer Events, and dispatches server-side purchase webhooks automatically with built-in deduplication.
Verifying your integration
Before putting real ad spend behind campaigns, walk through these checks:
On product pages, open browser DevTools, switch to the Network tab, and verify that calls to bzr.openai.com return an HTTP 202 response.
On cart pages, add an item to the cart and confirm items_added emits with integer amounts and valid item IDs.
During checkout, use Shopify's Customer Events test console to watch your sandboxed pixel triggers dispatch as you navigate through shipping and payment steps.
On order completion, place a test order using a discount code or test payment gateway, check your server logs for an outgoing POST to CAPI, and confirm the sale shows up in OpenAI Ads Manager within a few minutes.
Common Shopify tracking pitfalls
Watch out for these frequent issues:
Theme updates overwriting layout scripts. Updating or switching your active Shopify theme can wipe manual edits in theme.liquid. Always spot-check that the pixel snippet is intact after publishing theme changes.
Duplicate tracking apps running simultaneously. Multiple third-party apps injecting their own OpenAI scripts can double-count visitor traffic. Stick to a single source of truth for your pixel.
Cookie consent banners blocking tags. If your store uses a GDPR or CCPA cookie app, make sure bzrcdn.openai.com and bzr.openai.com are whitelisted so scripts can run for consenting shoppers.
Unpublished custom pixels. Sandboxed pixels won't fire until you explicitly click Connect inside the Customer Events dashboard.
Webhook delivery timeouts. If your server takes too long to process order webhooks, Shopify may drop the retry. Have your webhook endpoint return a quick HTTP 200 immediately, then process the CAPI dispatch asynchronously.
Missing attribution tokens. If purchases show up in Ads Manager under direct traffic instead of ad campaigns, verify that your cart attribute script is successfully writing _oppref to customer orders.
Before turning on live Shopify campaigns, pin OpenAI Ads Pixel Helper in Chrome to check storefront oaiq loading and confirm outgoing requests to bzr.openai.com through checkout.
If you prefer an automated Theme App Embed, sandboxed Web Pixel, _oppref cart stitching, and encrypted webhook queue without touching Liquid files, deploy our free Y OpenAI Ads Pixel ChatGPT Ads Shopify app.
Our ecommerce tracking service also offers end-to-end audit, setup, and validation for complex Shopify setups, including multi-currency and headless Hydrogen stores.
Need ChatGPT tracking installed?
Configured, tested, documented.