persistenceInCookieStorage
Type: Boolean
Default: false
Description:
This configuration option determines the browser storage mechanism used by the Zeotap SDK to persist user identities and consent information between page loads and sessions.
false(Default): The SDK utilizessessionStorage. This is generally suitable for most cases, offering potentially larger storage capacity and not being automatically sent with network requests.true: The SDK utilizescookieStorage.
Why Use cookieStorage (true)?
The primary reason to set persistenceInCookieStorage: true is for cross-subdomain persistence.
- If your website operates across multiple subdomains (e.g.,
www.example.com,shop.example.com,app.example.com) and you need the user's identity or consent status set on one subdomain to be recognized on another, you must use cookie storage. sessionStorageis scoped strictly to the origin (protocol + hostname + port) and cannot be shared across subdomains this way.
Considerations:
- Storage Limits: Cookies generally have smaller storage limits per domain compared to
sessionStorage. - Network Overhead: Cookies are automatically included in the headers of every HTTP request sent to the domain they are set for. This can add minor overhead to network traffic.
sessionStoragedata is not sent automatically. - Session Persistence: In
sessionStoragedata is only persisted for the particular session.cookieStoragestores the data for subsequent sessions as well.
Example:
SDK Initialization for Cross-Subdomain Cookie Storage
window.zeotap.init("YOUR_WRITE_KEY", {
persistenceInCookieStorage: true, // Use cookie storage
});
ZI Stamping
ZI is always stamped in cookie storage irrespective of this option's value. In case, cookie storage is not available, then ZI is stamped in local storage.
Try out this example.