Salesforce Dictionary - Free Salesforce GlossarySalesforce Dictionary
Full Cookie entry
How-to guide

How to set up Cookie Consent on Experience Cloud

Configure the Cookie Consent capability on an Experience Cloud site so non-essential cookies only run after a visitor agrees. This covers the high-level admin and developer steps; build the banner UI to match your brand.

By Dipojjal Chakrabarti · Founder & Editor, Salesforce DictionaryLast updated Jun 16, 2026

Configure the Cookie Consent capability on an Experience Cloud site so non-essential cookies only run after a visitor agrees. This covers the high-level admin and developer steps; build the banner UI to match your brand.

  1. Turn on consent in Security and Privacy settings

    In Setup, open the Security and Privacy area and enable cookie consent management for the org. Decide whether consent applies only to Required cookies or extends to Marketing, Preference, and Statistics categories.

  2. Build a Cookie Consent Lightning Web Component

    Create an LWC that imports the lightning/userConsentCookie module. Add a toggle for each category and wire the controls to setCookieConsent so the visitor decision is stored in the CookieConsent cookie.

  3. Place the component on the site

    In Experience Builder, add your consent component to the site so it appears on first visit. Confirm the CookieConsentPolicy and CookieConsent cookies are written after a choice is made.

  4. Gate non-essential cookies behind the decision

    Before any marketing or statistics script runs, call isCategoryAllowedForCurrentConsent for its category. Only load the pixel or set the cookie when that category is allowed.

Key options
Consent scoperemember

Whether consent covers only Required cookies or the full set of Marketing, Preference, and Statistics categories.

Cookie categoriesremember

The four buckets (Required, Marketing, Preference, Statistics) that each cookie on the site maps to for consent decisions.

CMP integrationremember

Whether you wire the banner to a third-party Consent Management Platform or keep the workflow fully inside Salesforce.

Gotchas
  • Required cookies always run; do not try to gate the session cookie behind consent or you will break login.
  • The banner UI is yours to build. Salesforce supplies the module and storage cookies, not a finished design.
  • Map every cookie on the site to a category before launch, including custom cookies you set from Apex or LWC.

See the full Cookie entry

Cookie includes the definition, worked example, deep dive, related terms, and a quiz.