Skip to content

Add Usercentrics CMP (cookie consent + GDPR compliance)#3293

Draft
isstuev wants to merge 1 commit intomainfrom
fe-usercentrics-cmp
Draft

Add Usercentrics CMP (cookie consent + GDPR compliance)#3293
isstuev wants to merge 1 commit intomainfrom
fe-usercentrics-cmp

Conversation

@isstuev
Copy link
Copy Markdown
Contributor

@isstuev isstuev commented Feb 24, 2026

Description and Related Issue(s)

resolves #3289

Proposed Changes

added NEXT_PUBLIC_USERCENTRICS_CONFIG variable to set usercentrics script src and ruleset id.

Additional Information

Usercentrics has manual and auto modes. Here we support manual mode (client who requested feature uses manual mode).

Usercentrics requires to set the exact website domain (or list of the domains) on their side, otherwise won't work. Also, at least one Data Processing Services should be added to ruleset. If empty, usercentrics treat any user selection as 'ALL_ACCEPTED'.

Also, there are 3 categories: essential, functional and marketing. In this PR, only marketing acceptance is supported (including 'accept all' case).

Checklist for PR author

  • I have tested these changes locally.
  • I added tests to cover any new functionality, following this guide
  • Whenever I fix a bug, I include a regression test to ensure that the bug does not reappear silently.
  • If I have added a feature or functionality that is not privacy-compliant (e.g., tracking, analytics, third-party services), I have disabled it for private mode.
  • If I have added, changed, renamed, or removed an environment variable
    • I updated the list of environment variables in the documentation
    • I made the necessary changes to the validator script according to the guide
    • I added "ENVs" label to this pull request

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Feb 24, 2026

Important

Review skipped

Auto reviews are disabled on this repository. To trigger a review, include @coderabbitai review in the PR description. Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: dfc55309-9c2b-4fe5-b22f-e745d07039d6

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@isstuev isstuev force-pushed the fe-usercentrics-cmp branch from 50f44ce to 9ad1416 Compare March 6, 2026 12:32

return {
'script-src': [
scriptOrigin,
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we provide the complete link to the script instead of just its origin to make the rule stricter?

Comment thread pages/_document.tsx
Comment on lines +87 to +100
{ googleAnalyticsFeature.isEnabled && (
<>
<script
{ ...(usercentricsFeature.isEnabled ? { type: 'text/plain', 'data-usercentrics': 'Google Analytics' } : {}) }
async
src={ `https://www.googletagmanager.com/gtag/js?id=${ googleAnalyticsFeature.propertyId }` }
/>
{ }
<script
{ ...(usercentricsFeature.isEnabled ? { type: 'text/plain', 'data-usercentrics': 'Google Analytics' } : {}) }
dangerouslySetInnerHTML={{ __html: GA_INLINE_SCRIPT }}
/>
</>
) }
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is it necessary to include the Google Analytics script in the head tag instead of loading it after the page loads? I assume there will be two scripts loaded: one from here and another from the ui/shared/GoogleAnalytics.tsx component.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add Usercentrics CMP (cookie consent + GDPR compliance)

2 participants