Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

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 can add the adsbygoogle requestNonPersonalizedAds configuration to your Google AdSense script. Follow these steps:

Add the Google AdSense script to your HTML file outside of the GlowCookies configuration, so that it will load regardless of the user's cookie consent.

<script async src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js?client=ca-pub-YOUR_PUBLISHER_ID" crossorigin="anonymous"></script>

Replace YOURPUBLISHERID with your actual Google AdSense publisher ID.

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. html Copy code

<script src="https://cdn.jsdelivr.net/gh/manucaralmo/GlowCookies@3.1.7/src/glowCookies.min.js"></script>
<script>
    function setNonPersonalizedAds() {
        (adsbygoogle = window.adsbygoogle || []).requestNonPersonalizedAds = 1;
    }

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

With this setup, ads will be displayed regardless of the user's cookie consent, but if the user rejects cookies, only non-personalized ads will be shown without tracking. This way, you can comply with privacy regulations while still displaying ads on your website.

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 can add the adsbygoogle requestNonPersonalizedAds configuration to your Google AdSense script. Follow these steps:

Add the Google AdSense script to your HTML file outside of the GlowCookies configuration, so that it will load regardless of the user's cookie consent.

<script async src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js?client=ca-pub-YOUR_PUBLISHER_ID" crossorigin="anonymous"></script>

Replace YOURPUBLISHERID YOUR_PUBLISHER_ID with your actual Google AdSense publisher ID.

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. html Copy code

<script src="https://cdn.jsdelivr.net/gh/manucaralmo/GlowCookies@3.1.7/src/glowCookies.min.js"></script>
<script>
    function setNonPersonalizedAds() {
        (adsbygoogle = window.adsbygoogle || []).requestNonPersonalizedAds = 1;
    }

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

With this setup, ads will be displayed regardless of the user's cookie consent, but if the user rejects cookies, only non-personalized ads will be shown without tracking. This way, you can comply with privacy regulations while still displaying ads on your website.

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 can add the adsbygoogle requestNonPersonalizedAds need to modify the GlowCookies configuration script to your control the ad loading behavior based on user consent. Here's the correct approach:

Load the Google AdSense script. Follow these steps:script only after the user has interacted with the GlowCookies banner.

Add the Google AdSense Update the GlowCookies configuration script to your HTML file outside of the GlowCookies configuration, so that it load a custom script based on the user's consent. This custom script will load regardless of the user's cookie consent.configure adsbygoogle to request non-personalized ads if the user rejects cookies and personalized ads if the user accepts cookies.

<script async src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js?client=ca-pub-YOUR_PUBLISHER_ID" crossorigin="anonymous"></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.

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. html Copy code

<script src="https://cdn.jsdelivr.net/gh/manucaralmo/GlowCookies@3.1.7/src/glowCookies.min.js"></script>
<script>
    function setNonPersonalizedAds() {
        (adsbygoogle = window.adsbygoogle || []).requestNonPersonalizedAds = 1;
    }

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

With this setup, ads will not be displayed regardless of the user's cookie consent, but if until the user interacts with the GlowCookies banner. If the user rejects cookies, only non-personalized ads will be shown without tracking. This way, you can comply with privacy regulations while still displaying ads on your website.If the user accepts cookies, personalized ads and tracking scripts will be activated.