@@ -18,8 +18,8 @@ if (!isset($escaper)) {
1818$ script = '' ;
1919?>
2020<!-- Google Tag Manager -->
21- <?php if ($ block ->isSpeedOptimizationEnabled () && $ block ->getRequest ()->getModuleName () !== 'checkout ' ) { ?>
22- <?php $ script .= <<<script
21+ <?php if ($ block ->isSpeedOptimizationEnabled () && $ block ->getRequest ()->getModuleName () !== 'checkout ' ) { ?>
22+ <?php $ script .= "
2323 document.addEventListener('scroll', mfGtmUserActionDetect);
2424 document.addEventListener('mousemove', mfGtmUserActionDetect);
2525 document.addEventListener('touchstart', mfGtmUserActionDetect);
@@ -31,17 +31,15 @@ $script = '';
3131 window.mfGtmUserActionDetected = true;
3232 mfLoadGtm();
3333 }
34- script ;
35- ?>
36- <?php } else { ?>
37- <?php $ script .= <<<script
34+ " ; ?>
35+ <?php } else { ?>
36+ <?php $ script .= "
3837 window.mfGtmUserActionDetected = true;
39- script ;
40- ?>
41- <?php } ?>
38+ " ; ?>
39+ <?php } ?>
4240
43- <?php if ($ block ->isProtectCustomerDataEnabled ()) { ?>
44- <?php $ script .= <<<script
41+ <?php if ($ block ->isProtectCustomerDataEnabled ()) { ?>
42+ <?php $ script .= "
4543 window.dataLayer = window.dataLayer || [];
4644 function gtag() { dataLayer.push(arguments); }
4745 gtag('consent', 'default', {
@@ -59,22 +57,20 @@ script;
5957 'wait_for_update': 2000
6058 });
6159 /* cookieyes.com start */
62- gtag(" set", " ads_data_redaction" , true);
63- gtag(" set", " url_passthrough" , true);
60+ gtag(' set', ' ads_data_redaction' , true);
61+ gtag(' set', ' url_passthrough' , true);
6462 /* cookieyes.com end */
65- script ;
66- ?>
63+ " ; ?>
6764
68- <?php if ($ block ->isLoadBeforeConsent ()) { ?>
69- <?php $ script .= <<<script
65+ <?php if ($ block ->isLoadBeforeConsent ()) { ?>
66+ <?php $ script .= "
7067 window.mfGtmLoadBeforeCookieAllowed = true;
7168 mfLoadGtm();
72- script ;
73- ?>
74- <?php } ?>
69+ " ; ?>
70+ <?php } ?>
7571
76- <?php if ($ block ->isCookieRestrictionModeEnabled ()) { ?>
77- <?php $ script .= <<<script
72+ <?php if ($ block ->isCookieRestrictionModeEnabled ()) { ?>
73+ <?php $ script .= "
7874 (function () {
7975 function getCookieValue(cookieName) {
8076 let name = cookieName + '=';
@@ -134,21 +130,19 @@ script;
134130 }, 1000);
135131 }
136132 })();
137- script ;
138- ?>
139- <?php } ?>
133+ " ; ?>
134+ <?php } ?>
140135
141- <?php } else { ?>
142- <?php $ script .= <<<script
136+ <?php } else { ?>
137+ <?php $ script .= "
143138 window.mfGtmUserCookiesAllowed = true;
144139 mfLoadGtm();
145- script ;
146- ?>
147- <?php } ?>
148- <?php $ script .= <<<script
140+ " ; ?>
141+ <?php } ?>
142+ <?php $ script .= "
149143
150144 function getMfGtmCustomerIdentifier() {
151- return localStorage.getItem(" mf_gtm_customer_identifier" ) ? localStorage.getItem(" mf_gtm_customer_identifier" ) : null;
145+ return localStorage.getItem(' mf_gtm_customer_identifier' ) ? localStorage.getItem(' mf_gtm_customer_identifier' ) : null;
152146 }
153147
154148 function mfLoadGtm() {
@@ -157,35 +151,32 @@ script;
157151
158152 if (window.mfGTMTriedToLoad) return;
159153 window.mfGTMTriedToLoad = true;
160- script ;
161- ?>
162- <?php if ($ block ->getPublicId ()) { ?>
163- <?php if ('use_public_id ' === $ block ->getConfig ()->getInstallGtm ()) { ?>
164- <?php $ script .= <<<script
154+ " ; ?>
155+ <?php if ($ block ->getPublicId ()) { ?>
156+ <?php if ('use_public_id ' === $ block ->getConfig ()->getInstallGtm ()) { ?>
157+ <?php $ script .= "
165158 (function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({'gtm.start':
166159 new Date().getTime(),event:'gtm.js'});var f=d.getElementsByTagName(s)[0],
167160 j=d.createElement(s),dl=l!='dataLayer'?'&l='+l:'';j.async=true;j.src=
168161 'https:' + '/' + '/' + 'www.googletagmanager.com/gtm.js?id='+i+dl;f.parentNode.insertBefore(j,f);
169162 })(window,document,'script','dataLayer',' {$ escaper ->escapeHtml ($ block ->getPublicId ())}');
170- script ;
171- ?>
172- <?php } elseif ('use_head_and_body_script ' === $ block ->getConfig ()->getInstallGtm ()) { ?>
173- <?php $ script .= $ block ->getGtmScript (); ?>
174- <?php } ?>
175- <?php } ?>
176- <?php $ script .= <<<script
163+ " ; ?>
164+ <?php } elseif ('use_head_and_body_script ' === $ block ->getConfig ()->getInstallGtm ()) { ?>
165+ <?php $ script .= $ block ->getGtmScript (); ?>
166+ <?php } ?>
167+ <?php } ?>
168+ <?php $ script .= "
177169 }
178- script ;
179- ?>
170+ " ; ?>
180171<?= /* @noEscape */ $ mfSecureRenderer ->renderTag ('script ' , [], $ script , false ) ?>
181172
182173<?php if (!$ mfHyvaThemeDetection ->execute ()) { ?>
183- <?php $ script = <<<script
174+ <?php $ script = "
184175 if (!window.MagefanRocketJsCustomOptimization && window.require)
185176 require(['jquery', 'Magento_Customer/js/customer-data'], function ($, customer) {
186177 function updateMfGtmCustomerIdentifier(data) {
187178 if (data.mf_gtm_customer_identifier) {
188- localStorage.setItem(" mf_gtm_customer_identifier" , data.mf_gtm_customer_identifier);
179+ localStorage.setItem(' mf_gtm_customer_identifier' , data.mf_gtm_customer_identifier);
189180 }
190181 }
191182 let customerData = customer.get('customer');
@@ -195,27 +186,25 @@ script;
195186 }.bind(this));
196187 updateMfGtmCustomerIdentifier(customerData());
197188 });
198- script ;
199- ?>
189+ " ; ?>
200190 <?= /* @noEscape */ $ mfSecureRenderer ->renderTag ('script ' , [], $ script , false ) ?>
201191<?php } else { ?>
202- <?php $ script = <<<script
192+ <?php $ script = "
203193 /* Hyva code */
204194 function mfHyvaGtmSetCustomerIdentifier(event) {
205195 let data, j;
206196 let sections = event.detail.data;
207197 for (j in sections) {
208198 data = sections[j];
209199 if (data.mf_gtm_customer_identifier) {
210- localStorage.setItem(" mf_gtm_customer_identifier" , data.mf_gtm_customer_identifier);
200+ localStorage.setItem(' mf_gtm_customer_identifier, data.mf_gtm_customer_identifier);
211201 return;
212202 }
213203 }
214204 }
215- window.addEventListener(" private-content-loaded" , mfHyvaGtmSetCustomerIdentifier);
205+ window.addEventListener(' private-content-loaded' , mfHyvaGtmSetCustomerIdentifier);
216206 /* End Hyva code */
217- script ;
218- ?>
207+ " ; ?>
219208 <?= /* @noEscape */ $ mfSecureRenderer ->renderTag ('script ' , [], $ script , false ) ?>
220209<?php } ?>
221210<!-- End Google Tag Manager -->
0 commit comments