Get Started Get Started

Setting Up E-commerce Tracking for OpenAI Ads

OpenAI Ads e-commerce tracking lets you measure completed orders and their transaction values. This setup uses Google Tag Manager, so the OpenAI Ads Pixel must already be installed on your Oncord website through Google Tag Manager before you continue.

How E-commerce Tracking Works

When a customer places an order, Oncord generates a purchase event on the order success page and passes the transaction ID, order value and currency through the data layer.

By creating an OpenAI Ads e-commerce conversion tag in Google Tag Manager, you can send this information to OpenAI Ads Manager to measure:

  • Purchase conversions.
  • Revenue attributed to OpenAI Ads.
  • Return on ad spend (ROAS).
  • E-commerce campaign performance.

Before You Begin

Before getting started, make sure you have:

You will also need the Pixel ID associated with your OpenAI Ads data source.

Create the Purchase Event Trigger

First, create a trigger that detects the purchase event Oncord generates after an order is placed.

  • Log in to your Google Tag Manager account.
  • Select the container installed on your Oncord website.
  • Click Triggers in the left menu.
  • Click New.
  • Enter a meaningful trigger name, such as OpenAI Ads Purchase Event.
  • Click Trigger Configuration.
  • Select Custom Event.
  • Enter purchase in the Event name field.
  • Under This trigger fires on, select Some Custom Events.
  • Set the condition to {{Event}} equals purchase.
  • Click Save.

Create the Order Data Variables

Next, create Data Layer Variables that retrieve the transaction ID, order value and currency from the Oncord purchase event.

Create the Order ID Variable

  • Click Variables in the left menu.
  • Under User-Defined Variables, click New.
  • Enter Order ID as the variable name.
  • Click Variable Configuration.
  • Select Data Layer Variable.
  • Enter ecommerce.transaction_id in the Data Layer Variable Name field.
  • Select Version 2 for the Data Layer Version.
  • Click Save.

This variable returns the Oncord order number, the same number shown to the customer on the order success page. OpenAI uses it as the Event ID to recognise repeated submissions of the same order. This matters because a customer who refreshes the order success page causes the purchase event to be sent again, and the Event ID is what lets OpenAI discard the duplicate.

Create the Order Value Variable

  • Under User-Defined Variables, click New.
  • Enter Order Value as the variable name.
  • Click Variable Configuration.
  • Select Data Layer Variable.
  • Enter ecommerce.value in the Data Layer Variable Name field.
  • Select Version 2 for the Data Layer Version.
  • Click Save.

This variable returns the order total as text, with the number of decimal places used by the order's currency. An order worth AUD 100.00 returns 100.00.

Create the Order Currency Variable

  • Under User-Defined Variables, click New.
  • Enter Order Currency as the variable name.
  • Click Variable Configuration.
  • Select Data Layer Variable.
  • Enter ecommerce.currency in the Data Layer Variable Name field.
  • Select Version 2 for the Data Layer Version.
  • Click Save.

This variable returns the three-letter currency code associated with the order, such as AUD, USD or EUR.

Convert the Order Amount

OpenAI requires monetary values to be sent as whole numbers in the currency's smallest unit. For currencies with two decimal places, this means converting the value into cents.

For example:

  • AUD 100.00 is sent as 10000.
  • AUD 42.50 is sent as 4250.
  • AUD 9.99 is sent as 999.

To perform this conversion, create a Custom JavaScript variable:

  • Under User-Defined Variables, click New.
  • Enter Order Amount as the variable name.
  • Click Variable Configuration.
  • Select Custom JavaScript.
  • Enter the following code:

function() {
return Math.round(Number({{Order Value}}) * 100);
}

  • Click Save.

This example uses AUD, which has two decimal places and therefore needs the order value multiplied by 100.

Using Another Currency

If your website sells in another currency, check its ISO 4217 minor unit and adjust the multiplier:

  • Minor unit of 2 - Multiply by 100. This covers most currencies, including USD and EUR.
  • Minor unit of 0 - Do not multiply. JPY is the common example.
  • Minor unit of 3 - Multiply by 1,000. KWD is the common example.

For the full list, see the OpenAI supported event specification and the ISO 4217 currency standard.

Create the OpenAI Ads Order Tag

After creating the trigger and variables, create the tag that sends the completed order to OpenAI Ads Manager.

  • Click Tags in the left menu.
  • Click New.
  • Enter a meaningful tag name, such as OpenAI Ads Order Created.
  • Click Tag Configuration.
  • Select OpenAI Ads Measurement Pixel under the Custom tag types.

Note: If the tag type is not listed, add it from the Community Template Gallery by searching for OpenAI Ads Measurement Pixel.

Configure the tag as follows:

  • Enter your OpenAI Ads Pixel ID in the Pixel ID field.
  • Select Send a measurement event when this tag fires.
  • Select Order created as the event name.
  • Click the + button next to Event ID and select Order ID.
  • Click the + button next to Amount and select Order Amount.
  • Click the + button next to Currency and select Order Currency.
  • Leave the optional Contents fields empty unless you also want to send individual product details.

Assign the Purchase Trigger

  • Click Triggering.
  • Select the OpenAI Ads Purchase Event trigger you created earlier.
  • Click Save.

The tag now fires when Oncord generates the purchase event after an order is placed.

Test the Purchase Event

Test the configuration before publishing it.

Use Google Tag Manager Preview Mode

  • Click Preview in Google Tag Manager.
  • Enter your Oncord website URL and connect Tag Assistant.
  • Place a test order on your website.
  • In Tag Assistant, select the purchase event.
  • Confirm that the OpenAI Ads Order Created tag fired successfully.
  • Open the Variables tab for the purchase event.
  • Confirm that Order ID, Order Value, Order Amount and Order Currency contain the expected values.

For an AUD 100.00 test order, the expected values are:

  • Order Value: 100.00
  • Order Amount: 10000
  • Order Currency: AUD

If the tag fails with a message stating that the amount must be a whole number in minor currency units, check that the tag uses Order Amount rather than Order Value.

Publish the Changes

Once the purchase tag fires correctly:

  • Return to Google Tag Manager.
  • Click Submit.
  • Enter a version name and description.
  • Publish the container changes.

OpenAI Ads Manager can now receive completed order events and transaction values from your Oncord website.