Day 8 : Salesforce, Experience Cloud, cookies and a cup of milk

By

2 minutes de lecture

Hello everyone !

Today, I’m in charge of the 8th day of our Advent calendar and we are going to talk about cookies. This is a perfect timing to talk about those delicious biscuits that we can find in our daily use of Internet.

First step : Ingredients

  • A good cloud : This new winter 22 features are only available on Experience Cloud. For those who don’t know this cloud you can find an overview here.
  • A bit of API : This component requires API version 53.0 or later.
  • A pinch of LWC.

 

Second Step : The Cookies Recipe 

  1. First of all you have to enable cookie consent in Security & Privacy Settings, if you don’t, only the required types of cookies are allowed.
  2. Once the first step is done you can provide users the option to allow Marketing, Preference, and Statistics cookies as well.
  3. Next, go to your cookie consent LWC and import the user ConsentCookie module.
  4. Provide the user to consent all the cookie types you need (Required, Marketing, Preference, and Statistics) using the HTML file and JavaScript in your component.

 

Last Step : How to serve 

Furthermore, to continue with our cookies, here it’s the simplest way to use it in the Javascript part.

A table, not of chocolate but a String/Boolean one :

var consent = {
    "Preferences" : true, 
    "Marketing" : false 
}

Next, you must set it this way:

Sfdc.Cookie.setCookieConsent(consent);

Finally, if you want to test which cookies are used :

isCategoryAllowedForCurrentConsent("Marketing");

If you want to see how HTML can be set up for this cookies consent component you can go to the documentation here.

Hope you enjoyed this blog post and don’t forget to read all the previous ones, starting with this one wrote by Fabien Huot presenting the new Assignment Expiration feature on Permissions sets.

Stay safe and enjoy Christmas !

Read more posts

Enforce code standards with PMD

Developers working on a project usually set coding rules to have a standardized codebase. It is an important piece of the code maintainability, and it can be very easy …
March 2023
Advices
Scratch orgs

Uncovering Salesforce Settings: A Step-by-Step Guide for Scratch Orgs

Today, it’s pretty easy to build your Scratch Org definition file when you know what Settings you want to activate, as they are mapped with the same setting names …
February 2023
Advices
Business Analyst

Core qualities of a Business Analyst?

A common definition we are used to hear is that being a Business Analyst means to have a combination of both hard skills and soft skills. What does a …
June 2022
Advices
Image d'illustration d'une employée travaillant sur un ordinateur portable

Process builder and workflow make way to Flows (½)

Overview “If you can do it with a Workflow, then do it with a Process Builder, because everything a Workflow does, a Process Builder does it better”. If you …
March 2022
Advices

Day 22 : Salesforce new “Migrate To Flow tool” in Spring 22

As most of you already know, the workflow rules and process builders are planned to be retired in 2023 (no precise date defined so far). Today, I’m going to …
December 2021
Advices

Day 18 : Fake callout responses for test classes !

Hello everybody ! Today let’s talk about Apex tests classes in Salesforce. Everyone loves a good test class, and Salesforce makes it official by requiring to have a minimum …
December 2021
Advices