Tag Managers, CDPs & Server-Side Automation Cloudflare Zaraz

Cloudflare Zaraz: Edge-Side OpenAI Ads Pixel and CAPI Setup with Cloudflare Zaraz

By: Comercio Services Engineering Team
Updated: 26/04/26
Share

Adding heavy third-party JavaScript tags directly to client templates degrades core page speed metrics and mobile responsiveness.

Cloudflare Zaraz provides an alternative approach by executing analytics and advertising tags within Cloudflare's edge worker infrastructure instead of the visitor's browser.

Because Zaraz runs directly on edge nodes, it can handle browser triggers and dispatch outbound server calls to OpenAI's Conversions API without loading external client SDKs. This approach improves page load performance while capturing conversion signals reliably.

Here is how to configure OpenAI Ads as an edge-managed Custom Tool inside Cloudflare Zaraz.

Setting up OpenAI Ads as a Custom Tool in Zaraz

Configure the base tool inside the Cloudflare control panel:

  1. Sign in to your Cloudflare dashboard and select your domain.
  2. In the left navigation menu, open Zaraz and select Tools.
  3. Click Add new tool and choose Custom Tool.
  4. Set the tool name to OpenAI Ads CAPI.
  5. Under permissions, enable HTTP requests and worker execution.

Compare zero-client-SDK edge execution in Zaraz against Google Tag Manager web and server containers and Stape.io managed sGTM.

Creating Zaraz actions for pageviews and conversions

Within your new Custom Tool, create dedicated actions to handle event dispatches:

Pageview action

  1. Under the OpenAI Ads tool, click Add Action.
  2. Set the action name to Pageview.
  3. Choose Pageview as the firing trigger.
  4. Set Action Type to HTTP Request.
  5. Set Request URL to https://bzr.openai.com/v1/events.
  6. Set the HTTP method to POST.
  7. Add headers for Authorization: Bearer YOUR_OPENAI_ADS_ACCESS_TOKEN and Content-Type: application/json.
  8. Construct the request body using Zaraz variables:
{
  "data": [
    {
      "event_name": "PageView",
      "event_time": {{ system.timestamp }},
      "event_id": "zaraz_{{ client.session_id }}_{{ system.timestamp }}",
      "action_source": "website",
      "custom_data": {
        "page_url": "{{ client.url.href }}"
      }
    }
  ]
}

Purchase action

  1. Create a second action named Purchase.
  2. Set the trigger to match your checkout completion event or purchase URL path.
  3. Set Action Type to HTTP Request.
  4. Configure the destination to https://bzr.openai.com/v1/events with your Bearer authentication header.
  5. Format the conversion body using order data:
{
  "data": [
    {
      "event_name": "Purchase",
      "event_time": {{ system.timestamp }},
      "event_id": "cf_order_{{ client.order_id }}",
      "action_source": "website",
      "user_data": {
        "em": "{{ client.user_email | hash: 'sha256' }}"
      },
      "custom_data": {
        "currency": "{{ client.currency }}",
        "value": {{ client.order_value_cents }},
        "order_id": "{{ client.order_id }}"
      }
    }
  ]
}

Triggering Zaraz events from your storefront

From your website templates, dispatch user actions using Zaraz's client API:

zaraz.track("Purchase", {
  order_id: "ORD-92812",
  order_value_cents: 9900,
  currency: "USD",
  user_email: "shopper@example.com"
});

Zaraz receives the local track call, processes variable interpolation at the edge, hashes customer identity data, and delivers the POST request to OpenAI's endpoint without loading third-party vendor scripts in the browser.

Verification checklist

Enable Zaraz Debug Mode from the Cloudflare dashboard to inspect edge execution logs.

Open your browser developer console and verify that zaraz.track calls emit without errors.

Inspect the Network tab to confirm that no bloated third-party JavaScript files are loaded from external ad domains.

Review OpenAI Ads Event Manager to confirm that incoming conversion signals arrive with complete parameter metadata.

Dispatching from Cloudflare Workers recovers signals highlighted in ad-blocker CAPI recovery while keeping bearer secrets off the browser per secure CAPI server boundaries.

Frequently asked questions

What are the performance advantages of using Cloudflare Zaraz for OpenAI Ads?

Zaraz executes tag logic on Cloudflare's edge network instead of in the client browser. This eliminates third-party script bloat, reduces main thread blocking, and improves Core Web Vitals scores.

Does Zaraz require installing OpenAI's JavaScript SDK?

No. Zaraz constructs and transmits HTTP POST requests directly from edge nodes to OpenAI's /v1/events endpoint, bypassing client-side SDK downloads entirely.

How does Zaraz handle customer identity hashing?

You can use Zaraz data masking rules or template transformation filters to calculate SHA-256 hashes of email addresses and phone numbers before dispatching to the ad network.

Can Zaraz track dynamic ecommerce variables like order values?

Yes. You pass transactional parameters into zaraz.track(), and Zaraz injects those properties into the outgoing HTTP payload using its variable interpolation syntax.

Configure Cloudflare Zaraz Edge OpenAI Ads Tracking

Zero-bloat edge telemetry: Cloudflare Zaraz Custom Tool setup, edge payload hashing, and direct CAPI dispatch.