cookieconsent icon indicating copy to clipboard operation
cookieconsent copied to clipboard

[Docs]: how to configure google consent mode

Open orestbida opened this issue 10 months ago • 11 comments

What is the improvement/update you wish to see?

Add a section in the docs on how to configure google consent mode (v2). (#665)

Link the related docs page, if it exists.

No response

orestbida avatar Apr 01 '24 19:04 orestbida

how to do it please?

H0nzik1 avatar Apr 03 '24 18:04 H0nzik1

I assume this is the way forward, or? https://github.com/orestbida/cookieconsent/issues/665#issuecomment-2022621032

jannejava avatar Apr 22 '24 05:04 jannejava

how to do it please?

This article explains how to implement consent mode with v2.9.

Charissa24 avatar May 01 '24 14:05 Charissa24

how to do it please?

This article explains how to implement consent mode with v2.9.

Interesting, this seems to be another way. It seems that you can configure cookie consent without touching the site's code, instead using Google Tag Manager, or is this the way?

jannejava avatar May 15 '24 05:05 jannejava

I do it this way

function updatePreferences(cookie) {
    let preferences = {
        analytics_storage: "denied",
        ad_storage: "denied",
        ad_user_data: "denied",
        ad_personalization: "denied"
    };

    cookie.categories.forEach(category => {
        if (category === 'analytics') {
            preferences.analytics_storage = "granted";
        }
        if (category === 'advertising') {
            preferences.ad_storage = "granted";
            preferences.ad_user_data = "granted";
            preferences.ad_personalization = "granted";
        }
    });

    if (preferences) {
        window.dataLayer = window.dataLayer || [];

        function gtag() {
            window.dataLayer.push(arguments);
        }

        gtag("consent", "update", preferences);

        setTimeout(function () {
            window.location.reload();
        }, 1000);
    }
}

onFirstConsent: ({cookie}) => updatePreferences(cookie),
onChange: ({cookie}) => updatePreferences(cookie),

Hucoo avatar May 15 '24 14:05 Hucoo

@Hucoo Are you using v3?

amitsarkerr avatar May 16 '24 12:05 amitsarkerr

@Hucoo Are you using v3?

What you mean about v3?

Hucoo avatar May 16 '24 18:05 Hucoo

@Hucoo Are you using v3?

What you mean about v3?

Have you found a solution for cookie consent version 3 to ensure compatibility with Google Consent?

amitsarkerr avatar May 16 '24 19:05 amitsarkerr

Hi everyone, there's an updated tutorial for version 3: https://uninterrupted.tech/blog/manage-user-cookie-consent-with-google-tag-manager-adapting-to-cookie-consent-v3/

Charissa24 avatar May 23 '24 13:05 Charissa24

@Charissa24 is this tutorial written by yourself?

I tried to understand it but I don't get the steps needed, maybe because there seem to be many possibilities to use and configure Tag Manager.

https://github.com/brainsum/cookieconsent?tab=readme-ov-file#consent-mode-v2 and https://developers.google.com/tag-platform/security/guides/consent?consentmode=advanced&hl=de#region-specific-behavior just suggest to set gtag() parameters which seem to make it much more easy: It doesn't require me to go through the Google Tag Manager Container's GUI, am I right?

alxndr-w avatar Aug 29 '24 13:08 alxndr-w

@Charissa24 is this tutorial written by yourself?

I tried to understand it but I don't get the steps needed, maybe because there seem to be many possibilities to use and configure Tag Manager.

https://github.com/brainsum/cookieconsent?tab=readme-ov-file#consent-mode-v2 and https://developers.google.com/tag-platform/security/guides/consent?consentmode=advanced&hl=de#region-specific-behavior just suggest to set gtag() parameters which seem to make it much more easy: It doesn't require me to go through the Google Tag Manager Container's GUI, am I right?

I didn't write this tutorial. But it should all be done within Tag Manager.

Charissa24 avatar Aug 29 '24 14:08 Charissa24