OpenAI Ads Conversions API Tag for Google Tag Manager Server-Side

The OpenAI Ads Conversions API Tag for Google Tag Manager Server-Side allows you to send conversion event data from your server container directly to the OpenAI Ads Conversions API. This server-to-server integration provides a more reliable and privacy-compliant way to track conversions for OpenAI (ChatGPT) ad campaigns compared to pixel-only setups.

Features

  • Server-to-Server Events: Sends conversion data directly from the GTM Server Container to the OpenAI Ads Conversions API.
  • Flexible Event Mapping: Supports standard OpenAI event types, inherits and maps from GA4 event names automatically, or sends fully custom event names.
  • Automatic Data Mapping: Intelligently maps parameters from incoming GTM event data for server event data, user identifiers, and event parameters.
  • Click ID Cookie Management: Automatically reads and sets the __oppref (Click ID) cookie server-side to improve attribution.
  • PII Hashing: Automatically hashes email addresses and User IDs using SHA-256 before sending. Pre-hashed values are accepted and will not be re-hashed.
  • Consent Mode Support: Integrates with Google Consent Mode, checking for ad_storage consent before sending data.

Installation

  1. Import the template from the GTM Template Gallery:
    • Add the OpenAI Ads Conversions API by Stape tag to your GTM container from the GTM Template Gallery.
  2. Import to GTM Server Container:
    • In your GTM Server Container, navigate to the Templates section.
    • Click New under the Tag Templates section.
    • Click the three-dot menu in the top right and select Import.
    • Select the downloaded template.tpl file and click Save.
  3. Create a New Tag:
    • Go to Tags and click New.
    • Select the newly imported “OpenAI Ads Conversions API by Stape” template.

Tag Configuration

Base Configuration

Parameter Description
Event Name Setup Method Choose Standard to select a predefined event type, Inherit from client to automatically map from GA4 event names, or Custom to enter a custom event name. Regardless of the method chosen, the resulting event name is always checked against the Standard Event Types list below: if it matches, the event is sent as that Standard Event; if it doesn’t, the event is sent as a Custom Event (custom_event_name set to that value).
Pixel ID Your OpenAI Pixel ID from your ad account.
API Key Your OpenAI API Key, provided by the OpenAI Account team.
Action Source Where the event occurred: Web, Mobile App, Offline, Physical Store, Phone Call, or Email.
Validate Only If true, the event is sent in test mode and excluded from measurement.
Use Optimistic Scenario If enabled, the tag fires gtmOnSuccess() immediately without waiting for the API response, speeding up server response time.

Standard Event Types

Event Name
page_viewed
app_installed
app_opened
appointment_scheduled
checkout_started
contents_viewed
items_added
lead_created
order_created
registration_completed
subscription_created
trial_started

This list applies no matter which Event Name Setup Method is used: whenever the resolved event name (from Standard, Inherit from client, or Custom) matches one of the names above, the event is sent as that Standard Event; otherwise, it is sent as a Custom Event with custom_event_name set to the resolved name.

GA4 → Conversions API Event Name Mapping (Inherit from client)

When using Inherit from client, the following GA4 event names are mapped:

GA4 Event Name OpenAI Conversions API Event Type
page_view page_viewed
view_item contents_viewed
add_to_cart items_added
begin_checkout checkout_started
purchase order_created
generate_lead lead_created
sign_up registration_completed
Any other GA4 event that matches a Standard Event Type that Standard Event Type
Any other GA4 event custom (with custom_event_name set)

Custom Event Name Requirements

  • Maximum 64 characters
  • Accepted characters: lowercase alphanumeric, _, and -
  • If the entered name matches a Standard Event Type, it is sent as that Standard Event instead of a Custom Event

Click ID Cookie Settings

Controls how the tag handles the OpenAI Click ID (oppref).

Parameter Description
Set Click ID cookie If true, the Click ID is sent in the request and stored as the __oppref cookie by server GTM. If false, the Click ID is still sent if found but not stored as a cookie.
Cookie Domain Override the cookie domain. Defaults to auto, which resolves via page_location, Referer, or Host headers.
Cookie SameSite None, Lax (default), or Strict.
Cookie HTTP Only Whether to set the HttpOnly flag on the cookie. Defaults to false.
Cookie Expiration Number of days until the cookie expires. Defaults to 30.

The Click ID (oppref) is sourced in the following priority order:

  1. User Identifiers Parameters section (manual override)
  2. oppref URL parameter
  3. __oppref cookie
  4. common_cookie.__oppref Event Data parameter
  5. __oppref Event Data parameter
  6. oppref Event Data parameter

Server Event Data Parameters

Parameter Description
Opt Out When true, the event is marked as opted out.
Automap Server Event Data Parameters If enabled, automatically sets Event Timestamp (Unix timestamp in ms), Source URL (from eventData.page_location), Event ID (from eventData.event_id or eventData.eventId), and Click ID (from oppref sources).
Server Event Data Parameters Manually override or add Event Timestamp, Event ID, Click ID, and Source URL. Manual values always take precedence over auto-mapped ones.

Note: Timestamp cannot be more than 7 days in the past or 10 minutes into the future. Source URL is required when Action Source is set to Web.

User Data Parameters

Parameter Description
Automap User Data Parameters If enabled, automatically maps Email, Phone Number, City, ZIP Code, Region, Country, First Name, Last Name, External ID, IP Address, User Agent, and Android Advertising ID from the Event Data.
User Identifiers Parameters Manually specify user identifiers. Supported fields: Email Addresses, Phone Numbers, External ID, External IDs SHA256 Hashed, First Names, Last Names, Cities, ZIP Codes, Regions/States, Countries, IP Address, User Agent, Android Advertising ID (GAID).

Email, Phone Number, External ID, First Name, Last Name, City, ZIP Code, Region, and
Country all accept more than one value: auto-mapping preserves every value found when
the underlying Event Data field is an array (for example, more than one user_data.address
record), and a manual entry can be bound to a variable that returns an array instead of a
single string. IP Address, User Agent, Browser ID, and Android Advertising ID
only ever accept a single value.

Auto-mapping sources:

Field Event Data Sources
Email email, email_address, user_data.email, user_data.email_address, user_data.sha256_email_address
Phone Number phone_number, user_data.phone_number
External ID user_id
First Name user_data.address.first_name
Last Name user_data.address.last_name
City user_data.address.city
ZIP Code user_data.address.postal_code
Region user_data.address.region
Country user_data.address.country
IP Address ip_override
User Agent user_agent
Android Advertising ID x-ga-resettable_device_id (only when x-ga-platform is android; an all-zero GUID is ignored)

The tag automatically hashes the following fields using SHA-256 before sending: Email,
Phone Number, External ID, First Name, Last Name. Pre-hashed values (64-character hex
strings) are detected and will not be re-hashed. City, ZIP Code, Region, and Country are
sent as plain values, not hashed.

Event Parameters

Parameter Description
Automap Event Parameters If enabled, automatically maps Amount (from eventData.value or sum of items price × quantity), Currency (from eventData.currency or items), and Contents (from eventData.items, including item_group_id as group_id).
Custom Item ID Key Optional. Override the item ID field key used when mapping items. Defaults to item_id. Useful for WooCommerce setups.
Event Parameters Manually specify Amount, Currency, Contents, and Plan ID.

Note: Currency is required when Amount is used. Each item in Contents must have content_type defined.

Useful Resources

Open Source

The OpenAI Ads Conversions API Tag for GTM Server-Side is developed and maintained by the Stape Team under the Apache 2.0 license.

GTM Gallery Status

:green_circle: Listed

GitHub

:green_circle: Repository

stape-io/openai-capi-tag — updated: view commit

  • Added “Other” option to a value list for improved categorization
  • Introduced informative labels with links to OpenAI Ads Conversions API documentation for Server Event Data Parameters, User Data Parameters, and Event Parameters to assist users in correct parameter usage
  • Renamed parameter lists for clarity (e.g., serverEventDataList to serverEventDataParametersList)
  • Enhanced auto-mapping help text to clarify amount handling, specifying conversions between regular and lowest currency units
  • Added support for two distinct amount parameter types: “Amount (in the currency’s lowest unit)” and “Amount (in the currency’s regular unit),” with priority rules if both are supplied
  • Updated amount processing logic to convert values from regular units to minor units based on currency, ensuring correct monetary representation
  • Implemented currency-specific conversion handling respecting zero-decimal and three-decimal currency formats (e.g., JPY, BHD)
  • Adjusted event object property names for consistency (event_type

GTM Gallery Status

:red_circle: Not listed

stape-io/openai-capi-tag — updated: view commit

  • Renamed the tag from “OpenAI Ads Events API” to “OpenAI Ads Conversions API” to better reflect its purpose
  • Updated description and documentation references to specify usage with the Conversions API instead of the Events API
  • Clarified event name mappings from GA4 schema to correspond to Conversions API event names, ensuring accurate integration guidance

GTM Gallery Status

:red_circle: Not listed

The template is now available in the GTM Template Gallery.
You can import it in your container by adding a new tag and searching the template from the Gallery.

stape-io/openai-capi-tag — updated: view commit

  • Removed all logging functionality including console and BigQuery log options and settings

GTM Gallery Status

:green_circle: Listed

stape-io/openai-capi-tag — updated: view commit

  • Add validation to require Event ID before proceeding

GTM Gallery Status

:green_circle: Listed

stape-io/openai-capi-tag — updated: view commit

  • Removed phone number fields and hashing from auto-mapping and user data handling
  • Deprecated “External ID” in favor of “External ID SHA256 Hashed” as the primary identifier
  • Limited automatic hashing to only Email Address and External ID SHA256 Hashed parameters
  • Dropped normalization of phone numbers and address fields from user data processing
  • Added backward compatibility to map deprecated fields to their updated SHA256 versions

GTM Gallery Status

:green_circle: Listed

stape-io/openai-capi-tag — updated: view commit

  • Added support for new standard events: app_installed, app_opened, appointment_scheduled, subscription_created, and trial_started
  • Introduced Browser ID (__obref) handling with optional cookie storage and expiration configuration
  • Enhanced event name selection to send unmatched variable values as Custom Events automatically
  • Updated GA4 event name mappings with improved help documentation and post-mapping standardization
  • Improved automatic parameter mapping to include Browser ID along with existing user data fields

GTM Gallery Status

:green_circle: Listed

stape-io/openai-capi-tag — updated: view commit

  • Added stape-sgtm as the integration source identifier

GTM Gallery Status

:green_circle: Listed

stape-io/openai-capi-tag — updated: view commit

  • Updated service account key hint to use the sk-svcacct format
  • Added custom event parameters for custom event names, including support for varied value types

GTM Gallery Status

:green_circle: Listed

stape-io/openai-capi-tag — updated: view commit

  • Expanded automatic user-data mapping to support phone numbers, first/last names, regions, Android Advertising ID, and address arrays
  • Added support for multiple values across hashed identity and geographic fields
  • Added field-specific normalization for emails, phone numbers, names, and external IDs before hashing
  • Added item_group_id mapping to item data and updated parameter labels/help text for the expanded fields

GTM Gallery Status

:green_circle: Listed