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 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
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.
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).
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.
Part of our OpenAI Ads series
This walkthrough covers WooCommerce specifically, running the pixel on Shopify instead? Our dedicated guide on installing the OpenAI Ads pixel on Shopify 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