[GA extension configuring using Adobe Launch] - How to Prevent Google Analytics Cookies from Dropping Before Consent Using Adobe Launch and OneTrust | Community
Skip to main content
May 23, 2025
Solved

[GA extension configuring using Adobe Launch] - How to Prevent Google Analytics Cookies from Dropping Before Consent Using Adobe Launch and OneTrust

  • May 23, 2025
  • 1 reply
  • 523 views

I'm currently implementing Google Analytics on my website using both the Google Universal Analytics and gtag extensions in Adobe Launch.

Consent management is handled through OneTrust, using the official extension, with the consent model set to opt-out by default. I’ve successfully configured custom code to ensure all Adobe-related cookies are only set after the user provides the appropriate consent.

However, I've encountered an issue where Google Analytics cookies (_ga, _gid, and _gat) are being dropped on page load, even when the user has not yet consented. From my investigation, it appears these cookies are automatically set by the Google Universal Analytics and gtag extensions, regardless of consent status.

Question:
Is there a recommended way to prevent these GA cookies from being set until the user has explicitly opted in — ideally while still using the Google Analytics and gtag extensions in Adobe Launch? Or does this require a more manual approach (e.g., loading GA scripts conditionally via custom code based on consent)?

Any best practices or implementation tips would be greatly appreciated!

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Best answer by Asheesh_Pandey

@saurabh_pathak 

Issue: By default, Google Universal Analytics and gtag extensions in Adobe Launch load the GA script (analytics.js or gtag.js) immediately, and that’s what sets the (_ga, _gid, and _gat) cookies even before any consent decision is made.

How to solve it: 

To ensure full compliance with your opt-out-by-default model, you’ll need to load GA scripts only after consent is granted, using custom code and Launch rules.

Option 1:

Using Custom Code

if (typeof OptanonActiveGroups !== 'undefined' && OptanonActiveGroups.includes('C0002')) { // Analytics consent group ('C0002" is an example ID, your OneTrust setup may diffrent) // Load GA manually here }

Option 2: use the OneTrust event callback (OptanonWrapper or OnConsentChanged) to trigger your GA load rule when consent is given.

Option 3: create a Data Element that returns whether the analytics group has been consented to, and use that as a condition in your Launch rules.

 

These options guarantees the GA cookies are only dropped after the user opts in.

1 reply

Asheesh_Pandey
Community Advisor
Asheesh_PandeyCommunity AdvisorAccepted solution
Community Advisor
May 24, 2025

@saurabh_pathak 

Issue: By default, Google Universal Analytics and gtag extensions in Adobe Launch load the GA script (analytics.js or gtag.js) immediately, and that’s what sets the (_ga, _gid, and _gat) cookies even before any consent decision is made.

How to solve it: 

To ensure full compliance with your opt-out-by-default model, you’ll need to load GA scripts only after consent is granted, using custom code and Launch rules.

Option 1:

Using Custom Code

if (typeof OptanonActiveGroups !== 'undefined' && OptanonActiveGroups.includes('C0002')) { // Analytics consent group ('C0002" is an example ID, your OneTrust setup may diffrent) // Load GA manually here }

Option 2: use the OneTrust event callback (OptanonWrapper or OnConsentChanged) to trigger your GA load rule when consent is given.

Option 3: create a Data Element that returns whether the analytics group has been consented to, and use that as a condition in your Launch rules.

 

These options guarantees the GA cookies are only dropped after the user opts in.