How to install the OpenAI Ads pixel on Shopify

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

  • Two parts, in different places. A base pixel in your theme file, then a purchase tag on the checkout side, which your theme doesn’t cover.
  • The base pixel needs a small theme.liquid edit, there’s no plugin shortcut on Shopify.
  • Which purchase method you need depends on your checkout setup, most stores use Additional Scripts, newer stores on the shopify.com customer domain need Customer Events instead.
  • Test orders use Shopify’s built-in Bogus Gateway, no real payment needed to verify tracking.

What do you need before you start?


  • Access to your Shopify Admin, specifically Online Store > Themes and Settings
  • Your OpenAI Ads Pixel ID, found in Ads Manager under Tools > Conversions
  • A few minutes to check which purchase-tracking option applies to your store, see below

How do you install the base pixel?


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.

How do you know which purchase tracking method you need?


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.

How do you check it’s actually working?


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.

If you liked what you saw, please find here some other articles which we believe will be useful for you:

Smart simplicity starts with a conversation.

Partner with our team of experts to bring clarity to your paid media journey

Find out more about Addesu

Our Expertise

We're paid media specialists at our core, with extensive experience in deploying that knowledge to help challenger brands grow.

Our Platform

At the heart of much of our work. Reporting, tools and alerts systems designed for every paid media professional.

Our Pricing

We tailor pricing to reflect the individual requirements of each customer, favouring a performance model that aligns with their business goals.

Scroll to Top