Skip to content

Zaraz Context

The Zaraz Context is a versatile object that provides a set of configurable properties for Zaraz, a web analytics tool for tracking user behavior on websites. These properties can be accessed and utilized across various components, including Worker Variables and JSONata expressions.

System properties, which are automatically collected by Zaraz, provide insights into the user’s environment and device, while Client properties, obtained through Zaraz Web API calls like zaraz.track(), offer additional information on user behavior and actions.

System properties

Page information

PropertyTypeDescription
system.page.queryObjectKey-Value object containing all query parameters in the current URL.
system.page.titleStringCurrent page title.
system.page.urlURLURL Object containing information about the current URL
system.page.referrerStringCurrent page referrer from document.referrer.
system.page.encodingStringCurrent page character encoding from document.characterSet.

Cookies

PropertyTypeDescription
system.cookiesObjectKey-Value object containing all present cookies.

The the keys inside the system.cookies are the cookies name. The property system.cookies.foo will return the value of the a cookie named foo.

Device information

PropertyTypeDescription
system.device.ipStringVisitor incoming IP address.
system.device.resolutionStringScreen resolution for device.
system.device.viewportStringVisible web page area in user’s device.
system.device.languageStringLanguage used in user’s device.
system.device.locationObjectAll location-related keys from IncomingRequestCfProperties
system.device.user-agent.uaStringBrowser user agent.
system.device.user-agent.browser.nameStringBrowser name.
system.device.user-agent.browser.versionStringBrowser version.
system.device.user-agent.engine.nameStringType of browser engine (for example, WebKit).
system.device.user-agent.engine.versionStringVersion of the browser engine.
system.device.user-agent.os.nameStringOperating system.
system.device.user-agent.os.versionStringVersion of the operating system.
system.device.user-agent.deviceStringType of device used (for example, iPhone).
system.device.user-agent.cpuStringDevice’s CPU.
PropertyTypeDescription
system.consentObjectKey-value object containing the current consent status from the Zaraz Consent Manager.

The keys inside the system.consent object are purpose IDs, and values are true for consent, false for lack of consent.

Managed Components

PropertyTypeDescription
system.clientKVObjectKey-value object containing all the KV data from your Managed Components.

The keys inside the system.clientKV object are formatted as Tool ID, underscore, Key name. Assuming you want to read the value of the ga4 key used by a tool with ID abcd, the path would be system.clientKV.abcd_ga4.

Miscellaneous

PropertyTypeDescription
system.misc.randomNumberRandom number unique to each request.
system.misc.timestampNumberUnix time in seconds.
system.misc.timestampMillisecondsNumberUnix time in milliseconds.

Event properties

PropertyTypeDescription
client.__zarazTrackStringReturns the name of the event sent using the Track method of the Web API. Refer to Zaraz Track for more information.
client.<KEY_NAME>StringReturns the value of a zaraz.track() eventProperties key. The key can either be directly used in zaraz.track() or set using zaraz.set(). Replace <KEY_NAME> with the name of your key. Refer to Zaraz Track for more information.