Skip to content

Set up consent mode #222

@joachimVT

Description

@joachimVT

To setup a consent solution on a webshop and integrate consent mode (AKA cookie banner) a default consent mode should be setup. I think it can be added in script.phtml so that easy integration with a custom cookie banner can be added.

Would it be beneficial to update the script.phtml file like described here: https://developers.google.com/tag-platform/security/guides/consent?consentmode=advanced#implementation_example

events.forEach(function (eventType) {
window.removeEventListener(eventType, initYireoGoogleTagManager2);
});

// Define dataLayer and the gtag function.
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}

// Set default consent to 'denied' as a placeholder
// Determine actual values based on your own requirements
gtag('consent', 'default', {
'ad_storage': 'denied',
'ad_user_data': 'denied',
'ad_personalization': 'denied',
'analytics_storage': 'denied'
});

(function (w, d, s, l, i) {
w[l] = w[l] || [];
w[l].push({'gtm.start': new Date().getTime(), event: 'gtm.js'});
var f = d.getElementsByTagName(s)[0],
j = d.createElement(s),
dl = l != 'dataLayer' ? '&l=' + l : '';
j.async = true;
j.src = '<?= $config->getGoogleTagmanagerUrl() ?>' + '/gtm.js?id=' + i + dl;
f.parentNode.insertBefore(j, f);
})(window, document, 'script', 'dataLayer', '<?= $config->getId() ?>');

I could add a PR for this.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions