Ask Your Question
0

How can I use GlowCookies for Google Adsense to comply with GDPR?

asked 2023-04-24 01:01:08 +0000

qstack gravatar image

edit retag flag offensive close merge delete

2 Answers

Sort by ยป oldest newest most voted
0

answered 2023-04-24 01:02:16 +0000

qstack gravatar image

o use GlowCookies with Google AdSense, you need to modify the GlowCookies configuration script to load the Google AdSense script only after the user has accepted cookies. Here's how to do it:

First, remove the default Google AdSense script from your HTML file if you've already added it. You will include it later within the GlowCookies configuration.

Update the GlowCookies configuration script with the customScript parameter. Add the Google AdSense script as a custom script that will only load after the user has accepted cookies.

<script src="https://cdn.jsdelivr.net/gh/manucaralmo/GlowCookies@3.1.7/src/glowCookies.min.js"></script>
<script>
    glowCookies.start('en', { 
        style: 1,
        analytics: 'G-FH87DE17XF', 
        facebookPixel: '990955817632355',
        policyLink: 'https://link-to-your-policy.com',
        customScript: [
            { 
                type: 'src', 
                position: 'head', 
                content: 'https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js?client=ca-pub-YOUR_PUBLISHER_ID', 
                crossorigin: 'anonymous' 
            },
            { 
                type: 'custom', 
                position: 'body', 
                content: `
                    (adsbygoogle = window.adsbygoogle || []).push({
                        google_ad_client: "ca-pub-YOUR_PUBLISHER_ID",
                        enable_page_level_ads: true
                    });
                ` 
            }
        ]
    });
</script>

Replace YOUR_PUBLISHER_ID with your actual Google AdSense publisher ID.

This configuration will load the Google AdSense script only after the user has accepted cookies. This way, you comply with the GDPR and other privacy regulations when using Google AdSense with GlowCookies.

edit flag offensive delete link more
0

answered 2023-04-24 01:05:20 +0000

plato gravatar image

updated 2023-04-24 01:17:08 +0000

The last approach completely disables the ad-display in case the user clicks on reject. Alternatively, it is possible to show non-personalized ads while disabling ad personalization and tracking. To achieve this, you need to modify the GlowCookies configuration script to control the ad loading behavior based on user consent. Here's the correct approach:

Load the Google AdSense script only after the user has interacted with the GlowCookies banner.

Update the GlowCookies configuration script to load a custom script based on the user's consent. This custom script will configure adsbygoogle to request non-personalized ads if the user rejects cookies and personalized ads if the user accepts cookies.

<script src="https://cdn.jsdelivr.net/gh/manucaralmo/GlowCookies@3.1.7/src/glowCookies.min.js"></script>
<script>
    function loadAdSenseScript() {
        var script = document.createElement('script');
        script.src = 'https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js?client=ca-pub-YOUR_PUBLISHER_ID';
        script.setAttribute('crossorigin', 'anonymous');
        script.async = true;
        document.head.appendChild(script);
    }

    function setNonPersonalizedAds() {
        loadAdSenseScript();
        (adsbygoogle = window.adsbygoogle || []).requestNonPersonalizedAds = 1;
    }

    function setPersonalizedAds() {
        loadAdSenseScript();
        (adsbygoogle = window.adsbygoogle || []).requestNonPersonalizedAds = 0;
    }

    glowCookies.start('en', { 
        style: 1,
        analytics: 'G-FH87DE17XF', 
        facebookPixel: '990955817632355',
        policyLink: 'https://link-to-your-policy.com',
        acceptedCallback: setPersonalizedAds,
        rejectedCallback: setNonPersonalizedAds
    });
</script>

Replace YOUR_PUBLISHER_ID with your actual Google AdSense publisher ID.

With this setup, ads will not be displayed until the user interacts with the GlowCookies banner. If the user rejects cookies, only non-personalized ads will be shown without tracking. If the user accepts cookies, personalized ads and tracking scripts will be activated.

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account. This space is reserved only for answers. If you would like to engage in a discussion, please instead post a comment under the question or an answer that you would like to discuss

Add Answer


Question Tools

1 follower

Stats

Asked: 2023-04-24 01:01:08 +0000

Seen: 31 times

Last updated: Apr 24 '23