GoogleAnalytics4/Application/views/blocks/_gtm_js.tpl

60 lines
2.8 KiB
Smarty
Raw Normal View History

2023-01-17 14:42:17 +01:00
[{assign var="d3VtConfigObject" value=$oViewConf->getConfig()}]
2023-01-27 08:59:06 +01:00
[{if $d3VtConfigObject->getConfigParam('d3_gtm_settings_hasOwnCookieManager')}]
[{if $oViewConf->D3blAcceptedCookie($d3VtConfigObject->getConfigParam('d3_gtm_settings_cookieName'))}]
2023-01-17 14:42:17 +01:00
[{if $oViewConf->getGtmContainerId()}][{strip}]
<!-- Google Tag Manager -->
<script>
var dataLayer = [{$oViewConf->getGtmDataLayer()}] || [];
(function (w, d, s, l, i) {
2021-07-17 23:22:23 +02:00
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);
2023-01-17 14:42:17 +01:00
})(window, document, 'script', 'dataLayer', '[{$oViewConf->getGtmContainerId()}]');
</script>
<!-- End Google Tag Manager -->
[{if $oViewConf->getTopActionClassName() === "alist" }]
[{* include file="ga4_view_item_list.tpl" gtmCategory=$oView->getActiveCategory() gtmProducts=$oView->getArticleList() listtype=$oView->getListType() *}]
[{elseif $oViewConf->getTopActionClassName() === "details" }]
[{* include file="ga4_view_item.tpl" gtmProduct=$oView->getProduct() *}]
[{elseif $oViewConf->getTopActionClassName() === "search" }]
[{elseif $oViewConf->getTopActionClassName() === "basket" }]
[{/if}]
[{/strip}][{/if}]
[{else}]
<script>
var dataLayer = [{$oViewConf->getGtmDataLayer()}] || [];
</script>
2023-01-17 14:42:17 +01:00
[{/if}]
[{else}]
[{if $oViewConf->getGtmContainerId()}][{strip}]
<!-- Google Tag Manager -->
<script>
var dataLayer = [{$oViewConf->getGtmDataLayer()}] || [];
(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', '[{$oViewConf->getGtmContainerId()}]');
2021-07-17 23:22:23 +02:00
</script>
<!-- End Google Tag Manager -->
[{if $oViewConf->getTopActionClassName() === "alist" }]
2023-01-17 14:42:17 +01:00
[{* include file="ga4_view_item_list.tpl" gtmCategory=$oView->getActiveCategory() gtmProducts=$oView->getArticleList() listtype=$oView->getListType() *}]
2021-07-17 23:22:23 +02:00
[{elseif $oViewConf->getTopActionClassName() === "details" }]
2023-01-17 14:42:17 +01:00
[{* include file="ga4_view_item.tpl" gtmProduct=$oView->getProduct() *}]
2021-07-17 23:22:23 +02:00
[{elseif $oViewConf->getTopActionClassName() === "search" }]
[{elseif $oViewConf->getTopActionClassName() === "basket" }]
[{/if}]
2023-01-17 14:42:17 +01:00
[{/strip}][{/if}]
[{/if}]
2021-07-17 23:22:23 +02:00
[{$smarty.block.parent}]