Client-Side Storage
This page covers what the Dreamdata script stores in your visitors' browsers, how long it stays there, and the options you can set to store less.
What the script stores
Cookies hold IDs only: the anonymous ID, and the user ID and group ID once
you pass them. They are first-party cookies set on your top-level domain, so
they are shared across your subdomains. They are set with SameSite=Lax and
Secure, and expire after 1 year. The expiry renews each time the visitor
returns.
Local storage holds the same IDs, plus:
dd_user_traits: the traits the visitor has been identified with, such asemail.dd_group_properties: the properties of the visitor's company.
Local storage has no expiry. Entries stay until the visitor clears their site
data or your site calls reset().
If an event cannot be sent, for example because the visitor goes offline, the
script keeps it in local storage under a persisted-queue:v1: key and sends it
on the next page load. An unsent identify event includes its traits.
See Cookies for the full list of names.
When an email is stored
dd_user_traits contains an email address in these cases:
- Your site calls
identify()with anemailtrait. - Form tracking is enabled and a visitor submits a tracked form that has an email field.
- A visitor opens a link with a
dd_trait_emailparameter. See Using URL Query Parameters.
New traits are merged into the stored ones, so the entry keeps every trait the visitor has been identified with until it is cleared.
Clear stored data on logout
Call reset() when a user logs out:
dreamdata.reset();
This removes the stored user ID, anonymous ID and group ID, and empties the
stored traits and group properties. The dd_user_traits and
dd_group_properties entries remain in local storage with an empty value. A new
anonymous ID is created with the next event.
Set storage options
Storage options go in the second argument of the load call.
Website script. The script you copy from Dreamdata Platform contains a line like this:
dreamdata.load("<YOUR_WRITE_KEY>", { formTracking: { html: true } });
Add the storage options to that object. Keep the options that are already there.
Single-Page App SDK. Pass the options as the second argument:
export const dreamdata = AnalyticsBrowser.load(
{ writeKey: "<YOUR_WRITE_KEY>" },
{
user: { localStorageFallbackDisabled: true },
group: { localStorageFallbackDisabled: true },
},
);
Keep traits out of local storage
Set localStorageFallbackDisabled on both user and group:
dreamdata.load("<YOUR_WRITE_KEY>", {
// ...the options already in your script
user: { localStorageFallbackDisabled: true },
group: { localStorageFallbackDisabled: true },
});
The script then stops writing traits, group properties and IDs to local storage. IDs stay in cookies, so a returning visitor is still recognized. Traits and group properties are kept in memory for the current page only.
storage: { stores: ["cookie", "memory"] } has the same effect for both user
and group in one option.
What changes:
- An
identify()call no longer includes traits from the visitor's earlier page loads, only those passed on the current page. - Form tracking cannot re-identify a returning visitor from an email stored on an earlier visit.
- Intent sources look up the visitor's company again on each page load.
Entries already written for returning visitors stay in local storage. The script
no longer reads or clears them, including on reset(). To remove them, run this
on your site, for example when a user logs out:
localStorage.removeItem("dd_user_traits");
localStorage.removeItem("dd_group_properties");
Store nothing in the browser
Set disableClientPersistence to keep IDs, traits and unsent events in memory
instead of cookies and local storage:
dreamdata.load("<YOUR_WRITE_KEY>", {
// ...the options already in your script
disableClientPersistence: true,
});
Every page load then starts as a new anonymous visitor, so visits are only joined up when the visitor is identified on that page. If you need tracking without cookies, use Cookieless Account Analytics instead.