add cookieManager switch

This commit is contained in:
MaxBUhe 2023-01-17 14:42:17 +01:00
parent 633c1336a8
commit a74b6d9f15
3 changed files with 69 additions and 11 deletions

View File

@ -32,4 +32,17 @@ $aLang = [
'SHOP_MODULE_vt_gtm_sMpapisecret' => 'Map ist Geheim??', 'SHOP_MODULE_vt_gtm_sMpapisecret' => 'Map ist Geheim??',
'SHOP_MODULE_vt_gtm_aPromotionlistIDs' => 'Promotion Produktlisten IDs <div>Weitere Infos zu dieser Einstellung: <b><u><a href="https://github.com/vanilla-thunder/oxid-module-gtm/wiki/Promotion-Produktlisten" target="_blank">Modui-Wiki</a></u></b></div>', 'SHOP_MODULE_vt_gtm_aPromotionlistIDs' => 'Promotion Produktlisten IDs <div>Weitere Infos zu dieser Einstellung: <b><u><a href="https://github.com/vanilla-thunder/oxid-module-gtm/wiki/Promotion-Produktlisten" target="_blank">Modui-Wiki</a></u></b></div>',
'SHOP_MODULE_vt_gtm_blEnableDebug' => 'Debug-Modus aktivieren', 'SHOP_MODULE_vt_gtm_blEnableDebug' => 'Debug-Modus aktivieren',
// for cookie manager settings
'SHOP_MODULE_GROUP_vt_gtm_settings_cookiemanager' => 'Cookie Manager Einstellungen',
'SHOP_MODULE_vt_gtm_settings_hasOwnCookieManager' => 'Eigenen Cookie Manager nutzen?
<strong style="color: red">Hinweis (Fragezeichen) lesen!</strong>',
'HELP_SHOP_MODULE_vt_gtm_settings_hasOwnCookieManager' => 'Stellen Sie sicher, dass Sie ein Modul installiert haben,
dass die Methode "blAcceptedCookie" implementiert.<br> Sollten Sie sich nicht sicher sein, kontaktieren Sie Ihren
technischen Ansprechpartner.<br><br>
Diese Möglichkeit zu aktivieren, <u>ohne dem nötigen technischen Wissen</u> kann den Shop-Ablauf (Frontend) stören.<hr>
Diese Möglichkeit kann vernachlässigt werden, sofern die Cookies beispielsweise direkt via Google handhabt werden.
Bei Fragen <u>kontaktieren Sie bitte</u> auch hier einen entsprechenden technischen Ansprechpartner.',
'SHOP_MODULE_vt_gtm_settings_cookieName' => 'Cookie-Name',
]; ];

View File

@ -1,25 +1,57 @@
[{if $oViewConf->getGtmContainerId()}][{strip}] [{assign var="d3VtConfigObject" value=$oViewConf->getConfig()}]
<!-- Google Tag Manager --> [{if $d3VtConfigObject->getConfigParam('vt_gtm_settings_hasOwnCookieManager')}]
<script> [{if $oViewConf->blAcceptedCookie($d3VtConfigObject->getConfigParam('vt_gtm_settings_cookieName'))}]
var dataLayer = [{$oViewConf->getGtmDataLayer()}] || [];
(function (w, d, s, l, i) { [{if $oViewConf->getGtmContainerId()}][{strip}]
<!-- Google Tag Manager -->
<script>
var dataLayer = [{$oViewConf->getGtmDataLayer()}] || [];
(function (w, d, s, l, i) {
w[l] = w[l] || []; w[l] = w[l] || [];
w[l].push({'gtm.start': new Date().getTime(), event: 'gtm.js'}); 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 : ''; var f = d.getElementsByTagName(s)[0], j = d.createElement(s), dl = l != 'dataLayer' ? '&l=' + l : '';
j.async = true; j.async = true;
j.src = 'https://www.googletagmanager.com/gtm.js?id=' + i + dl; j.src = 'https://www.googletagmanager.com/gtm.js?id=' + i + dl;
f.parentNode.insertBefore(j, f); f.parentNode.insertBefore(j, f);
})(window, document, 'script', 'dataLayer', '[{$oViewConf->getGtmContainerId()}]'); })(window, document, 'script', 'dataLayer', '[{$oViewConf->getGtmContainerId()}]');
</script>
<!-- End Google Tag Manager -->
[{$oViewConf->triggerGA4events()}]
[{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}]
[{/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()}]');
</script> </script>
<!-- End Google Tag Manager --> <!-- End Google Tag Manager -->
[{$oViewConf->triggerGA4events()}] [{$oViewConf->triggerGA4events()}]
[{if $oViewConf->getTopActionClassName() === "alist" }] [{if $oViewConf->getTopActionClassName() === "alist" }]
[{* include file="ga4_view_item_list.tpl" gtmCategory=$oView->getActiveCategory() gtmProducts=$oView->getArticleList() listtype=$oView->getListType() *}] [{* include file="ga4_view_item_list.tpl" gtmCategory=$oView->getActiveCategory() gtmProducts=$oView->getArticleList() listtype=$oView->getListType() *}]
[{elseif $oViewConf->getTopActionClassName() === "details" }] [{elseif $oViewConf->getTopActionClassName() === "details" }]
[{* include file="ga4_view_item.tpl" gtmProduct=$oView->getProduct() *}] [{* include file="ga4_view_item.tpl" gtmProduct=$oView->getProduct() *}]
[{elseif $oViewConf->getTopActionClassName() === "search" }] [{elseif $oViewConf->getTopActionClassName() === "search" }]
[{elseif $oViewConf->getTopActionClassName() === "basket" }] [{elseif $oViewConf->getTopActionClassName() === "basket" }]
[{/if}] [{/if}]
[{/strip}][{/if}] [{/strip}][{/if}]
[{/if}]
[{$smarty.block.parent}] [{$smarty.block.parent}]

View File

@ -182,7 +182,20 @@ $aModule = [
'type' => 'bool', 'type' => 'bool',
'value' => false, 'value' => false,
'position' => 999 'position' => 999
] ],
[
'group' => 'vt_gtm_settings_cookiemanager',
'name' => 'vt_gtm_settings_hasOwnCookieManager',
'type' => 'bool',
'value' => false,
'position' => 999
],
[
'group' => 'vt_gtm_settings_cookiemanager',
'name' => 'vt_gtm_settings_cookieName',
'type' => 'str',
'value' => 'example',
'position' => 999
],
] ]
]; ];