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",
});
Replace 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:

NameDescriptionExampleClearing mechanism using the SDK
rl_user_idStores the user ID set via the identify API. All the subsequent event payloads will contain this data unless cleared from the storage.4578, USER_001rudderanalytics.reset()
rl_traitStores the user traits object set via the identify API. All the subsequent event payloads will contain this data unless cleared from the storage.
{
email: "alex@example.com",
accountType: "pro",
country: "US",
someObj: {
key1: val1,
key2: val2,
}
}
rudderanalytics.reset()
rl_anonymous_idStores 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, customAnonIdrudderanalytics.reset(true)
rl_group_idStores 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, 98rudderanalytics.reset()
rl_group_traitStores 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.
{
location: "New Orleans",
nationality: "US",
someObj: {
key1: val1,
key2: val2,
}
}
rudderanalytics.reset()
rl_page_init_referrerStores 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_domainStores 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.comCannot be cleared using SDK.
test_rudder_cookieChecks whether the cookie storage of a browser is accessible or not. Once checked, the SDK removes the cookie immediately.test_rudder_cookie:trueCleared automatically.
The cookie values are encrypted and their length is directly proportional to the values provided to the SDK. Also, all the cookie names are prefixed with 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:

NameDescriptionExample
ackTimer for other browser tabs to claim control of the retry queue.1639734070124
reclaimStart and reclaimEndDetermines if a tab takes over the queue from another tab.2dc2aee6-2836-4273-be69-79c90c04ddec
inProgressKeeps track of the events in progress.
{
"d89d7fb5-945e-4378-bda5-492e4b596fb4": {
"item": {
"url": "https://rudderstack-dataplane.rudderstack.com/v1/track",
"headers": {
"Content-Type": "application/json",
...
},
"message": {
...
}
"attemptNumber": 1,
"time": 1639734792773,
"id": "a4d89d7f-b594-4eb3-b8bd-a5492e4b596f"
}
}
}
queueKeeps track of the events that are in queue to be processed.
[
{
"item": {
"url": "https://rudderstack-dataplane.rudderstack.com/v1/track",
"headers": {
"Content-Type": "application/json",
...
},
"message": {
...
}
"attemptNumber": 0,
"time": 1639734792773,
"id": "a4d89d7f-b594-4eb3-b8bd-a5492e4b596f"
}
}
]
All the local storage cookie names are prefixed with 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.

On this page