Cookies and Storage

This article describes the different cookies used by the Braze Web SDK.

Before reading on, please note that the Braze Web SDK will not store any data in the browser (cookies or otherwise) until your website initializes the SDK.

Additionally, these values are subject to change and should not be accessed directly through your integration. Instead, please see our Javascript documentation for our public API interfaces.

Cookies

This section provides information on how cookies in the Braze Web SDK can be set and managed. The Braze Web SDK is built to provide you with maximum flexibility, legal compliance, and messaging relevance.

When Braze creates cookies, they are stored with a 1 year expiration that automatically renews on new sessions.

Disabling Cookies

To disable all cookies, use the noCookies option when initializing the Web SDK. Disabling cookies will prevent you from associating anonymous users who navigate across sub-domains, and will result in a new user on each subdomain.

1
2
3
4
5
import braze from "@braze/web-sdk";
braze.initialize("API-KEY", {
    baseUrl: "BASE-URL",
    noCookies: true
});

To stop Braze tracking in general, or to clear all stored browser data, please see the stopWebTracking and wipeData SDK methods, respectively. These two methods can be useful should a user revoke consent or you wish to stop all Braze functionality after the SDK has already been initialized.

List of Cookies

Cookie Description
ab.storage.userId.[your-api-key] Used to determine whether the currently-logged-in user has changed, and to associate events with the current user.
ab.storage.sessionId.[your-api-key] Out-of-the-box randomly generated string used to determine whether the user is starting a new or existing session, in order to sync messages and calculate session analytics.
ab.storage.deviceId.[your-api-key] Out-of-the-box randomly generated string used to identify anonymous users, and to differentiate users’ devices and enables device-based messaging.
ab.optOut Used to store a user’s opt-out preference
ab._gd Temporarily created (and then deleted) to determine the root-level cookie domain which allows the SDK to work properly across sub-domains.

Device Properties

By default, Braze will collect the following device-level properties to allow device, language, and timezone based message personalization:

  • BROWSER
  • BROWSER_VERSION
  • LANGUAGE
  • OS
  • RESOLUTION
  • TIME_ZONE
  • USER_AGENT

You can disable or specify the properties you wish to collect by setting the devicePropertyAllowlist initialization option to a list of DeviceProperties. Note that without some properties, not all features will function properly. For instance, without the time zone, local timezone delivery will not function.

1
2
3
4
5
import braze from "@braze/web-sdk";
braze.initialize("API-KEY", {
    baseUrl: "BASE-URL",
    devicePropertyAllowlist: [ braze.DeviceProperties.LANGUAGE ] // list of `DeviceProperties` you want to collect
});
WAS THIS PAGE HELPFUL?
New Stuff!