Skip to content
Start here

Get Zaraz configuration

client.Zaraz.Config.Get(ctx, query) (*Configuration, error)
GET/zones/{zone_id}/settings/zaraz/config

Gets latest Zaraz configuration for a zone. It can be preview or published configuration, whichever was the last updated. Secret variables values will not be included.

Security
API Token

The preferred authorization scheme for interacting with the Cloudflare API. Create a token.

Example:Authorization: Bearer Sn3lZJTBX6kkg7OdcBUAxOO963GEIyGQqnFTOFYY
API Email + API Key

The previous authorization scheme for interacting with the Cloudflare API, used in conjunction with a Global API key.

Example:X-Auth-Email: user@example.com

The previous authorization scheme for interacting with the Cloudflare API. When possible, use API tokens instead of Global API keys.

Example:X-Auth-Key: 144c9defac04969c7bfad8efaa8ea194
Accepted Permissions (at least one required)
Zaraz EditZaraz ReadZaraz Admin
ParametersExpand Collapse
query ConfigGetParams
ZoneID param.Field[string]

Identifier.

maxLength32
ReturnsExpand Collapse
type Configuration struct{…}

Zaraz configuration.

DataLayer bool

Data layer compatibility mode enabled.

DebugKey string

The key for Zaraz debug mode.

Settings ConfigurationSettings

General Zaraz settings.

AutoInjectScript bool

Automatic injection of Zaraz scripts enabled.

ContextEnricher ConfigurationSettingsContextEnricheroptional

Details of the worker that receives and edits Zaraz Context object.

EscapedWorkerName string
WorkerTag string
CookieDomain stringoptional

The domain Zaraz will use for writing and reading its cookies.

Ecommerce booloptional

Ecommerce API enabled.

EventsAPIPath stringoptional

Custom endpoint for server-side track events.

HideExternalReferer booloptional

Hiding external referrer URL enabled.

HideIPAddress booloptional

Trimming IP address enabled.

HideQueryParams booloptional

Removing URL query params enabled.

HideUserAgent booloptional

Removing sensitive data from User Agent string enabled.

InitPath stringoptional

Custom endpoint for Zaraz init script.

InjectIframes booloptional

Injection of Zaraz scripts into iframes enabled.

McRootPath stringoptional

Custom path for Managed Components server functionalities.

ScriptPath stringoptional

Custom endpoint for Zaraz main script.

TrackPath stringoptional

Custom endpoint for Zaraz tracking requests.

Tools map[string, ConfigurationTool]

Tools set up under Zaraz configuration, where key is the alpha-numeric tool ID and value is the tool configuration object.

One of the following:
type ConfigurationToolsZarazManagedComponent struct{…}
BlockingTriggers []string

List of blocking trigger IDs.

Component string

Tool's internal name.

DefaultFields map[string, ConfigurationToolsZarazManagedComponentDefaultFieldsUnion]

Default fields for tool's actions.

One of the following:
UnionString
UnionBool
Enabled bool

Whether tool is enabled.

Name string

Tool's name defined by the user.

Permissions []string

List of permissions granted to the component.

Settings map[string, ConfigurationToolsZarazManagedComponentSettingsUnion]

Tool's settings.

One of the following:
UnionString
UnionBool
Type ConfigurationToolsZarazManagedComponentType
Actions map[string, NeoEvent]optional

Actions configured on a tool. Either this or neoEvents field is required.

ActionType string

Tool event type.

BlockingTriggers []string

List of blocking triggers IDs.

Data unknown

Event payload.

FiringTriggers []string

List of firing triggers IDs.

DefaultPurpose stringoptional

Default consent purpose ID.

NeoEvents []NeoEventoptional

DEPRECATED - List of actions configured on a tool. Either this or actions field is required. If both are present, actions field will take precedence.

ActionType string

Tool event type.

BlockingTriggers []string

List of blocking triggers IDs.

Data unknown

Event payload.

FiringTriggers []string

List of firing triggers IDs.

VendorName stringoptional

Vendor name for TCF compliant consent modal, required for Custom Managed Components and Custom HTML tool with a defaultPurpose assigned.

VendorPolicyURL stringoptional

Vendor's Privacy Policy URL for TCF compliant consent modal, required for Custom Managed Components and Custom HTML tool with a defaultPurpose assigned.

type ConfigurationToolsWorker struct{…}
BlockingTriggers []string

List of blocking trigger IDs.

Component string

Tool's internal name.

DefaultFields map[string, ConfigurationToolsWorkerDefaultFieldsUnion]

Default fields for tool's actions.

One of the following:
UnionString
UnionBool
Enabled bool

Whether tool is enabled.

Name string

Tool's name defined by the user.

Permissions []string

List of permissions granted to the component.

Settings map[string, ConfigurationToolsWorkerSettingsUnion]

Tool's settings.

One of the following:
UnionString
UnionBool
Type ConfigurationToolsWorkerType
Worker ConfigurationToolsWorkerWorker

Cloudflare worker that acts as a managed component.

EscapedWorkerName string
WorkerTag string
Actions map[string, NeoEvent]optional

Actions configured on a tool. Either this or neoEvents field is required.

ActionType string

Tool event type.

BlockingTriggers []string

List of blocking triggers IDs.

Data unknown

Event payload.

FiringTriggers []string

List of firing triggers IDs.

DefaultPurpose stringoptional

Default consent purpose ID.

NeoEvents []NeoEventoptional

DEPRECATED - List of actions configured on a tool. Either this or actions field is required. If both are present, actions field will take precedence.

ActionType string

Tool event type.

BlockingTriggers []string

List of blocking triggers IDs.

Data unknown

Event payload.

FiringTriggers []string

List of firing triggers IDs.

VendorName stringoptional

Vendor name for TCF compliant consent modal, required for Custom Managed Components and Custom HTML tool with a defaultPurpose assigned.

VendorPolicyURL stringoptional

Vendor's Privacy Policy URL for TCF compliant consent modal, required for Custom Managed Components and Custom HTML tool with a defaultPurpose assigned.

Triggers map[string, ConfigurationTrigger]

Triggers set up under Zaraz configuration, where key is the trigger alpha-numeric ID and value is the trigger configuration.

ExcludeRules []ConfigurationTriggersExcludeRule

Rules defining when the trigger is not fired.

One of the following:
type ConfigurationTriggersExcludeRulesZarazLoadRule struct{…}
ID string
Match string
Op ConfigurationTriggersExcludeRulesZarazLoadRuleOp
One of the following:
const ConfigurationTriggersExcludeRulesZarazLoadRuleOpContains ConfigurationTriggersExcludeRulesZarazLoadRuleOp = "CONTAINS"
const ConfigurationTriggersExcludeRulesZarazLoadRuleOpEquals ConfigurationTriggersExcludeRulesZarazLoadRuleOp = "EQUALS"
const ConfigurationTriggersExcludeRulesZarazLoadRuleOpStartsWith ConfigurationTriggersExcludeRulesZarazLoadRuleOp = "STARTS_WITH"
const ConfigurationTriggersExcludeRulesZarazLoadRuleOpEndsWith ConfigurationTriggersExcludeRulesZarazLoadRuleOp = "ENDS_WITH"
const ConfigurationTriggersExcludeRulesZarazLoadRuleOpMatchRegex ConfigurationTriggersExcludeRulesZarazLoadRuleOp = "MATCH_REGEX"
const ConfigurationTriggersExcludeRulesZarazLoadRuleOpNotMatchRegex ConfigurationTriggersExcludeRulesZarazLoadRuleOp = "NOT_MATCH_REGEX"
const ConfigurationTriggersExcludeRulesZarazLoadRuleOpGreaterThan ConfigurationTriggersExcludeRulesZarazLoadRuleOp = "GREATER_THAN"
const ConfigurationTriggersExcludeRulesZarazLoadRuleOpGreaterThanOrEqual ConfigurationTriggersExcludeRulesZarazLoadRuleOp = "GREATER_THAN_OR_EQUAL"
const ConfigurationTriggersExcludeRulesZarazLoadRuleOpLessThan ConfigurationTriggersExcludeRulesZarazLoadRuleOp = "LESS_THAN"
const ConfigurationTriggersExcludeRulesZarazLoadRuleOpLessThanOrEqual ConfigurationTriggersExcludeRulesZarazLoadRuleOp = "LESS_THAN_OR_EQUAL"
Value string
type ConfigurationTriggersExcludeRulesZarazClickListenerRule struct{…}
ID string
Action ConfigurationTriggersExcludeRulesZarazClickListenerRuleAction
Settings ConfigurationTriggersExcludeRulesZarazClickListenerRuleSettings
Selector string
Type ConfigurationTriggersExcludeRulesZarazClickListenerRuleSettingsType
One of the following:
const ConfigurationTriggersExcludeRulesZarazClickListenerRuleSettingsTypeXpath ConfigurationTriggersExcludeRulesZarazClickListenerRuleSettingsType = "xpath"
const ConfigurationTriggersExcludeRulesZarazClickListenerRuleSettingsTypeCSS ConfigurationTriggersExcludeRulesZarazClickListenerRuleSettingsType = "css"
WaitForTags int64
minimum0
type ConfigurationTriggersExcludeRulesZarazTimerRule struct{…}
ID string
Action ConfigurationTriggersExcludeRulesZarazTimerRuleAction
Settings ConfigurationTriggersExcludeRulesZarazTimerRuleSettings
Interval int64
minimum50
Limit int64
minimum0
type ConfigurationTriggersExcludeRulesZarazFormSubmissionRule struct{…}
ID string
Action ConfigurationTriggersExcludeRulesZarazFormSubmissionRuleAction
Settings ConfigurationTriggersExcludeRulesZarazFormSubmissionRuleSettings
Selector string
Validate bool
type ConfigurationTriggersExcludeRulesZarazVariableMatchRule struct{…}
ID string
Action ConfigurationTriggersExcludeRulesZarazVariableMatchRuleAction
Settings ConfigurationTriggersExcludeRulesZarazVariableMatchRuleSettings
Match string
Variable string
type ConfigurationTriggersExcludeRulesZarazScrollDepthRule struct{…}
ID string
Action ConfigurationTriggersExcludeRulesZarazScrollDepthRuleAction
Settings ConfigurationTriggersExcludeRulesZarazScrollDepthRuleSettings
Positions string
type ConfigurationTriggersExcludeRulesZarazElementVisibilityRule struct{…}
ID string
Action ConfigurationTriggersExcludeRulesZarazElementVisibilityRuleAction
Settings ConfigurationTriggersExcludeRulesZarazElementVisibilityRuleSettings
Selector string
LoadRules []ConfigurationTriggersLoadRule

Rules defining when the trigger is fired.

One of the following:
type ConfigurationTriggersLoadRulesZarazLoadRule struct{…}
ID string
Match string
Op ConfigurationTriggersLoadRulesZarazLoadRuleOp
One of the following:
const ConfigurationTriggersLoadRulesZarazLoadRuleOpContains ConfigurationTriggersLoadRulesZarazLoadRuleOp = "CONTAINS"
const ConfigurationTriggersLoadRulesZarazLoadRuleOpEquals ConfigurationTriggersLoadRulesZarazLoadRuleOp = "EQUALS"
const ConfigurationTriggersLoadRulesZarazLoadRuleOpStartsWith ConfigurationTriggersLoadRulesZarazLoadRuleOp = "STARTS_WITH"
const ConfigurationTriggersLoadRulesZarazLoadRuleOpEndsWith ConfigurationTriggersLoadRulesZarazLoadRuleOp = "ENDS_WITH"
const ConfigurationTriggersLoadRulesZarazLoadRuleOpMatchRegex ConfigurationTriggersLoadRulesZarazLoadRuleOp = "MATCH_REGEX"
const ConfigurationTriggersLoadRulesZarazLoadRuleOpNotMatchRegex ConfigurationTriggersLoadRulesZarazLoadRuleOp = "NOT_MATCH_REGEX"
const ConfigurationTriggersLoadRulesZarazLoadRuleOpGreaterThan ConfigurationTriggersLoadRulesZarazLoadRuleOp = "GREATER_THAN"
const ConfigurationTriggersLoadRulesZarazLoadRuleOpGreaterThanOrEqual ConfigurationTriggersLoadRulesZarazLoadRuleOp = "GREATER_THAN_OR_EQUAL"
const ConfigurationTriggersLoadRulesZarazLoadRuleOpLessThan ConfigurationTriggersLoadRulesZarazLoadRuleOp = "LESS_THAN"
const ConfigurationTriggersLoadRulesZarazLoadRuleOpLessThanOrEqual ConfigurationTriggersLoadRulesZarazLoadRuleOp = "LESS_THAN_OR_EQUAL"
Value string
type ConfigurationTriggersLoadRulesZarazClickListenerRule struct{…}
ID string
Action ConfigurationTriggersLoadRulesZarazClickListenerRuleAction
Settings ConfigurationTriggersLoadRulesZarazClickListenerRuleSettings
Selector string
Type ConfigurationTriggersLoadRulesZarazClickListenerRuleSettingsType
One of the following:
const ConfigurationTriggersLoadRulesZarazClickListenerRuleSettingsTypeXpath ConfigurationTriggersLoadRulesZarazClickListenerRuleSettingsType = "xpath"
const ConfigurationTriggersLoadRulesZarazClickListenerRuleSettingsTypeCSS ConfigurationTriggersLoadRulesZarazClickListenerRuleSettingsType = "css"
WaitForTags int64
minimum0
type ConfigurationTriggersLoadRulesZarazTimerRule struct{…}
ID string
Action ConfigurationTriggersLoadRulesZarazTimerRuleAction
Settings ConfigurationTriggersLoadRulesZarazTimerRuleSettings
Interval int64
minimum50
Limit int64
minimum0
type ConfigurationTriggersLoadRulesZarazFormSubmissionRule struct{…}
ID string
Action ConfigurationTriggersLoadRulesZarazFormSubmissionRuleAction
Settings ConfigurationTriggersLoadRulesZarazFormSubmissionRuleSettings
Selector string
Validate bool
type ConfigurationTriggersLoadRulesZarazVariableMatchRule struct{…}
ID string
Action ConfigurationTriggersLoadRulesZarazVariableMatchRuleAction
Settings ConfigurationTriggersLoadRulesZarazVariableMatchRuleSettings
Match string
Variable string
type ConfigurationTriggersLoadRulesZarazScrollDepthRule struct{…}
ID string
Action ConfigurationTriggersLoadRulesZarazScrollDepthRuleAction
Settings ConfigurationTriggersLoadRulesZarazScrollDepthRuleSettings
Positions string
type ConfigurationTriggersLoadRulesZarazElementVisibilityRule struct{…}
ID string
Action ConfigurationTriggersLoadRulesZarazElementVisibilityRuleAction
Settings ConfigurationTriggersLoadRulesZarazElementVisibilityRuleSettings
Selector string
Name string

Trigger name.

Description stringoptional

Trigger description.

System ConfigurationTriggersSystemoptional
Variables map[string, ConfigurationVariable]

Variables set up under Zaraz configuration, where key is the variable alpha-numeric ID and value is the variable configuration. Values of variables of type secret are not included.

One of the following:
type ConfigurationVariablesZarazStringVariable struct{…}
Name string
Type ConfigurationVariablesZarazStringVariableType
Value string
type ConfigurationVariablesZarazSecretVariable struct{…}
Name string
Type ConfigurationVariablesZarazSecretVariableType
Value string
type ConfigurationVariablesZarazWorkerVariable struct{…}
Name string
Type ConfigurationVariablesZarazWorkerVariableType
Value ConfigurationVariablesZarazWorkerVariableValue
EscapedWorkerName string
WorkerTag string
ZarazVersion int64

Zaraz internal version of the config.

Analytics ConfigurationAnalyticsoptional

Cloudflare Monitoring settings.

DefaultPurpose stringoptional

Consent purpose assigned to Monitoring.

Enabled booloptional

Whether Advanced Monitoring reports are enabled.

SessionExpTime int64optional

Session expiration time (seconds).

maximum86400
minimum60
HistoryChange booloptional

Single Page Application support enabled.

Get Zaraz configuration

package main

import (
  "context"
  "fmt"

  "github.com/cloudflare/cloudflare-go"
  "github.com/cloudflare/cloudflare-go/option"
  "github.com/cloudflare/cloudflare-go/zaraz"
)

func main() {
  client := cloudflare.NewClient(
    option.WithAPIToken("Sn3lZJTBX6kkg7OdcBUAxOO963GEIyGQqnFTOFYY"),
  )
  configuration, err := client.Zaraz.Config.Get(context.TODO(), zaraz.ConfigGetParams{
    ZoneID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"),
  })
  if err != nil {
    panic(err.Error())
  }
  fmt.Printf("%+v\n", configuration.DataLayer)
}
{
  "errors": [
    {
      "code": 1000,
      "message": "message",
      "documentation_url": "documentation_url",
      "source": {
        "pointer": "pointer"
      }
    }
  ],
  "messages": [
    {
      "code": 1000,
      "message": "message",
      "documentation_url": "documentation_url",
      "source": {
        "pointer": "pointer"
      }
    }
  ],
  "result": {
    "dataLayer": true,
    "debugKey": "debugKey",
    "settings": {
      "autoInjectScript": true,
      "contextEnricher": {
        "escapedWorkerName": "escapedWorkerName",
        "workerTag": "workerTag"
      },
      "cookieDomain": "cookieDomain",
      "ecommerce": true,
      "eventsApiPath": "eventsApiPath",
      "hideExternalReferer": true,
      "hideIPAddress": true,
      "hideQueryParams": true,
      "hideUserAgent": true,
      "initPath": "initPath",
      "injectIframes": true,
      "mcRootPath": "mcRootPath",
      "scriptPath": "scriptPath",
      "trackPath": "trackPath"
    },
    "tools": {
      "foo": {
        "blockingTriggers": [
          "string"
        ],
        "component": "component",
        "defaultFields": {
          "foo": "string"
        },
        "enabled": true,
        "name": "name",
        "permissions": [
          "string"
        ],
        "settings": {
          "foo": "string"
        },
        "type": "component",
        "actions": {
          "foo": {
            "actionType": "actionType",
            "blockingTriggers": [
              "string"
            ],
            "data": {},
            "firingTriggers": [
              "string"
            ]
          }
        },
        "defaultPurpose": "defaultPurpose",
        "neoEvents": [
          {
            "actionType": "actionType",
            "blockingTriggers": [
              "string"
            ],
            "data": {},
            "firingTriggers": [
              "string"
            ]
          }
        ],
        "vendorName": "vendorName",
        "vendorPolicyUrl": "vendorPolicyUrl"
      }
    },
    "triggers": {
      "foo": {
        "excludeRules": [
          {
            "id": "id",
            "match": "match",
            "op": "CONTAINS",
            "value": "value"
          }
        ],
        "loadRules": [
          {
            "id": "id",
            "match": "match",
            "op": "CONTAINS",
            "value": "value"
          }
        ],
        "name": "name",
        "description": "description",
        "system": "pageload"
      }
    },
    "variables": {
      "foo": {
        "name": "name",
        "type": "string",
        "value": "value"
      }
    },
    "zarazVersion": 0,
    "analytics": {
      "defaultPurpose": "defaultPurpose",
      "enabled": true,
      "sessionExpTime": 60
    },
    "consent": {
      "enabled": true,
      "buttonTextTranslations": {
        "accept_all": {
          "foo": "string"
        },
        "confirm_my_choices": {
          "foo": "string"
        },
        "reject_all": {
          "foo": "string"
        }
      },
      "companyEmail": "companyEmail",
      "companyName": "companyName",
      "companyStreetAddress": "companyStreetAddress",
      "consentModalIntroHTML": "consentModalIntroHTML",
      "consentModalIntroHTMLWithTranslations": {
        "foo": "string"
      },
      "cookieName": "cookieName",
      "customCSS": "customCSS",
      "customIntroDisclaimerDismissed": true,
      "defaultLanguage": "defaultLanguage",
      "hideModal": true,
      "purposes": {
        "foo": {
          "description": "description",
          "name": "name"
        }
      },
      "purposesWithTranslations": {
        "foo": {
          "description": {
            "foo": "string"
          },
          "name": {
            "foo": "string"
          },
          "order": 0
        }
      },
      "tcfCompliant": true
    },
    "historyChange": true
  },
  "success": true
}
Returns Examples
{
  "errors": [
    {
      "code": 1000,
      "message": "message",
      "documentation_url": "documentation_url",
      "source": {
        "pointer": "pointer"
      }
    }
  ],
  "messages": [
    {
      "code": 1000,
      "message": "message",
      "documentation_url": "documentation_url",
      "source": {
        "pointer": "pointer"
      }
    }
  ],
  "result": {
    "dataLayer": true,
    "debugKey": "debugKey",
    "settings": {
      "autoInjectScript": true,
      "contextEnricher": {
        "escapedWorkerName": "escapedWorkerName",
        "workerTag": "workerTag"
      },
      "cookieDomain": "cookieDomain",
      "ecommerce": true,
      "eventsApiPath": "eventsApiPath",
      "hideExternalReferer": true,
      "hideIPAddress": true,
      "hideQueryParams": true,
      "hideUserAgent": true,
      "initPath": "initPath",
      "injectIframes": true,
      "mcRootPath": "mcRootPath",
      "scriptPath": "scriptPath",
      "trackPath": "trackPath"
    },
    "tools": {
      "foo": {
        "blockingTriggers": [
          "string"
        ],
        "component": "component",
        "defaultFields": {
          "foo": "string"
        },
        "enabled": true,
        "name": "name",
        "permissions": [
          "string"
        ],
        "settings": {
          "foo": "string"
        },
        "type": "component",
        "actions": {
          "foo": {
            "actionType": "actionType",
            "blockingTriggers": [
              "string"
            ],
            "data": {},
            "firingTriggers": [
              "string"
            ]
          }
        },
        "defaultPurpose": "defaultPurpose",
        "neoEvents": [
          {
            "actionType": "actionType",
            "blockingTriggers": [
              "string"
            ],
            "data": {},
            "firingTriggers": [
              "string"
            ]
          }
        ],
        "vendorName": "vendorName",
        "vendorPolicyUrl": "vendorPolicyUrl"
      }
    },
    "triggers": {
      "foo": {
        "excludeRules": [
          {
            "id": "id",
            "match": "match",
            "op": "CONTAINS",
            "value": "value"
          }
        ],
        "loadRules": [
          {
            "id": "id",
            "match": "match",
            "op": "CONTAINS",
            "value": "value"
          }
        ],
        "name": "name",
        "description": "description",
        "system": "pageload"
      }
    },
    "variables": {
      "foo": {
        "name": "name",
        "type": "string",
        "value": "value"
      }
    },
    "zarazVersion": 0,
    "analytics": {
      "defaultPurpose": "defaultPurpose",
      "enabled": true,
      "sessionExpTime": 60
    },
    "consent": {
      "enabled": true,
      "buttonTextTranslations": {
        "accept_all": {
          "foo": "string"
        },
        "confirm_my_choices": {
          "foo": "string"
        },
        "reject_all": {
          "foo": "string"
        }
      },
      "companyEmail": "companyEmail",
      "companyName": "companyName",
      "companyStreetAddress": "companyStreetAddress",
      "consentModalIntroHTML": "consentModalIntroHTML",
      "consentModalIntroHTMLWithTranslations": {
        "foo": "string"
      },
      "cookieName": "cookieName",
      "customCSS": "customCSS",
      "customIntroDisclaimerDismissed": true,
      "defaultLanguage": "defaultLanguage",
      "hideModal": true,
      "purposes": {
        "foo": {
          "description": "description",
          "name": "name"
        }
      },
      "purposesWithTranslations": {
        "foo": {
          "description": {
            "foo": "string"
          },
          "name": {
            "foo": "string"
          },
          "order": 0
        }
      },
      "tcfCompliant": true
    },
    "historyChange": true
  },
  "success": true
}