Our Expertise
We're paid media specialists at our core, with extensive experience in deploying that knowledge to help challenger brands grow.
Explore our expertise
Getting OpenAI Ads tracking right on Shopify comes down to two things, a base pixel added to your theme, and a purchase tag that fires on the order confirmation step. The two live in different places, so treat them as separate jobs.
At a glance
Shopify’s checkout doesn’t load your theme code, so this step covers every page except the purchase itself, that’s the next section.
1. In Shopify Admin, go to Online Store > Themes.
2. Next to your active theme, click the three-dot menu, then Edit code.
3. In the file list, open theme.liquid under Layout.
4. Find the closing </head> tag and paste the following immediately before it, replacing YOUR_PIXEL_ID with your own.
<!-- OpenAI Ads Base Pixel -->
<script>!function(w,d,s,u){if(w.oaiq)return;var q=function(){q.q.push(arguments)};q.q=[];w.oaiq=q;var j=d.createElement(s);j.async=1;j.src=u;var f=d.getElementsByTagName(s)[0];f.parentNode.insertBefore(j,f)}(window,document,"script","https://bzrcdn.openai.com/sdk/oaiq.min.js");oaiq("init",{pixelId:"YOUR_PIXEL_ID"});</script>
5. Click Save.
Go to Settings > Checkout. If you see a message about your customer accounts domain using the shopify.com domain, use Option B below. Otherwise start with Option A, it covers most stores.
Option A, Additional Scripts, is the most common setup.
1. Go to Settings > Checkout.
2. Scroll to the Order status page section.
3. In the Additional scripts field, paste the following, replacing YOUR_PIXEL_ID with your own.
<!-- OpenAI Ads Purchase Conversion -->
<script>
!function(w,d,s,u){if(w.oaiq)return;var q=function(){q.q.push(arguments)};q.q=[];w.oaiq=q;var j=d.createElement(s);j.async=1;j.src=u;var f=d.getElementsByTagName(s)[0];f.parentNode.insertBefore(j,f)}(window,document,"script","https://bzrcdn.openai.com/sdk/oaiq.min.js");
oaiq("init", { pixelId: "YOUR_PIXEL_ID" });
oaiq("measure", "order_created", { type: "contents" }, { event_id: "{{ order.order_number }}" });
</script>
4. Click Save.
The {{ order.order_number }} tag is a Shopify variable that fills in automatically with each order’s unique number. Leave it exactly as written.
Option B, Customer Events, is for stores that saw the shopify.com domain message. It works regardless of your customer accounts domain setting.
1. Go to Settings > Customer events.
2. Click Add custom pixel.
3. Name it OpenAI Ads.
4. Paste the following as the pixel code, replacing YOUR_PIXEL_ID with your own.
analytics.subscribe('checkout_completed', (event) => {
const checkout = event.data.checkout;
const orderId = (checkout.order && checkout.order.id) ? String(checkout.order.id) : checkout.token;
const script = document.createElement('script');
script.textContent = `
window.oaiq = window.oaiq || function () {
(window.oaiq.q = window.oaiq.q || []).push(arguments);
};
oaiq("init", { pixelId: "YOUR_PIXEL_ID" });
oaiq("measure", "order_created", { type: "contents" }, { event_id: "${orderId}" });
`;
document.head.appendChild(script);
const sdk = document.createElement('script');
sdk.async = true;
sdk.src = 'https://bzrcdn.openai.com/sdk/oaiq.min.js';
document.head.appendChild(sdk);
});
5. Click Save, then Connect.
1. Browse a few pages with your developer console open (right-click, then Inspect, then Console) and confirm activity from the OpenAI pixel with no errors.
2. Enable Shopify’s Bogus Gateway under Settings > Payments, then place a test order with it, no real payment needed.
3. On the confirmation page, check the console for a request to bzrcdn.openai.com confirming the conversion fired.
4. In OpenAI Ads Manager, under Tools > Conversions, confirm the test event shows up within a few minutes.
Final takeaway. The base pixel living in your theme and the purchase tag living in your checkout are two different systems on Shopify, forgetting that is the single most common way this setup goes wrong. Confirm both independently before trusting the numbers.
Part of our OpenAI Ads series
This walkthrough covers Shopify specifically, running the pixel on WordPress and WooCommerce instead? Our dedicated guide on installing the OpenAI Ads pixel on WordPress and WooCommerce walks through that version. And if you haven’t set everything else up yet, our guides on what you need to know before you set up OpenAI Ads and getting your product feed live on OpenAI Ads cover the rest.
If you liked what you saw, please find here some other articles which we believe will be useful for you:
Elsewhere on Addesu
We're paid media specialists at our core, with extensive experience in deploying that knowledge to help challenger brands grow.
Explore our expertiseAt the heart of much of our work. Reporting, tools and alerts systems designed for every paid media professional.
See the platformBuilt from the same platform our own account team runs on.
Upload your account and get an instant health grade, goal balance, and actionable recommendations.
Access the toolTurn raw Google & Microsoft Ads search term data into clear insights, spot wasted spend and new keyword opportunities.
Access the tool