How to install the OpenAI Ads pixel on WordPress and WooCommerce

Getting OpenAI Ads tracking right on a WooCommerce store means two things done in the right order. A base pixel goes on every page, and a purchase tag fires once per order, no more than that. Both can be handled entirely through a free plugin, without touching theme files directly, and is a setup we’ve walked several WooCommerce clients through already.

At a glance

  • Two parts, done in order. A base pixel across every page, then a purchase tag on the order confirmation page only.
  • One free plugin handles both, WPCode, no custom theme editing required.
  • The recommended purchase method uses a WooCommerce hook so each order counts once, even if the confirmation page gets refreshed.
  • A JavaScript-only fallback exists for stores without PHP-snippet access, though it can double-count a purchase on a refresh.

What do you need before you start?


  • Admin access to your WordPress dashboard
  • Your OpenAI Ads Pixel ID, found in Ads Manager under Tools > Conversions
  • A standard WooCommerce checkout, since the setup relies on its built-in order confirmation page

How do you install the base pixel?


The simplest way to get the pixel loading on every page is the free WPCode plugin (formerly Insert Headers and Footers).

1. In WordPress Admin, go to Plugins > Add New.

2. Search for WPCode, then install and activate it.

3. Go to Code Snippets > Headers & Footers.

4. Paste the following into the Header section, replacing YOUR_PIXEL_ID with your own.

<!-- OpenAI Ads Base Pixel -->
<script>
  window.oaiq = window.oaiq || function () {
    (window.oaiq.q = window.oaiq.q || []).push(arguments);
  };
  oaiq("init", { pixelId: "YOUR_PIXEL_ID" });
</script>
<script async src="https://bzrcdn.openai.com/sdk/oaiq.min.js"></script>

5. Click Save Changes. The pixel now loads on every page of your site.

How do you track purchases without double-counting them?


WooCommerce’s built-in order confirmation page (the “Thank You” page) is where the purchase tag needs to fire, and only there.

Option A, a PHP snippet through WPCode, is the one we’d recommend. It hooks into the moment WooCommerce marks an order complete, and passes the order ID along so a refreshed confirmation page never counts the same purchase twice.

1. Go to Code Snippets > Add Snippet, then Add Your Custom Code (New Snippet).

2. Name it something identifiable, e.g. OpenAI Ads Purchase Conversion.

3. Set the code type to PHP Snippet and paste the following.

add_action('woocommerce_thankyou', function($order_id) {
    if (!$order_id) return;
    ?>
    <script>
    oaiq("measure", "order_created", { type: "contents" }, { event_id: "<?php echo esc_js((string) $order_id); ?>" });
    </script>
    <?php
}, 10, 1);

4. Set Insertion to Site Wide, toggle the snippet Active, then save.

Option B is a JavaScript-only fallback, worth using only if PHP snippets aren’t an option. It fires based on the confirmation page’s URL rather than the order itself, so a refreshed page can register the same purchase more than once. Use Option A wherever you can.

if (window.location.pathname.indexOf('/checkout/order-received/') !== -1) {
  oaiq("measure", "order_created", { type: "contents" });
}

Same snippet steps as above apply (new snippet, JavaScript type, Site Wide, Active).

How do you check it’s actually working?


Four checks before trusting the data.

1. Open any page with your browser’s developer console (right-click, then Inspect, then Console) and confirm requests to bzrcdn.openai.com are firing with no errors.

2. Place a test order using a sandbox or Cheque payment method.

3. On the confirmation page, check the console for the conversion request firing.

4. In OpenAI Ads Manager, under Tools > Conversions, confirm the test event shows up within a few minutes.

Final takeaway. The setup itself is quick. Most of the actual risk sits in the details that are easy to skip, firing the tag on the wrong page, or picking the option that double-counts. Getting it right once at the start means every number after that is one you can actually trust.

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