Support for Google Tag Manager's "Consent Initialization" trigger

Created on 12 July 2022, over 2 years ago
Updated 8 August 2024, 3 months ago

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/

✨ Feature request
Status

Active

Version

2.0

Component

Code

Created by

πŸ‡¬πŸ‡§United Kingdom graham73may

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • πŸ‡ΊπŸ‡ΈUnited States jrb Raleigh-Durham Area, NC, USA

    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.

  • πŸ‡¬πŸ‡§United Kingdom scott_euser

    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 ✨ Make the module compatible with Google Consent Mode RTBC is still work in progress there though.

  • πŸ‡¨πŸ‡­Switzerland DamienMo

    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".

Production build 0.71.5 2024