Server-Side Tag Management: Third-Party Tools, Triggers, Consent, and Web API
How Cloudflare Zaraz loads analytics and marketing tags at the edge, with tools, triggers, consent, and verification.
This page summarises Cloudflare Zaraz documentation: an edge-hosted way to control third-party analytics, advertising, chat, and marketing tools without loading their scripts directly in the browser. Zaraz is aimed at site owners who want faster pages, tighter privacy controls, and one place to wire tags to events—similar goals to a tag manager, but with server-side execution on the CDN.
Offload third-party tools and services to the cloud and improve the speed and security of your website.
— Cloudflare, Cloudflare Zaraz
Cloudflare Zaraz gives you complete control over third-party tools and services for your website, and allows you to offload them to Cloudflare’s edge, improving the speed and security of your website. With Cloudflare Zaraz you can use it to load tools such as analytics tools, advertising pixels and scripts, chatbots, marketing automation tools, and more, in the most optimized way.
— Cloudflare, Cloudflare Zaraz
Zaraz accounts, zones, and Tag setup in the dashboard
Section titled “Zaraz accounts, zones, and Tag setup in the dashboard”Cloudflare organises settings across accounts, zones, and profiles. A zone is a domain (or subdomain) on Cloudflare; zone-level products such as cache rules apply only to that hostname. Account-level products—including Workers and bulk redirects—can span multiple zones in the same account.
Zaraz configuration recently moved in the dashboard: you can open Tag Management at account level to compare settings across zones, then pick a zone under Tag setup to edit that site’s tools, triggers, and consent. Existing zone configurations and entitlements are unchanged by the UI move.
| Layer | What you configure there for Zaraz |
|---|---|
| Account | Tag Management overview; workers used by Context Enricher or Custom Managed Components |
| Zone | Tag setup: tools, triggers, variables, consent, monitoring for one domain |
Third-party tools: what Zaraz loads and how
Section titled “Third-party tools: what Zaraz loads and how”Zaraz maintains a catalog of third-party tools (analytics, ads, CDPs, embeds) plus Custom HTML, Custom Image, and HTTP Request for bespoke integrations. Native integrations run at the edge; the FAQ states that tools load server-side, so browser extensions often cannot “see” vendor pixels the way they would with client-side tags.
Zaraz is loading tools server-side, which means code running in the browser will not be able to see it. Running tools server-side is better for your website performance and privacy, but it also means you cannot use normal browser extensions to debug your Zaraz tools.
— Cloudflare, FAQ
For Google Analytics, Zaraz can collect data without loading the GA script on the page; not every GA feature is available that way (see Zaraz FAQ for gaps). E-commerce events can be forwarded automatically to supported vendors once tracking is enabled in Settings and per tool.
E-commerce stores and web asset performance use cases highlight the same pattern: load analytics and marketing tags through Cloudflare to avoid blocking render.
Pricing: Zaraz pricing includes 1,000,000 free “Zaraz Events” per month per account; a pageview, zaraz.track(), and similar each count as one event.
Events, triggers, and actions: when a tag fires
Section titled “Events, triggers, and actions: when a tag fires”Zaraz decides what runs through events, triggers, and actions—described in Get started and Triggers and rules.
- Events arrive via the built-in Pageview, the Web API, optional data layer compatibility, or HTTP Events API from servers and apps.
- Triggers are named sets of rules; all rules in a trigger must match (create a trigger).
- Actions belong to a tool; firing triggers start the action when any selected trigger matches (create an action).
Tools that support Automatic Actions can ship with Pageviews, Events, or E-commerce presets; otherwise you configure custom actions manually.
Match rules and click listeners
Section titled “Match rules and click listeners”Match rules compare a property (for example Event Name equals purchase after zaraz.track("purchase", …)). For URL- or cookie-based logic on ordinary page loads, combine match rules with Event Name equals Pageview so the trigger does not fire on every event on the page.
Click listeners fire on CSS selectors or XPath; include # or . in CSS selectors. Optional “Wait for actions” delays navigation so beacons can complete.
Blocking Triggers vs turning Zaraz off
Section titled “Blocking Triggers vs turning Zaraz off”Blocking Triggers prevent specific actions from starting when a condition is true; if any blocking trigger is true, the action does not fire. Other actions without those blocking triggers still run. Zaraz still loads on the page.
Blocking Triggers are triggers that instead of being used to define when to start an action, are used to define when to not start an action.
— Cloudflare, Blocking Triggers
To block every action in a tool, attach blocking triggers to each action. To skip Zaraz entirely on certain URLs or requests, use Load Zaraz selectively with Configuration Rules, or set disable_zaraz: true in configuration rule settings.
Variables, fields, and Workers
Section titled “Variables, fields, and Workers”Variables (string, masked, or Worker-backed) feed triggers and tool fields. Additional fields send extra data per action or as defaults for all actions in a tool. Worker Variables and the Context Enricher compute or enrich the Zaraz Context (system and client) before data reaches vendors. JSONata can transform context in action fields using {{ expression }}.
Web API: zaraz.track, zaraz.set, and e-commerce
Section titled “Web API: zaraz.track, zaraz.set, and e-commerce”The Web API runs in the page <body>.
Track — custom events:
zaraz.track("purchase", { value: 200, currency: "USD" });Create a trigger with Variable name Event Name, operation Equals, Match string purchase, then reference {{ client.value }} in actions (Track).
Set — attach keys to all later track calls:
zaraz.set("userId", "ABC-123");Optional scope: page, session, or default persist (Set).
E-commerce — journey events after enabling tracking in Settings and the tool:
zaraz.ecommerce("Order Completed", { order_id: "817286897056801", total: 30.0, currency: "USD", products: [/* … */] });SPA sites can call zaraz.spaPageview() for manual pageviews (FAQ).
Server-side events: configure a unique path under Settings → Endpoints → HTTP Events API, then POST JSON with an events array; use __zarazTrack as event name and __zarazEcommerce: true for e-commerce-shaped payloads.
Debug: enable debug mode with zaraz.debug("YOUR_DEBUG_KEY") from the console after copying the key from Settings.
Consent management and Google Consent Mode
Section titled “Consent management and Google Consent Mode”The Consent Management platform (CMP) helps meet GDPR and ePrivacy expectations: you define purposes, assign each tool to exactly one purpose, and collect opt-in consent before non-essential tools run.
Purpose: The reason you are loading a given tool on your website, such as to track conversions or improve your website’s layout based on behavior tracking. One purpose can be assigned to many tools, but one tool can be assigned only to one purpose.
— Cloudflare, Consent management
New tools have no purpose by default and may run without consent until you assign purposes in Enable Consent Management. Preferences live in a first-party JSON cookie (true / false / missing). IAB TCF is opt-in for EEA/UK ad scenarios.
The Consent API exposes zaraz.consent.get, set, getAll, sendQueuedEvents(), and events zarazConsentAPIReady and zarazConsentChoicesUpdated. Show the modal again with zaraz.showConsentModal() or by changing the consent cookie name (FAQ).
Google Consent Mode v2 can default via Settings or zaraz.set("google_consent_default", { … }) in page HTML (not Custom HTML), then update with google_consent_update when the user chooses. Verify in the debugger that Google requests include the gcd parameter.
Custom CSS styles the modal. Combine CMP with region logic using system.device.location in Custom HTML as documented on the Consent API page.
Zaraz settings, preview, and common mistakes
Section titled “Zaraz settings, preview, and common mistakes”Key Settings toggles:
| Setting | Effect if misconfigured |
|---|---|
| Auto-inject script | Off → you must add /cdn-cgi/zaraz/i.js manually (load manually) |
| Automatic Pageview Tracking | Off → fire Pageview yourself or via consent integration |
| Single Page Application support | Off → virtual navigations may not count as pageviews |
| Data layer compatibility | Off → dataLayer.push is not translated to zaraz.track |
| E-commerce tracking | Off → zaraz.ecommerce() returns undefined (FAQ) |
| Preview & Publish | On → test with zaraz.preview("<YOUR_DEBUG_KEY>") before Publish |
Common mistakes
- Leaving new tools without a consent purpose while CMP is enabled elsewhere.
- Using Blocking Triggers when the goal is to disable Zaraz on whole paths (use Configuration Rules or selective loading).
- Running Rocket Loader alongside Zaraz (Cloudflare recommends disabling Rocket Loader).
- Expecting full GA4 “enhanced measurement” automatically—Zaraz may only report Page View, Session Start, and First Visit unless you add triggers and actions (FAQ).
- Loading Google Tag Manager inside Zaraz (not recommended: tags inside GTM are not optimised or restricted by Zaraz privacy controls).
- Duplicating legacy third-party scripts on the page while also routing through Zaraz (FAQ).
Import & export backs up configuration; import replaces the current config. Advanced options cover selective loading, manual load, Logpush, and Custom Managed Components.
How to check this on your site
Section titled “How to check this on your site”-
Open your site, open developer tools, and type
zarazin the console. If you see “zaraz is not defined”, confirm the zone is proxied, Auto-inject script is on (or the script tag is present), HTML has valid<head>, and at least one tool is enabled—per FAQ. -
Copy your debug key from Zaraz Settings, run
zaraz.debug("YOUR_DEBUG_KEY")as in debug mode, and confirm triggers and server-side requests for your test actions. -
In the dashboard, open Monitoring and check Loads, Events, Triggers, Actions, and Server-side requests for the time range where you tested.
-
If you use consent or Google tags, grant or deny test consent and verify queued events with
zaraz.consent.sendQueuedEvents()where applicable (Consent API); for Consent Mode v2, confirmgcdon Google-bound requests (Google Consent Mode). -
You can check automatically in Answerwell (our tool): https://answerwell.org/workspace
Report an error or ask a question
Section titled “Report an error or ask a question”If something on this page does not match your setup or the official docs, email yimasynthetic@gmail.com with the page URL and the exact wording you think is wrong. We will clarify or correct it.