Skip to main content

Overview

Cloudflare Zaraz loads third-party tools like analytics, marketing pixels, and customer support widgets without slowing down your website. Manage configurations, publish changes, and view history.

Initialize the client

import Cloudflare from 'cloudflare';

const client = new Cloudflare({
  apiToken: 'your-api-token',
});

Workflow

Manage Zaraz workflow settings.

Update workflow

Update the Zaraz workflow for a zone.
const workflow = await client.zaraz.update({
  zone_id: '023e105f4ecef8ad9ca31a8372d0c353',
  workflow: 'realtime',
});
zone_id
string
required
Zone identifier
workflow
object
required
Zaraz workflow configuration
id
string
Workflow identifier
settings
object
Workflow settings

Get workflow

Retrieve current workflow configuration.
const workflow = await client.zaraz.workflow.get({
  zone_id: '023e105f4ecef8ad9ca31a8372d0c353',
});

Config

Manage Zaraz configuration.

Update configuration

Update Zaraz configuration for a zone.
const config = await client.zaraz.config.update({
  zone_id: '023e105f4ecef8ad9ca31a8372d0c353',
  // configuration settings
});
zone_id
string
required
Zone identifier

Get configuration

Retrieve current Zaraz configuration.
const config = await client.zaraz.config.get({
  zone_id: '023e105f4ecef8ad9ca31a8372d0c353',
});
tools
array
Configured third-party tools
triggers
array
Event triggers
variables
array
Custom variables

Publish

Publish Zaraz configuration changes.

Publish configuration

Publish pending configuration changes to production.
const result = await client.zaraz.publish.create({
  zone_id: '023e105f4ecef8ad9ca31a8372d0c353',
  description: 'Added Google Analytics 4',
});
zone_id
string
required
Zone identifier
description
string
Description of the changes being published
id
string
Publish identifier
status
string
Publish status
published_at
string
When the configuration was published

History

View Zaraz configuration history.

List history

Retrieve configuration change history.
const history = await client.zaraz.history.list({
  zone_id: '023e105f4ecef8ad9ca31a8372d0c353',
});
zone_id
string
required
Zone identifier
id
string
History entry identifier
description
string
Change description
published_at
string
Publication timestamp
published_by
string
User who published the changes

Update history entry

const entry = await client.zaraz.history.update(
  historyId,
  params
);

Default

Manage default Zaraz settings.

Get default settings

Retrieve default Zaraz configuration.
const defaults = await client.zaraz.default.get({
  zone_id: '023e105f4ecef8ad9ca31a8372d0c353',
});

Export

Export Zaraz configuration.

Export configuration

Export the current Zaraz configuration.
const exported = await client.zaraz.export.get({
  zone_id: '023e105f4ecef8ad9ca31a8372d0c353',
});
zone_id
string
required
Zone identifier
Exported configurations can be used for backup, migration, or version control.

Types

Configuration

Zaraz configuration object.
tools
array
Third-party tools (analytics, marketing, support)
triggers
array
Event triggers that activate tools
variables
array
Custom variables for tool configuration
Consent management settings

NeoEvent

Tool event configuration.
actionType
string
Tool event type
blockingTriggers
string[]
List of blocking trigger IDs
firingTriggers
string[]
List of firing trigger IDs
data
object
Event payload

Use cases

Zaraz is useful for:
  • Performance: Load third-party tools without blocking page rendering
  • Privacy: Manage user consent and data collection
  • Simplicity: Configure tools without editing code
  • Control: Enable/disable tools from the dashboard
  • Debugging: Test tools in staging before publishing

Build docs developers (and LLMs) love