The JavaScript SDK stores persistent user data in the cookies by default. If the cookies are not supported, the SDK uses local storage instead.
By default, the SDK stores all the cookies in the top-level domain. It helps you to identify the users visiting websites hosted under a particular sub-domain. For example, if you include the JavaScript SDK in both admin.samplewebsite.com
and app.samplewebsite.com
, the SDK will store the cookie in samplewebsite.com
. However, you can specify the cookie storage location by using the setCookieDomain
parameter in the load
API options as shown:
rudderanalytics.load(WRITE_KEY, DATA_PLANE_URL, { setCookieDomain: "samplewebsite.com",});
WRITE_KEY
and DATA_PLANE_URL
in the above snippet with the actual values.Cookies
The following table lists the cookies used by the JavaScript SDK to store persistent user data:
Name | Description | Example | Clearing mechanism using the SDK |
---|---|---|---|
rl_user_id | Stores the user ID set via the identify API. All the subsequent event payloads will contain this data unless cleared from the storage. | 4578 , USER_001 | rudderanalytics.reset() |
rl_trait | Stores the user traits object set via the identify API. All the subsequent event payloads will contain this data unless cleared from the storage. | { | rudderanalytics.reset() |
rl_anonymous_id | Stores the anonymous ID. By default, it would be the auto-generated unique ID by SDK for each visitor unless overridden via setAnonymousId API. All the subsequent event payloads will contain this data unless cleared from the storage. | 5bfe258f-bd2f-49cf-bddd-8b844f74ab4b , customAnonId | rudderanalytics.reset(true) |
rl_group_id | Stores the user group ID set via the group API. All the subsequent group event payloads will contain this data unless cleared from the storage. | GRP_3 , 98 | rudderanalytics.reset() |
rl_group_trait | Stores the user group traits object set via the group API. All the subsequent group event payloads will contain this data unless cleared from the storage. | { | rudderanalytics.reset() |
rl_page_init_referrer | Stores the initial referrer of the page when a user visits a site for the first time. All the subsequent event payloads will contain this data. | https://www.google.com/ | Cannot be cleared using SDK. |
rl_page_init_referring_domain | Stores the initial referring domain of the page when a user visits a site for the first time. All the subsequent event payloads will contain this data. | google.com | Cannot be cleared using SDK. |
test_rudder_cookie | Checks whether the cookie storage of a browser is accessible or not. Once checked, the SDK removes the cookie immediately. | test_rudder_cookie:true | Cleared automatically. |
rl_
and the values are prefixed with RudderEncrypt:
. For example, rl_user_id —> RudderEncrypt:U2FsdGVkX1+UKmiooYoGmKdNws7sgmWgGfHe
.Local storage
The JavaScript SDK uses local storage to keep track of the events sent to the RudderStack backend, as listed in the below table:
Name | Description | Example |
---|---|---|
ack | Timer for other browser tabs to claim control of the retry queue. | 1639734070124 |
reclaimStart and reclaimEnd | Determines if a tab takes over the queue from another tab. | 2dc2aee6-2836-4273-be69-79c90c04ddec |
inProgress | Keeps track of the events in progress. | { |
queue | Keeps track of the events that are in queue to be processed. | [ |
rudder.<uuid>.
The uuid
here is in the standard UUID v4 format. For example,rudder.2dc2aee6-2836-4273-be69-79c90c04ddec.reclaimEnd
.Contact us
For more information on the topics covered on this page, email us or start a conversation in our Slack community.