From 201bcb6e378682674e54610a81adc358ac5f6674 Mon Sep 17 00:00:00 2001 From: MaxBUhe Date: Tue, 19 Mar 2024 09:22:07 +0100 Subject: [PATCH] [OST#929760][Added] serverside tagging usability *missing any test, yet! --- Application/views/blocks/_gtm_js.tpl | 2 +- Application/views/blocks/_gtm_nojs.tpl | 2 +- Modules/Core/ViewConfig.php | 26 ++++++++++++++++++++++++++ metadata.php | 13 +++++++++++++ 4 files changed, 41 insertions(+), 2 deletions(-) diff --git a/Application/views/blocks/_gtm_js.tpl b/Application/views/blocks/_gtm_js.tpl index de0cb3e..8f8856f 100755 --- a/Application/views/blocks/_gtm_js.tpl +++ b/Application/views/blocks/_gtm_js.tpl @@ -13,7 +13,7 @@ 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; + j.src = '[{$oViewConf->getServerSidetaggingJsDomain()}]?id=' + i + dl; f.parentNode.insertBefore(j, f); })(window, document, 'script', 'dataLayer', '[{$oViewConf->getGtmContainerId()}]'); diff --git a/Application/views/blocks/_gtm_nojs.tpl b/Application/views/blocks/_gtm_nojs.tpl index 98a47ad..e15907e 100644 --- a/Application/views/blocks/_gtm_nojs.tpl +++ b/Application/views/blocks/_gtm_nojs.tpl @@ -2,7 +2,7 @@ [{if $oViewConf->getGtmContainerId()}][{strip}] diff --git a/Modules/Core/ViewConfig.php b/Modules/Core/ViewConfig.php index b6c5bb3..d8e6298 100644 --- a/Modules/Core/ViewConfig.php +++ b/Modules/Core/ViewConfig.php @@ -203,4 +203,30 @@ class ViewConfig extends ViewConfig_parent $oConfig = Registry::getConfig(); $aPromotionListIds = $oConfig->getConfigParam("") ?? ['bargainItems', 'newItems', 'topBox', 'alsoBought', 'accessories', 'cross']; } + + /** + * @return string + * @throws ContainerExceptionInterface + * @throws NotFoundExceptionInterface + */ + public function getServerSidetaggingJsDomain() :string + { + return ContainerFactory::getInstance() + ->getContainer() + ->get(ModuleSettingBridgeInterface::class) + ->get('d3_gtm_settings_serversidetagging_js', 'd3googleanalytics4'); + } + + /** + * @return string + * @throws ContainerExceptionInterface + * @throws NotFoundExceptionInterface + */ + public function getServerSidetaggingNoJsDomain() :string + { + return ContainerFactory::getInstance() + ->getContainer() + ->get(ModuleSettingBridgeInterface::class) + ->get('d3_gtm_settings_serversidetagging_nojs', 'd3googleanalytics4'); + } } \ No newline at end of file diff --git a/metadata.php b/metadata.php index 6ffeebd..86c5b6e 100755 --- a/metadata.php +++ b/metadata.php @@ -210,5 +210,18 @@ $aModule = [ 'value' => 'none', 'constraints' => 'NONE|CONSENTMANAGER|USERCENTRICS|COOKIEFIRST|COOKIEBOT', ], + // OST929760 - Erweiterung für Serverside Tagging + [ + 'group' => 'd3_gtm_settings_serversidetagging', + 'name' => 'd3_gtm_settings_serversidetagging_js', + 'type' => 'str', + 'value' => 'https://www.googletagmanager.com/gtm.js', + ], + [ + 'group' => 'd3_gtm_settings_serversidetagging', + 'name' => 'd3_gtm_settings_serversidetagging_nojs', + 'type' => 'str', + 'value' => 'https://www.googletagmanager.com/ns.html', + ], ] ]; \ No newline at end of file