OpenAI Ads Cloud Mode Integration
4 minute read
After you have successfully instrumented OpenAI Ads as a destination in RudderStack, follow this guide to correctly send your events to OpenAI Ads in cloud mode.
Find the open source transformer code for this destination in the GitHub repository.
Track
Use the track call to send conversion events to OpenAI Ads.
A sample track call is shown below:
rudderanalytics.track("Order Completed", {
orderId: "order-123",
revenue: 49.99,
currency: "USD",
action_source: "web",
source_url: "https://www.example.com/checkout/success",
products: [
{
product_id: "sku-123",
name: "T-shirt",
category: "Apparel",
quantity: 1,
price: 49.99,
},
],
});Event mapping
RudderStack uses your event mapping settings to resolve the OpenAI Ads event type for each track event.
- If a configured mapping matches the RudderStack event name, RudderStack sends the event to the mapped OpenAI Ads standard or custom event.
- If no mapping matches and the RudderStack event name already matches a standard OpenAI Ads event ID, such as
order_created, RudderStack sends it as that standard event. - If no mapping matches and the event name is not a standard OpenAI Ads event ID, RudderStack rejects the event.
Page
Use the page call to send web page view events to OpenAI Ads.
A sample page call is shown below:
rudderanalytics.page("Product", "Product Viewed", {
url: "https://www.example.com/products/sku-123",
});RudderStack resolves page events using your event mapping settings. Unmapped page events default to the OpenAI Ads page_viewed event.
Screen
Use the screen call to send mobile screen view events to OpenAI Ads through cloud mode.
A sample screen call is shown below:
rudderanalytics.screen("Home", "Home Viewed");RudderStack resolves screen events using your event mapping settings. Unmapped screen events default to the OpenAI Ads page_viewed event.
Event data fields
RudderStack maps the following top-level event fields to OpenAI Ads:
| RudderStack property | OpenAI Ads field | Notes |
|---|---|---|
properties.action_sourceproperties.actionSourceDefault action source setting | action_source | Optional. Supported values are web, mobile_app, offline, physical_store, phone_call, email, and other. |
properties.source_urlproperties.sourceUrlcontext.page.url | source_url | Required when action_source is web. |
properties.oppref | oppref | Optional OpenAI Ads reference value. |
properties.optOutproperties.opt_out | opt_out | Optional boolean value. |
RudderStack maps the following event data fields:
| RudderStack property | OpenAI Ads field | Notes |
|---|---|---|
properties.amountproperties.valueproperties.revenue | data.amount | Converted to the currency’s minor units when currency is available. |
properties.currencyDefault currency setting | data.currency | Required when amount is present. |
properties.contentsproperties.products | data.contents | Sent for contents, plan_enrollment, and custom event data shapes. Not sent for customer_action events. |
For each item in properties.contents or properties.products, RudderStack maps the following fields:
| RudderStack property | OpenAI Ads field |
|---|---|
idcontent_idcontentIditem_iditemIdproduct_idproductIdsku | id |
nametitleproduct_nameproductName | name |
content_typecontentTypetypecategoryproduct_category | content_type |
group_idgroupId | group_id |
variant_dictvariantDict | variant_dict |
quantitycount | quantity |
amountvalueprice | amount |
currencycurrency_codecurrencyCode | currency |
User matching fields
How RudderStack processes the following user matching fields depends on the Enable hashing setting:
| RudderStack property | OpenAI Ads field |
|---|---|
traits.emailscontext.traits.emailstraits.emailcontext.traits.email | emails_sha256 |
traits.phoneNumberscontext.traits.phoneNumberstraits.phone_numberscontext.traits.phone_numberstraits.phonescontext.traits.phonestraits.phonecontext.traits.phone | phone_numbers_sha256 |
userIdanonymousId | external_ids_sha256 |
traits.firstNamescontext.traits.firstNamestraits.first_namescontext.traits.first_namestraits.firstNametraits.first_namecontext.traits.firstNamecontext.traits.first_name | first_names_sha256 |
traits.lastNamescontext.traits.lastNamestraits.last_namescontext.traits.last_namestraits.lastNametraits.last_namecontext.traits.lastNamecontext.traits.last_name | last_names_sha256 |
Note that:
- When Enable hashing is enabled (the default), send raw values in the source fields listed above. RudderStack normalizes and hashes the values and rejects apparent pre-hashed input.
- When Enable hashing is disabled, each value supplied for these five
*_sha256fields must already be normalized and SHA-256 hashed. RudderStack does not normalize these values. If a supplied value isn’t hashed, RudderStack rejects it and the entire cloud mode event fails.
RudderStack lowercases every hash value it sends, whether it hashed the value itself or received it pre-hashed.
- For
external_ids_sha256, RudderStack usesuserIdwhen available and falls back toanonymousId. When hashing is disabled anduserIdis absent, RudderStack still hashes the SDK-generatedanonymousIdautomatically because it isn’t pre-hashed. - RudderStack also forwards the following non-hashed matching fields when present:
regions,postal_codes,cities,countries,obref,android_advertising_id,ip_address, anduser_agent.
See the identifier normalization rules section for more information.