Problem/Motivation

Hello, I have a feature request.

Google Tag Manager has recently added some new default triggers, the one that could be very useful in relation to this module is "Consent Initialization - All Pages"

Steps to reproduce

Set up a Tag in GTM with the trigger set to "Consent Initialization - All pages".

In GTM, click preview and load the page with the debugger.

GTM fires the tag before you click Accept or Don't Accept.

Proposed resolution

Add support to this module so that it reports back to GTM that consent has been given. (Is this possible?)

If we could add something to the community template gallery that would be fantastic.
https://support.google.com/tagmanager/answer/9454109?hl=en&ref_topic=300...

More info:
https://support.google.com/tagmanager/answer/10718549?hl=en

Nice blog post about the new consent mode:
https://www.simoahava.com/analytics/consent-settings-google-tag-manager/

Comments

graham73may created an issue. See original summary.

svenryen’s picture

Version: 8.x-1.19 » 2.0.x-dev
jrb’s picture

I've created a sandbox module that does this here:

https://www.drupal.org/sandbox/jrb/3433126

In order for this to work, the Google Tag Manager gtag script must be included on the page by some other method. This can be done with a custom script or with a module like Google Tag.

Just enable this module; and, when the user consents to cookies, it will call gtag with this:

gtag('consent', 'update', {
  'ad_user_data': 'granted',
  'ad_personalization': 'granted',
  'ad_storage': 'granted',
  'analytics_storage': 'granted'
});

Depending on what the maintainers of this module would like to do, this code could be folded into this module as a submodule or I could release it as a full module. Either way is OK with me.

scott_euser’s picture

I think probably this is the way to go? https://www.drupal.org/project/eu_cookie_compliance_gtm which seems to connect the google_tag and eu_cookie_compliance modules. I did notice #3332626: Make the module compatible with Google Consent Mode is still work in progress there though.

damienmo’s picture

What you are describing in this issue is the normal behavior.

GTM fires the tag before you click Accept or Don't Accept.

"Consent Initialization - All Pages" is supposed to be the first trigger to fire. It should be used to trigger a CookieBot Tag For example.

If you want your tag to be run after the consent has been given you should create a custom event trigger matching "cookie_consent_update".

atowl’s picture

Status: Active » Closed (won't fix)

Hi
This issue is tagged with version 2.

Since we are no longer releasing a version 2 i am closing this issue,

I wish to thank those who contribute their time to this issue

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.