@@ -17,6 +17,9 @@ if (!isset($escaper)) {
1717
1818$ script = '' ;
1919?>
20+
21+ <?= $ block ->getLayout ()->createBlock (\Magefan \Community \Block \JsScript::class)->setMethod ('getCookie ' )->toHtml () ?>
22+
2023<!-- Google Tag Manager -->
2124<?php if ($ block ->isSpeedOptimizationEnabled () && $ block ->getRequest ()->getModuleName () !== 'checkout ' ) { ?>
2225 <?php $ script .= "
@@ -39,28 +42,35 @@ $script = '';
3942<?php } ?>
4043
4144<?php if ($ block ->isProtectCustomerDataEnabled ()) { ?>
42- <?php $ script .= "
43- window.dataLayer = window.dataLayer || [];
44- function gtag() { dataLayer.push(arguments); }
45- gtag('consent', 'default', {
46- 'ad_user_data': 'denied',
47- 'ad_personalization': 'denied',
48- 'ad_storage': 'denied',
49- 'analytics_storage': 'denied',
50- /* cookieyes.com start */
51-
52- 'functionality_storage': 'denied',
53- 'personalization_storage': 'denied',
54- 'security_storage': 'granted',
55- /* cookieyes.com end */
56-
57- 'wait_for_update': 2000
58- });
59- /* cookieyes.com start */
60- gtag('set', 'ads_data_redaction', true);
61- gtag('set', 'url_passthrough', true);
62- /* cookieyes.com end */
63- " ; ?>
45+ <?php
46+ $ script .= "
47+ window.dataLayer = window.dataLayer || [];
48+ function gtag() { dataLayer.push(arguments); }
49+ " ;
50+
51+ if (!$ block ->isMfCookieConsentExtensionEnabled ()) {
52+ $ script .= "
53+ gtag('consent', 'default', {
54+ 'ad_user_data': 'denied',
55+ 'ad_personalization': 'denied',
56+ 'ad_storage': 'denied',
57+ 'analytics_storage': 'denied',
58+ /* cookieyes.com start */
59+
60+ 'functionality_storage': 'denied',
61+ 'personalization_storage': 'denied',
62+ 'security_storage': 'granted',
63+ /* cookieyes.com end */
64+
65+ 'wait_for_update': 2000
66+ });
67+ /* cookieyes.com start */
68+ gtag('set', 'ads_data_redaction', true);
69+ gtag('set', 'url_passthrough', true);
70+ /* cookieyes.com end */
71+ " ;
72+ }
73+ ?>
6474
6575 <?php if ($ block ->isLoadBeforeConsent ()) { ?>
6676 <?php $ script .= "
@@ -91,6 +101,10 @@ $script = '';
91101 };
92102
93103 function customerDataAllowed() {
104+ if (MagefanJs.getCookie('mf_cookie_consent') === '1') {
105+ return true;
106+ }
107+
94108 let cookie = getCookieValue(
95109 ' {$ escaper ->escapeHtml (\Magento \Cookie \Helper \Cookie::IS_USER_ALLOWED_SAVE_COOKIE )}'
96110 );
@@ -107,15 +121,21 @@ $script = '';
107121 function grantConsent()
108122 {
109123 window.mfGtmUserCookiesAllowed = true;
110- gtag('consent', 'update', {
124+ " ;
125+
126+ if (!$ block ->isMfCookieConsentExtensionEnabled ()) {
127+ $ script .= "gtag('consent', 'update', {
111128 'ad_user_data': 'granted',
112129 'ad_personalization': 'granted',
113130 'ad_storage': 'granted',
114131 'analytics_storage': 'granted',
115132 'functionality_storage': 'granted',
116133 'personalization_storage': 'granted',
117134 'security_storage': 'granted'
118- });
135+ }); " ;
136+ }
137+
138+ $ script .= "
119139 };
120140
121141 if (customerDataAllowed()) {
0 commit comments