- Developer guides
Configure consent for tracking and personalization
Your application controls whether Content SDK creates visitor cookies and runs tracking or personalization features. Connect your consent-management solution to both the browser and server integrations so that they use the visitor’s consent choice.
Content SDK does not provide a cookie-consent UI or a direct integration with consent-management platforms. Use your preferred solution to collect consent and make the resulting state available to your application.
Cookie configuration alone is not a complete consent implementation. You must also conditionally enable or disable the personalization middleware/proxy and page-view tracking through CdpPageView. PersonalizeProxy enables cookies internally. CdpPageView calls pageView(), which cookie flags do not disable.
This topic covers Content SDK for Next.js 2.x and assumes that your application already initializes Content SDK and uses a consent-management solution.
Your application must:
- Determine whether the visitor has granted the consent required for each feature.
- Make consent state available before browser tracking starts.
- Make consent state available to the server before personalization runs.
- Handle changes to the visitor’s consent choice.
The examples use a single consent choice for analytics and personalization. Adapt the consent lookup to your application’s requirements. An absent or unreadable consent value doesn't mean consent is granted.
For plugin and adapter setup, see Initializing tracking, events, and personalization in the Content SDK.
Configure browser cookie creation
In your existing browser initContentSdk() call, pass the applicable consent state to:
analyticsPlugin.options.enableCookieto control creation ofsc_cid.personalizeBrowserPlugin.options.enablePersonalizeCookieto control browser creation ofsc_cid_personalize.
Browser web personalization is optional and standard starters typically do not enable it. If your application uses it, also make webPersonalization conditional. This option loads the browser personalization script independently of the cookie flags, so disabling cookie creation alone doesn't prevent the script from loading.
The following example illustrates browser initialization when the browser is responsible for creating both cookies. It assumes that cookieConsentGiven comes from your application’s consent implementation:
Use a cookie domain appropriate for your deployment.
When these cookie options are false, the corresponding plugin initialization doesn't create the cookies. However, this doesn't delete cookies that already exist or automatically suppress every tracking or personalization call.
Creating sc_cid_personalize requires both enableCookie and enablePersonalizeCookie to be true in the relevant initialization.
If your application uses both browser and server personalization plugins, configure only one side to create sc_cid_personalize. If the server creates it, keep the browser’s enablePersonalizeCookie set to false.
Conditionally send page-view events
In starter applications, update the disabled() function in src/components/content-sdk/CdpPageView.tsx to check consent. Keep the existing development-mode check and any other conditions your application uses.
The following fragment assumes that cookieConsentGiven is available inside the component and reflects your application's current consent state:
CdpPageView checks disabled() before calling pageView(). It does not initialize cookies. Setting enableCookie: false in SDK initialization does not prevent this event API from sending requests.
Alternatively, conditionally render the component:
Apply consent checks to any additional tracking calls your application makes. Do not assume that the cookie options automatically block custom events or other direct SDK calls.
Make consent available to the server
Server-side personalization runs before browser scripts execute. A consent value stored only in browser memory cannot control the initial server request.
Persist the consent state using an application-managed mechanism that the server can read, such as a consent cookie sent with incoming requests.
For example:
app_tracking_consent is an example application cookie, not a Content SDK cookie. Replace it with your own consent lookup.
If you use a consent-management platform, interpret its stored consent values according to that platform’s format and your configured consent categories. Do not treat the presence of its cookie alone as proof that the required consent was granted.
Conditionally run server-side personalization
Applications using PersonalizeProxy
Skip PersonalizeProxy when the visitor has not granted the required consent. Add a consent check to its existing configuration:
Preserve any existing skip conditions by combining them with the consent check.
PersonalizeProxy enables cookies internally. Changing browser plugin options does not change this server-side configuration. Skipping the proxy prevents its personalization processing from running for that request.
Applications initializing server plugins directly
If your application initializes server personalization itself, use server-readable consent state in both plugin configurations:
This fragment assumes that analyticsAdapter and personalizeAdapter are configured for your server environment.
Disabling these options prevents cookie creation through this initialization path. To prevent personalization processing, also use consent checks before executing personalization logic.
Behavior when consent is absent
The behavior depends on applying consent consistently across the application:
| Application configuration | Result |
|---|---|
enableCookie is false in the relevant plugin initialization. | That initialization does not create sc_cid. |
enablePersonalizeCookie is false in the relevant plugin initialization. | That initialization does not create sc_cid_personalize. |
The application's CdpPageView.disabled() returns true, or the application does not render the component. | That component does not send page-view events. |
The application suppresses direct pageView() and other event calls. | Those calls do not send tracking requests. |
The application skips PersonalizeProxy. | That proxy does not run server-side personalization. |
Browser webPersonalization is false. | That plugin initialization does not load the web personalization script. |
The application suppresses any direct personalize() calls. | Those calls do not request personalization decisions. |
When the application applies all applicable controls above, it does not send analytics/events or run personalization, and the visitor receives the default unpersonalized experience. This requires applying consent to every tracking and personalization integration in the application, not only setting the cookie flags to false.
These settings do not automatically remove existing cookies or guarantee that other application code sends no tracking requests. Review all tracking and personalization paths in your application.
Handle changes to consent
When a visitor changes their consent choice, make the updated state available to both browser and server execution.
Your consent-change handling must account for:
- Whether
CdpPageViewcan send page-view events. - Whether subsequent server requests can run personalization.
- Cookie-creation options used by directly initialized plugins.
- Browser personalization script loading and direct tracking or personalization calls.
Delete cookies when consent is withdrawn
When a visitor withdraws consent, stop the relevant tracking and personalization processing and delete these existing cookies:
sc_cidsc_cid_personalize- Legacy
sc_{contextId}andsc_{contextId}_personalizecookies, if present. Replace{contextId}with the context ID used when those cookies were created.
Setting cookie options to false only prevents creation. It does not delete existing cookies, and adapters can still read cookies left in the browser or incoming request.
Content SDK does not provide a public cookie-deletion API. Use your application's cookie-handling code to expire the cookies, matching the Domain and Path and preserving the Secure and SameSite settings used when they were set. Do not use the internal SDK deleteCookie helper as a public API.