Search code examples
cookiesspartacus-storefront

Spartacus integration with CDS, profile.consent.given cookie not being set after clearing site data


We're integrating SAP Commerce 2005 and Spartacus 2.0.3 with CDS (Context-Driven Services). We followed the instructions from https://sap.github.io/spartacus-docs/cds-integration/ and we got it work right.

Nevertheless, we've noticed one issue.

When we clear the site data (either from Chrome DevTool or via browser Settings), the cookie named profile.consent.given is not being set anew while refreshing the page - even though the PROFILE consent has consentState "GIVEN" in local storage in spartacus-local-data > anonymous-consents > consents.

Initially I thought that it's just not visible in DevTools, but when I've added the url parameter ?profileTagDebug=true, in the console there is a log saying:

"[Profile Tag] No cookie found with name profile.consent.given".

When I set this cookie manually with value true, everything starts to work just fine, all other needed cookies and local storage data responsible for tracking users behavior is being set properly.

Do you see any place where we could have done something wrong, which may have caused this cookie to work improperly? Which module or component of Spartacus library would be of any clue in resolving this issue?


Edit: the reason of this strange behavior was in profile tag created by our team in CDS. It contained:

"consentListener": "type":"cookie","cookieName":"profile.consent.given","cookieValue":"true"},

which made the cookie profile.consent.given necessary while it shouldn't be. Using profile tag without this part made all work just fine.


Solution

  • With Spartacus, this cookie doesn’t make sense anymore. It is created by the Commerce backend and works best in combination with an accelerator frontend. Cds-spartacus in combination with ProfileTag relies on the anonymous consents or the user consents (depending on the user being logged in or not) loaded by Spartacus. More information about anonymous consents can be found here: https://sap.github.io/spartacus-docs/anonymous-consent/.