From b5e193833465ce9028319f5f738103778c75ed84 Mon Sep 17 00:00:00 2001 From: Dirk Persky Date: Wed, 27 Mar 2024 10:27:48 +0100 Subject: [PATCH] #127 Consent Mode v2 improvement, render blocking third-party scripts --- .../Tracking/googleTagManager.typoscript | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/Configuration/TypoScript/Tracking/googleTagManager.typoscript b/Configuration/TypoScript/Tracking/googleTagManager.typoscript index 322dfcf..f1a810a 100644 --- a/Configuration/TypoScript/Tracking/googleTagManager.typoscript +++ b/Configuration/TypoScript/Tracking/googleTagManager.typoscript @@ -16,16 +16,10 @@ page.headerData.998 { 15.wrap ( if(typeof window.tx_cookieconsent_init == 'undefined'){ window.tx_cookieconsent_init = true; - /* Google Tag Manager */ - (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= - 'https://www.googletagmanager.com/gtm.js?id='+i+dl;f.parentNode.insertBefore(j,f); - })(window,document,'script','dataLayer','#'); - /* End Google Tag Manager */ window.dataLayer = window.dataLayer || []; if(typeof window.gtag == 'undefined') window.gtag = function() { window.dataLayer.push(arguments); }; + window.gtag('consent', 'default', { ad_storage: 'denied', analytics_storage: 'denied', @@ -33,6 +27,16 @@ if(typeof window.tx_cookieconsent_init == 'undefined'){ ad_personalization: 'denied', wait_for_update: 500 }); + + setTimeout(function(){ + /* Google Tag Manager */ + (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= + 'https://www.googletagmanager.com/gtm.js?id='+i+dl;f.parentNode.insertBefore(j,f); + })(window,document,'script','dataLayer','#'); + /* End Google Tag Manager */ + }, 0); } ) 15.wrap.splitChar = #