- Issue created by @francismak
- π¨πSwitzerland zilloww
Hello, any new on this update? Just tried the patch but unfortunately, it is not working for me. (See Gtag preview mode screenshot linked below)
I tried it on `2.0.6`. When I try it on `^2.0-dev@dev`, the patch isn't applied.
While waiting for an answer, I'll try some tweaks to see if I can do something for this issue that is becoming a little critical because of the new Google consent restrictions deadline...
- πΊπΈUnited States philltran Detroit, MI
@zilloww Looks like this patch was committed via issue 3180185 β¨ Support Google Analytics consent mode Fixed
- πΊπΈUnited States philltran Detroit, MI
@zilloww Opps. My mistake. This patch moves the
if (config.consentMode === true) { gtag('consent', 'default', { ad_storage: 'denied', analytics_storage: 'denied', ad_user_data: 'denied', ad_personalization: 'denied', wait_for_update: 500, }); }
code block from `/js/gtag.js` to `/js/gtm.js`
- πΊπΈUnited States philltran Detroit, MI
I updated the patch to work on 2.0.x dev branch. I added a condition on gtag implementation of default consent to only apply if `gtm` is empty. Otherwise we would have consent.default set twice. I tested this successfully with GTM-xxx and AW-xxx ids. Using a G-xxx id made the consent.default load too late. I will continue to look into that issue and am open to anyone else's insight on the matter.
- Status changed to Needs review
4 months ago 9:48pm 1 January 2025 @philltran @zilloww Caution, some of these things don't look right.
1. I'm certain that Default Consent should not go before the Consent Initialization event in GTM. The Consent Initialization action is designed to be the very first thing that fires on a page, and it typically fires off the cookie consent banner, or establishes Default Consent settings. I know you're not firing anything from that action, but industry practice is to have Consent Initialization as #1. This way, you're safe if Google changes something assuming everyone has Consent Init first.
Links with useful nuggets and screenshots of how GTM consent mode in Preview Mode should look:
https://www.simoahava.com/analytics/consent-settings-google-tag-manager/
https://developers.google.com/tag-platform/tag-manager/templates/api#set...2. Caution with the GTAG js command that you're using I: know we got it form Google's documentation, but I can't see the context of your function, but there should be a line above it
// Define dataLayer and the gtag function. window.dataLayer = window.dataLayer || []; function gtag(){dataLayer.push(arguments);} // Set default consent to 'denied' as a placeholder // Determine actual values based on your own requirements gtag('consent', 'default', { 'ad_storage': 'denied', 'ad_user_data': 'denied', 'ad_personalization': 'denied', 'analytics_storage': 'denied' });more later.....
- π§πͺBelgium matthiasm11
See also π gtag.js/gtm.js order in D10.4 vs default consent Active .