Local Storage and Cookies for Data Capture


The Sitecore CDP uses the Boxever library script to capture data about guests' behavior that can be used in tracking, decision-making, and analytics while ensuring that General Data Protection Regulation (GDPR) is maintained.


Data capturing in Sitecore CDP is facilitated through a combination of cookies and local storage. Both methods store the same types of information and have the same Time to Live (TTL) setting, by default.


A cookie is a small file that an organization places on a user’s device (such as a PC, tablet, or mobile phone) to perform identity and data capturing. It is the duty of an organization to maintain General Data Protection Regulation compliance.


The Boxever library script places the following cookies on the website visitor's device:


bid_{clientKey} - This cookie persists in the browser ID between sessions. It generates a Universally Unique Identifier (UUID) that is unique per browser and remains identical until the cookie expires or is deleted after that a new UUID is generated. Sitecore CDP data capture cookies expire after two years of inactivity.


bx_bucket_number - This cookie is used only if the organization has enabled at least one Web Experiment on the website. This cookie allocates the Guest to a specific variant when using audience allocation. It performs allocation for each Web Experiment that is live on your site during the particular session. This session cookie is only stored for the duration of the session.


boxever_test - This cookie checks that other cookies are working as expected and then it is immediately removed from the visitor's device.


There is an option to only use cookies and not local storage but it is not recommended by Sitecore because the cookie Time to Live (TTL) is determined by the browser that the guest is using, therefore making data capture and persistence difficult.


From Boxever library script version 1.4.2+ you can set the cookie_expiry_in_days property that enables you to change the cookie and local storage expiry from the default value of two years.


From Boxever library script version 1.4.3+ you can set the cookies_only property to true to use only cookies and disable the local storage.


From Boxever library script version 1.4.6+ you can set the property itp_cross_domain which will automatically apply the cross-domain setting with respect to Intelligent Tracking Prevention (ITP) browsers.


<script type="text/javascript">
  var _boxeverq = _boxeverq || [];

  // Define the Boxever settings 
  var _boxever_settings = {
    client_key: '{{client Key}}', // Replace with your Client Key
    target: '{{API Target Endpoint}}', // Replace with your API Target Endpoint specific to your Data Center Region
    cookie_domain: '{{cookie Domain}}', // Replace with top level cookie domain of the website
    javascriptLibraryVersion: '{{JavaScript Library Version}}', // Replace with latest Boxever JavaScript Library Version"
    pointOfSale: '{{Points Of Sale}}', // Replace with Point of Sale configured in System Settings"
    web_flow_target: '{{Web Flow Target}}', // Replace with path of Amazon CloudFront CDN for Sitecore Personalize"
    web_flow_config: { async: false, defer: false }, // Customize the async and defer Script loading attributes
    itp_cross_domain: true
  };
  (function() {
    var s = document.createElement('script'); s.type = 'text/javascript'; s.async = true;  
    s.src = 'https://d1mj578wat5n4o.cloudfront.net/boxever-{{JavaScript Library Version}}.min.js';
    var x = document.getElementsByTagName('script')[0]; x.parentNode.insertBefore(s, x);
  })();
</script>


References


Using Local Storage and Cookies for data capture - https://doc.sitecore.com/cdp/en/developers/sitecore-customer-data-platform--data-model-2-1/using-local-storage-and-cookies-for-data-capture.html


Boxever JavaScript Library Release - https://doc.sitecore.com/cdp/en/developers/sitecore-customer-data-platform--data-model-2-1/boxever-javascript-library-release-notes.html



That's all for Today,

Happy Coding

Chirag Goel

I am a developer, likes to work on different future technologies.

Post a Comment (0)
Previous Post Next Post