How to Track Shopify Product Views, Add-to-Cart, Checkout, and Purchases
Shopify's web pixel events and OpenAI Ads' standard events aren't named the same thing, but they map cleanly: product_viewed becomes contents_viewed, product_added_to_cart becomes items_added, and so on. Here's the full mapping, where each event fires, and how to implement it with a custom pixel or the free Comercio app.
Before deploying tracking tags on your Shopify store, you need an exact translation layer between Shopify storefront actions and OpenAI Ads standard events.
Mapping events incorrectly ruins your campaign optimization. If an add-to-cart action is accidentally sent as checkout_started, OpenAI's machine learning models will optimize your ad spend toward early cart clicks while treating them as checkout initiations.
OpenAI Ads enforces strict naming conventions and schema definitions: contents_viewed, items_added, checkout_started, and order_created.
Here is the exact technical mapping between Shopify Customer Events and OpenAI Ads standard events, complete with implementation code and testing protocols.
Shopify to OpenAI Ads event mapping
Shopify's Customer Events API and OpenAI's measurement telemetry track the exact same customer journey under different schema structures:
Shopify's page_viewed maps directly to OpenAI's page_viewed for storefront navigation.
Shopify's product_viewed maps to OpenAI's contents_viewed for product detail views.
Shopify's product_added_to_cart maps to OpenAI's items_added for cart additions.
Shopify's checkout_started maps to OpenAI's checkout_started for checkout progress.
Shopify's checkout_completed maps to OpenAI's order_created for final purchases.
While page_viewed and checkout_started share identical event strings across both systems, their underlying data structures differ. Shopify emits data formatted around its GraphQL merchandise objects, whereas OpenAI expects its standard contents schema (amount, currency, and an array of contents objects). Mapping requires data transformation rather than a simple pass-through.
Event definitions and payload parameters
When a shopper loads an individual product page, fire contents_viewed. Avoid firing this event on catalog or collection grid views. The payload should carry the product id, item price in minor units, and currency.
When an item successfully enters the shopping cart, fire items_added. Firing should bind to confirmed API responses instead of initial button clicks. The payload carries the added item's unit price in minor units, currency, and line item quantity.
When the customer launches checkout, fire checkout_started. On Shopify, this executes within sandboxed Customer Events. The payload includes the cart subtotal in minor units, currency, and an array of all line items.
Upon order finalization, fire order_created. Because browser-side execution can drop during payment gateway redirects, pair this event with backend webhook CAPI dispatches for complete attribution.
Across all four events, monetary amounts must format as minor-unit integers (12999 for $129.99 USD) accompanied by a three-letter ISO currency code.
Custom pixel implementation
Because Shopify isolates checkout templates, scripts in theme.liquid cannot access checkout interactions. The supported integration path is creating a Custom Pixel in Shopify Admin under Settings > Customer Events:
// Re-initialize oaiq inside the sandboxed Customer Events context
window.oaiq = window.oaiq || function () {
(window.oaiq.q = window.oaiq.q || []).push(arguments);
};
oaiq("init", { pixelId: "YOUR-PIXEL-ID" });
analytics.subscribe("product_viewed", (event) => {
const product = event.data.productVariant;
oaiq("measure", "contents_viewed", {
type: "contents",
currency: product.price.currencyCode,
amount: Math.round(product.price.amount * 100),
contents: [{ id: String(product.product.id), quantity: 1 }]
});
});
analytics.subscribe("product_added_to_cart", (event) => {
const line = event.data.cartLine;
oaiq("measure", "items_added", {
type: "contents",
currency: line.merchandise.price.currencyCode,
amount: Math.round(line.merchandise.price.amount * 100) * line.quantity,
contents: [{ id: String(line.merchandise.id), quantity: line.quantity }]
});
});
analytics.subscribe("checkout_started", (event) => {
const checkout = event.data.checkout;
oaiq("measure", "checkout_started", {
type: "contents",
currency: checkout.totalPrice.currencyCode,
amount: Math.round(checkout.totalPrice.amount * 100),
contents: checkout.lineItems.map((item) => ({
id: String(item.variant.id),
quantity: item.quantity
}))
});
});
Because Shopify exposes prices as decimal floats, apply Math.round(price.amount * 100) to ensure values format as clean minor-unit integers.
Securing purchase telemetry with server CAPI
Client-side checkout_completed events remain vulnerable to browser ad blockers, Safari 24-hour cookie restrictions, and early tab exits during gateway redirects.
To ensure 100% order capture, register an orders/create webhook in Shopify that posts directly to the Conversions API endpoint:
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": "order_1001",
"type": "order_created",
"timestamp_ms": 1755446400000,
"oppref": "<value captured from __oppref cookie or cart attribute>",
"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" }
]
}
}
]
}'
To prevent double-counting when both the custom pixel and the backend webhook capture the transaction, pass the Shopify order ID as the shared identifier: set event_id on the client pixel and id on the server payload.
To maintain campaign attribution on server events, capture the __oppref cookie during the customer's browsing session and store it in cart attributes before checkout begins so it is accessible in the orders/create webhook payload.
No-code deployment option
For merchants seeking an automated solution, our free Shopify app, Pixel OpenAI Ads & ChatGPT Ads, deploys this entire architecture automatically: mapping Customer Events, converting currency units, and transmitting deduplicated server-side purchase webhooks.
Pre-launch testing checklist
Validate your tracking pipeline before directing campaign traffic:
Perform a complete test purchase across product, cart, checkout, and confirmation steps.
Verify in browser developer tools that product views and cart additions dispatch to bzr.openai.com returning HTTP 202.
Check Shopify Customer Events testing tools to confirm that the custom pixel executes on checkout templates.
Verify server logs to confirm that the orders/create webhook dispatches an outbound CAPI payload with integer minor units.
Confirm that the test conversion appears in OpenAI Ads Manager's event stream within a few minutes.
Common pitfalls to avoid:
Do not fire contents_viewed on collection or category listing pages. It should execute only when viewing a specific product.
Ensure currency accompanies every event containing an amount.
Always pass amounts as minor-unit integers ($89.98 formatted as 8998), never as floating decimals.
Review our Shopify debugging guide if events fail to appear in Ads Manager.
If your Shopify store needs full page_viewed, contents_viewed, Ajax items_added, checkout_started, and order_created coverage without editing theme templates, install Y OpenAI Ads Pixel ChatGPT Ads free from the Shopify App Store.
Before shoppers abandon a product detail view due to unanswered delivery or sizing questions, reinforce confidence right next to Add to Cart with FAQbucket: Product FAQ Page AI.
To make long Shopify product pages and editorial guides easier to scan for both mobile shoppers and automated crawlers, add visible semantic HTML TL;DR blocks free with xGeo: AI Product & LLM SEO AEO.
Need ChatGPT tracking installed?
Configured, tested, documented.