Compare commits

..

64 Commits

Author SHA1 Message Date
106fea9c91 fix explicit manager bug
bug would make script apply anyway, even if no manager is found
2023-05-31 14:29:46 +02:00
13132e6da0 Merge branch 'rel_2_prep_porting_rel_1.x' of git.d3data.de:D3Public/GoogleAnalytics4 into rel_2_prep_porting_rel_1.x 2023-05-31 13:42:54 +02:00
5c478124bc bump version && changelog to 2.6.0 2023-05-31 13:40:51 +02:00
12613357b3 bump version && changelog to 2.6.0 2023-05-31 13:38:32 +02:00
95e0cab68c rework 'Manager Type Handling'; add ManagerHandler + ManagerTypes 2023-05-31 12:17:00 +02:00
1d194d445a rm unnecessary check 2023-05-31 12:16:10 +02:00
bf3fee5ce5 add missing article-getter 2023-05-31 10:35:18 +02:00
3c280a3adb adjust readme and switch used block-extension 2023-05-31 10:34:34 +02:00
6217524828 adjusted usercentrics script 2023-05-31 10:34:24 +02:00
5ef600ff2a added position to block-extension 2023-05-31 10:34:14 +02:00
a40d922f42 [working-state] restructuring usercentricts & consentmanager decision
consentmanager decision is working so far; next step is implementing usercentricts
2023-05-31 10:33:59 +02:00
dae5f66f81 add usercentrics chosable settings-value; add additional methods; add new multilang-idents 2023-05-31 10:33:43 +02:00
347e551194 merge rel_1.x changelog 2023-05-23 11:49:09 +02:00
000c49c56b bump version && changelog to 2.5.0 2023-05-23 11:32:20 +02:00
002cc69d2a switch metadata entries; fix getPrice-bug 2023-05-23 10:06:21 +02:00
af78809ae5 add settings-entry; add consentmanager-option 2023-05-15 15:06:25 +02:00
d531ba648b fix unnecessary convert of int to str 2023-05-12 14:08:52 +02:00
a0c650fca3 Merge branch 'rel_2.x' 2023-05-11 15:26:45 +02:00
af341a984b Merge branch 'rel_1.x'
# Conflicts:
#	CHANGELOG.md
#	metadata.php
2023-05-11 15:26:31 +02:00
122dd4cf53 genuine code cleanup; switch hard-getter to methods and use price-object 2023-05-10 15:01:56 +02:00
27798703b0 bump version && changelog to 2.4.0 2023-05-02 14:36:52 +02:00
8eb734be8a OXID UserCentrics support, general overhaul for cookie managers 2023-05-02 14:28:47 +02:00
616f31ecba Merge remote-tracking branch 'remotes/origin/rel_2.x' 2023-03-20 15:46:58 +01:00
527eec1355 bump changelog 2023-03-20 11:01:03 +01:00
1966d3008e Merge remote-tracking branch 'remotes/origin/rel_2.x_custB' into rel_2.x 2023-03-20 10:56:29 +01:00
bd51b37159 hot-fix: add missing view_item file; add metadata entry 2023-03-20 09:49:49 +01:00
718b60e12c Merge remote-tracking branch 'remotes/origin/rel_2.x' 2023-03-17 15:31:34 +01:00
d4df87bfff Merge remote-tracking branch 'remotes/origin/rel_1.x' into rel_2.x 2023-03-17 15:30:03 +01:00
63007e9b02 bump version 2023-03-10 11:25:12 +01:00
5fe656988c genuine cleaning off of unnecessary files (prevent confusion) 2023-03-10 11:22:49 +01:00
9cb3a54824 Merge remote-tracking branch 'remotes/origin/rel_2.x' 2023-02-22 14:35:22 +01:00
2f6fd8a31c bump version 2023-02-22 14:31:28 +01:00
8f9ed021d6 bump version 2023-02-22 14:07:14 +01:00
0ef3d3373a Merge remote-tracking branch 'remotes/origin/dev/view_cart/illegal_character_U+20AC' into rel_2.x 2023-02-22 14:05:56 +01:00
fd2b4a5bbe add special price formatting 2023-02-22 13:46:27 +01:00
1c0d55bdc3 Merge remote-tracking branch 'remotes/origin/rel_2.x' 2023-02-21 12:47:38 +01:00
7c1f99e678 Merge remote-tracking branch 'remotes/origin/rel_2.x' 2023-02-21 12:47:02 +01:00
126e746651 missing changelog-entry 2023-02-21 12:46:34 +01:00
1c45a16356 bump version 2023-02-21 12:27:52 +01:00
1589f202a9 add own cookie-check method; rm unnecessary help-text 2023-02-21 12:09:04 +01:00
55bd7b7fb4 adjust module_options meta-docs 2023-02-01 14:27:49 +01:00
3c1e6a11ff bump version 2023-01-27 13:47:13 +01:00
9ac78a0d43 OST:#573111 fix bug - missing use 2023-01-27 13:43:29 +01:00
e2bcb34051 bump version 2023-01-27 11:11:09 +01:00
4ea0c19d7b Merge remote-tracking branch 'remotes/origin/rel_1.x' into rel_2.x 2023-01-27 11:04:23 +01:00
56740f1f10 rm unnecessary method call in gtm_js.tpl 2023-01-27 09:19:05 +01:00
daed30a585 rm unnecessary entries in metadata 2023-01-27 09:07:22 +01:00
48d411ac3f switch head-meta-infos 2023-01-27 09:07:09 +01:00
b530366cb8 rm unnecessary lang file 2023-01-27 09:06:49 +01:00
975d07056a cleaning off branding 2023-01-27 08:59:06 +01:00
24bf113d30 switch comment in changelog of 2.0 2023-01-26 09:20:56 +01:00
ca6a810fa3 add 1.0 section to changelog 2023-01-26 09:16:51 +01:00
62b382eadf adding tech-docs; rm unnecessary sections in readme; fixing wrong links 2023-01-26 09:15:10 +01:00
45d8e45137 fix missing entries in changelog 2023-01-25 10:58:24 +01:00
70f2308575 extend changelog and readme 2023-01-25 10:48:02 +01:00
6eb15ec080 add block description 2023-01-20 14:31:39 +01:00
d722c46a74 bump metadata-version 2023-01-20 11:26:09 +01:00
d847a34e99 set compatibility to oxid 6.5 and above 2023-01-20 11:24:30 +01:00
7b55d1d57c adjust requirements 2023-01-20 11:18:48 +01:00
a25be1069c rework code to actually fit 6.0.x && 6.1x 2023-01-20 11:18:17 +01:00
5200232a32 Merge remote-tracking branch 'remotes/origin/rel_1.x' into dev_1.x_OXID_6.3 2023-01-20 11:11:17 +01:00
bcd785774b adjusting composer.json to fit corresponding shop-version 2022-12-22 08:56:45 +01:00
5ba613df30 add currency to the params 2022-12-21 11:12:35 +01:00
a1dc0a6a58 fix bug that'd fail in wave and fail iIndex 2022-12-09 14:51:45 +01:00
25 changed files with 370 additions and 748 deletions

1
.gitignore vendored
View File

@ -1 +0,0 @@
.idea

View File

@ -34,8 +34,6 @@ class ManagerTypes
const CONSENTMANAGER = "CONSENTMANAGER"; const CONSENTMANAGER = "CONSENTMANAGER";
const COOKIEFIRST = "COOKIEFIRST";
/** /**
* @return array * @return array
*/ */
@ -47,8 +45,7 @@ class ManagerTypes
"net_cookie_manager" => self::NET_COOKIE_MANAGER, "net_cookie_manager" => self::NET_COOKIE_MANAGER,
"oxps_usercentrics" => self::USERCENTRICS_MODULE, "oxps_usercentrics" => self::USERCENTRICS_MODULE,
"usercentrics" => self::USERCENTRICS_MANUALLY, "usercentrics" => self::USERCENTRICS_MANUALLY,
"consentmanager" => self::CONSENTMANAGER, "consentmanager" => self::CONSENTMANAGER
"cookiefirst" => self::COOKIEFIRST
]; ];
} }

View File

@ -31,17 +31,10 @@ $aLang = [
// for cookie manager settings // for cookie manager settings
'SHOP_MODULE_GROUP_d3_gtm_settings_cookiemanager' => 'Cookie Manager Einstellungen', 'SHOP_MODULE_GROUP_d3_gtm_settings_cookiemanager' => 'Cookie Manager Einstellungen',
'SHOP_MODULE_d3_gtm_settings_hasOwnCookieManager' => 'Cookie Manager nutzen?', 'SHOP_MODULE_d3_gtm_settings_hasOwnCookieManager' => 'Cookie Manager nutzen?',
'HELP_SHOP_MODULE_d3_gtm_settings_HAS_STD_MANAGER' => 'Mehr Informationen zu den genannten Coookie-Manager finden Sie auf den folgenden Home-Pages<br><br>
<a href="https://consentmanager.net/">Consentmanager</a><br>
<a href="https://usercentrics.com/">Usercentrics</a><br>
<a href="https://cookiefirst.com">Cookiefirst</a><br>
<hr>
Bei weiteren Fragen stehen wir gern zur VerfĂĽgung! Kontaktieren Sie uns einfach unter <a href="https://www.d3data.de/">https://www.d3data.de/</a>',
'SHOP_MODULE_d3_gtm_settings_HAS_STD_MANAGER' => 'Nutzen Sie eine der folgenden Einbindungen?<br> 'SHOP_MODULE_d3_gtm_settings_HAS_STD_MANAGER' => 'Nutzen Sie eine der folgenden Einbindungen?<br>
Dann wählen Sie bitte die zutreffende aus.', Dann wählen Sie bitte die zutreffende aus.',
'SHOP_MODULE_d3_gtm_settings_HAS_STD_MANAGER_NONE' => '---', 'SHOP_MODULE_d3_gtm_settings_HAS_STD_MANAGER_NONE' => '---',
'SHOP_MODULE_d3_gtm_settings_HAS_STD_MANAGER_CONSENTMANAGER' => 'consentmanager', 'SHOP_MODULE_d3_gtm_settings_HAS_STD_MANAGER_CONSENTMANAGER' => 'consentmanager',
'SHOP_MODULE_d3_gtm_settings_HAS_STD_MANAGER_USERCENTRICS' => 'usercentrics', 'SHOP_MODULE_d3_gtm_settings_HAS_STD_MANAGER_USERCENTRICS' => 'usercentrics',
'SHOP_MODULE_d3_gtm_settings_HAS_STD_MANAGER_COOKIEFIRST' => 'cookiefirst',
'SHOP_MODULE_d3_gtm_settings_cookieName' => 'CookieID', 'SHOP_MODULE_d3_gtm_settings_cookieName' => 'CookieID',
]; ];

View File

@ -4,22 +4,28 @@
</script> </script>
[{if $oViewConf->D3blShowGtmScript()}] [{if $oViewConf->D3blShowGtmScript()}]
[{if $oViewConf->getGtmContainerId()}] [{if $oViewConf->getGtmContainerId()}][{strip}]
[{strip}] <!-- Google Tag Manager -->
<!-- Google Tag Manager --> <script [{$oViewConf->getGtmScriptAttributes()}]>
<script [{$oViewConf->getGtmScriptAttributes()}]> (function (w, d, s, l, i) {
(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>
</script> <!-- End Google Tag Manager -->
<!-- End Google Tag Manager -->
[{/strip}] [{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}] [{/if}]
[{/if}]
[{$smarty.block.parent}] [{$smarty.block.parent}]

View File

@ -0,0 +1,33 @@
[{$smarty.block.parent}]
[{*$oxcmp_basket|get_class_methods|dumpvar*}]
[{assign var="d3BasketPrice" value=$oxcmp_basket->getPrice()}]
[{assign var='gtmCartArticles' value=$oView->getBasketArticles()}]
[{strip}][{capture assign=d3_ga4_view_cart}]
dataLayer.push({"event": null, "eventLabel": null, "ecommerce": null}); /* Clear the previous ecommerce object. */
dataLayer.push({
'event': 'view_cart',
'eventLabel':'Checkout Step 1',
'ecommerce': {
'actionField': "step: 1",
'currency': "[{$currency->name}]",
'value': [{$d3BasketPrice->getPrice()}],
'items': [
[{foreach from=$oxcmp_basket->getContents() item=basketitem name=gtmCartContents key=basketindex}]
[{assign var="d3oItemPrice" value=$basketitem->getPrice()}]
{
'item_id': '[{$gtmCartArticles[$basketindex]->getFieldData('oxartnum')}]',
'item_name': '[{$gtmCartArticles[$basketindex]->getFieldData('oxtitle')}]',
'item_variant': '[{$gtmCartArticles[$basketindex]->getFieldData('oxvarselect')}]',
'price': [{$d3oItemPrice->getPrice()}],
'quantity':[{$basketitem->getAmount()}],
'position':[{$smarty.foreach.gtmCartContents.index}]
}[{if !$smarty.foreach.gtmCartContents.last}],[{/if}]
[{/foreach}]
]
}
});
[{/capture}][{/strip}]
[{oxscript add=$d3_ga4_view_cart}]

View File

@ -0,0 +1,36 @@
[{$smarty.block.parent}]
[{strip}]
<script>
dataLayer.push({"event": null, "eventLabel": null, "ecommerce": null}); /* Clear the previous ecommerce object. */
[{assign var="_gtmOrder" value=$oView->getOrder()}]
[{assign var="_gtmArticles" value=$_gtmOrder->getOrderArticles()}]
dataLayer.push({
'event': 'purchase',
'eventLabel':'Checkout Step 5',
'ecommerce': {
'transaction_id': '[{$_gtmOrder->getFieldData("oxordernr")}]',
'affiliation': '[{$oxcmp_shop->getFieldData("oxname")}]',
'value': [{$_gtmOrder->getTotalOrderSum()}],
'tax': [{math equation="x+y" x=$_gtmOrder->getFieldData("oxartvatprice1") y=$_gtmOrder->getFieldData("oxartvatprice2") }],
'shipping': [{$_gtmOrder->getFieldData("oxdelcost")}],
'currency': '[{$_gtmOrder->getFieldData('oxcurrency')}]',
'items':
[
[{foreach from=$_gtmArticles item="d3BasketArticle" name="gtmArticles"}]
[{assign var="d3oArticlePrice" value=$d3BasketArticle->getPrice()}]
{
'id': '[{$d3BasketArticle->getFieldData("oxartnum")}]',
'name': '[{$d3BasketArticle->getFieldData("oxtitle")}]',
'variant': '[{$d3BasketArticle->getFieldData("oxselvariant")}]',
'price': [{$d3oArticlePrice->getPrice()}],
'quantity': [{$d3BasketArticle->getFieldData("oxamount")}],
'position': [{$smarty.foreach.gtmArticles.iteration}]
}[{if !$smarty.foreach.gtmArticles.last}],[{/if}]
[{/foreach}]
]
}
})
</script>
[{/strip}]

View File

@ -1,56 +0,0 @@
[{$smarty.block.parent}]
[{block name="d3_ga4_purchase_block"}]
[{capture assign=d3_ga4_purchase}]
[{strip}]
dataLayer.push({"event": null, "eventLabel": null, "ecommerce": null}); /* Clear the previous ecommerce object. */
[{assign var="gtmOrder" value=$oView->getOrder()}]
[{assign var="gtmBasket" value=$oView->getBasket()}]
[{assign var="gtmArticles" value=$gtmOrder->getOrderArticles()}]
[{assign var="gtmOrderVouchers" value=$gtmOrder->getVoucherNrList()}]
dataLayer.push({
'event': 'purchase',
'eventLabel':'Checkout Step 5',
'ecommerce': {
'transaction_id': '[{$gtmOrder->getFieldData("oxordernr")}]',
'affiliation': '[{$oxcmp_shop->getFieldData("oxname")}]',
'value': [{$gtmOrder->getTotalOrderSum()}],
'tax': [{math equation="x+y" x=$gtmOrder->getFieldData("oxartvatprice1") y=$gtmOrder->getFieldData("oxartvatprice2") }],
'shipping': [{$gtmOrder->getFieldData("oxdelcost")}],
'currency': '[{$gtmOrder->getFieldData('oxcurrency')}]',
'coupon': '[{foreach from=$gtmOrderVouchers item="gtmOrderVoucher" name="gtmOrderVoucherIteration"}][{$gtmOrderVoucher}][{if !$smarty.foreach.gtmOrderVoucherIteration.last}], [{/if}][{/foreach}]',
'paymentType': '[{$gtmBasket->getPaymentOnPaymentId()}]',
'items': [
[{foreach from=$gtmArticles item="gtmBasketItem" name="gtmArticles"}]
[{assign var="gtmPurchaseItemPriceObject" value=$gtmBasketItem->getPrice()}]
[{assign var="gtmPurchaseItem" value=$gtmBasketItem->getArticle()}]
[{assign var="gtmPurchaseItemCategory" value=$gtmPurchaseItem->getCategory()}]
{
'item_id': '[{$gtmBasketItem->getFieldData("oxartnum")}]',
'item_name': '[{$gtmBasketItem->getFieldData("oxtitle")}]',
'affiliation': '[{$gtmBasketItem->getFieldData("oxtitle")}]',
'coupon': '[{foreach from=$gtmOrderVouchers item="gtmOrderVoucher" name="gtmOrderVoucherIteration"}][{$gtmOrderVoucher}][{if !$smarty.foreach.gtmOrderVoucherIteration.last}], [{/if}][{/foreach}]',
'item_variant': '[{$gtmBasketItem->getFieldData("oxselvariant")}]',
[{if $gtmPurchaseItemCategory}]
'item_category': '[{$gtmPurchaseItemCategory->getSplitCategoryArray(0)}]',
'item_category_2': '[{$gtmPurchaseItemCategory->getSplitCategoryArray(1)}]',
'item_category_3': '[{$gtmPurchaseItemCategory->getSplitCategoryArray(2)}]',
'item_category_4': '[{$gtmPurchaseItemCategory->getSplitCategoryArray(3)}]',
'item_list_name': '[{$gtmPurchaseItemCategory->getSplitCategoryArray()}]',
[{/if}]
'price': [{$gtmPurchaseItemPriceObject->getPrice()}],
'quantity': [{$gtmBasketItem->getFieldData("oxamount")}],
'position': [{$smarty.foreach.gtmArticles.iteration}]
}[{if !$smarty.foreach.gtmArticles.last}],[{/if}]
[{/foreach}]
]
}[{if $oViewConf->isDebugModeOn()}],
'debug_mode': 'true'
[{/if}]
})
[{/strip}]
[{/capture}]
[{oxscript add=$d3_ga4_purchase}]
[{/block}]

View File

@ -1,50 +0,0 @@
[{$smarty.block.parent}]
[{*$oxcmp_basket|get_class_methods|dumpvar*}]
[{assign var="d3BasketPrice" value=$oxcmp_basket->getPrice()}]
[{assign var='gtmCartArticles' value=$oView->getBasketArticles()}]
[{block name="d3_ga4_view_cart_block"}]
[{capture assign=d3_ga4_view_cart}]
[{strip}]
dataLayer.push({"event": null, "eventLabel": null, "ecommerce": null}); /* Clear the previous ecommerce object. */
dataLayer.push({
'event': 'view_cart',
'eventLabel':'Checkout Step 1',
'ecommerce': {
'actionField': "step: 1",
'currency': "[{$currency->name}]",
'value': [{$d3BasketPrice->getPrice()}],
'coupon': '[{foreach from=$oxcmp_basket->getVouchers() item=sVoucher key=key name=Voucher}][{$sVoucher->sVoucherNr}][{if !$smarty.foreach.Voucher.last}], [{/if}][{/foreach}]',
'items': [
[{foreach from=$oxcmp_basket->getContents() item=basketitem name=gtmCartContents key=basketindex}]
[{assign var="d3oItemPrice" value=$basketitem->getPrice()}]
[{assign var="gtmBasketItem" value=$basketitem->getArticle()}]
[{assign var="gtmBasketItemCategory" value=$gtmBasketItem->getCategory()}]
{
'item_id': '[{$gtmCartArticles[$basketindex]->getFieldData('oxartnum')}]',
'item_name': '[{$gtmCartArticles[$basketindex]->getFieldData('oxtitle')}]',
'item_variant': '[{$gtmCartArticles[$basketindex]->getFieldData('oxvarselect')}]',
[{if $gtmBasketItemCategory}]
'item_category': '[{$gtmBasketItemCategory->getSplitCategoryArray(0)}]',
'item_category_2': '[{$gtmBasketItemCategory->getSplitCategoryArray(1)}]',
'item_category_3': '[{$gtmBasketItemCategory->getSplitCategoryArray(2)}]',
'item_category_4': '[{$gtmBasketItemCategory->getSplitCategoryArray(3)}]',
'item_list_name': '[{$gtmBasketItemCategory->getSplitCategoryArray()}]',
[{/if}]
'price': [{$d3oItemPrice->getPrice()}],
'coupon': '[{foreach from=$oxcmp_basket->getVouchers() item=sVoucher key=key name=Voucher}][{$sVoucher->sVoucherNr}][{if !$smarty.foreach.Voucher.last}], [{/if}][{/foreach}]',
'quantity': [{$basketitem->getAmount()}],
'position': [{$smarty.foreach.gtmCartContents.index}]
}[{if !$smarty.foreach.gtmCartContents.last}],[{/if}]
[{/foreach}]
]
}[{if $oViewConf->isDebugModeOn()}],
'debug_mode': 'true'
[{/if}]
});
[{/strip}]
[{/capture}]
[{oxscript add=$d3_ga4_view_cart}]
[{/block}]

View File

@ -3,38 +3,24 @@
[{assign var="gtmCategory" value=$gtmProduct->getCategory()}] [{assign var="gtmCategory" value=$gtmProduct->getCategory()}]
[{assign var="gtmManufacturer" value=$gtmProduct->getManufacturer()}] [{assign var="gtmManufacturer" value=$gtmProduct->getManufacturer()}]
[{block name="d3_ga4_view_item_block"}] <script>
[{capture assign=d3_ga4_view_item}] dataLayer.push({"event": null, "eventLabel": null, "ecommerce": null}); /* Clear the previous ecommerce object. */
[{strip}] dataLayer.push({
dataLayer.push({"event": null, "eventLabel": null, "ecommerce": null}); /* Clear the previous ecommerce object. */ 'event': 'view_item',
'eventLabel':'Product View',
dataLayer.push({ 'ecommerce': {
'event': 'view_item', 'currency': '[{$currency->name}]',
'eventLabel':'Product View', 'items': [
'ecommerce': { {
'currency': '[{$currency->name}]', 'item_name': '[{$gtmProduct->getFieldData("oxtitle")}]',
'items': [ 'item_id': '[{$gtmProduct->getFieldData("oxartnum")}]',
{ 'item_brand': '[{if $gtmManufacturer}][{$gtmManufacturer->oxmanufacturers__oxtitle->value}][{/if}]',
'item_name': '[{$gtmProduct->getFieldData("oxtitle")}]', 'item_category': '[{if $gtmCategory}][{$gtmCategory->getLink()|parse_url:5|ltrim:"/"|rtrim:"/"}][{else}]-[{/if}]',
'item_id': '[{$gtmProduct->getFieldData("oxartnum")}]', 'item_variant': '[{if $gtmProduct->getFieldData("oxvarselect")}][{$gtmProduct->getFieldData("oxvarselect")}][{/if}]',
'item_brand': '[{if $gtmManufacturer}][{$gtmManufacturer->oxmanufacturers__oxtitle->value}][{/if}]', [{assign var="d3PriceObject" value=$gtmProduct->getPrice()}]
'item_variant': '[{if $gtmProduct->getFieldData("oxvarselect")}][{$gtmProduct->getFieldData("oxvarselect")}][{/if}]', 'price': [{$d3PriceObject->getPrice()}]
[{if $gtmCategory}] }
'item_category': '[{$gtmCategory->getSplitCategoryArray(0)}]', ]
'item_category_2':'[{$gtmCategory->getSplitCategoryArray(1)}]', }
'item_category_3':'[{$gtmCategory->getSplitCategoryArray(2)}]', });
'item_category_4':'[{$gtmCategory->getSplitCategoryArray(3)}]', </script>
'item_list_name':'[{$gtmCategory->getSplitCategoryArray()}]',
[{/if}]
[{assign var="d3PriceObject" value=$gtmProduct->getPrice()}]
'price': [{$d3PriceObject->getPrice()}]
}
]
}[{if $oViewConf->isDebugModeOn()}],
'debug_mode': 'true'
[{/if}]
});
[{/strip}]
[{/capture}]
[{oxscript add=$d3_ga4_view_item}]
[{/block}]

View File

@ -1,52 +1,56 @@
[{$smarty.block.parent}] [{$smarty.block.parent}]
[{* variable $gtmProduct is passed from parent tempalte *}] [{assign var="d3ProductObject" value=$oView->getProduct()}]
[{assign var="d3PriceObject" value=$gtmProduct->getPrice()}] [{assign var="d3PriceObject" value=$d3ProductObject->getPrice()}]
[{assign var="gtmCurrency" value=$oView->getActCurrency()}]
[{assign var="gtmManufacturer" value=$gtmProduct->getManufacturer()}]
[{assign var="gtmCategory" value=$gtmProduct->getCategory()}]
[{block name="d3_ga4_add_to_cart_block"}] [{capture assign=d3_ga4_add_to_cart}]
[{capture assign=d3_ga4_add_to_cart}] [{block name="d3_ga4_add_to_basket"}]
[{strip}] $("#toBasket").click(function(event) {
$("#toBasket").click(function(event) {
dataLayer.push({"event": null, "eventLabel": null, "ecommerce": null}); /* Clear the previous ecommerce object. */
[{*** Debug cases ***}] [{*** Debug cases ***}]
[{*event.preventDefault();*}] [{*event.preventDefault();*}]
let iArtQuantity = $("#amountToBasket").val(); let iArtQuantity = $("#amountToBasket").val();
dataLayer.push({ dataLayer.push({
'isAddToBasket': true, 'isAddToBasket': true,
'event':'add_to_cart', 'event':'add_to_cart',
'eventLabel': 'add_to_cart', 'eventLabel': 'add_to_cart',
'ecommerce': { 'ecommerce': {
'currency': "[{$currency->name}]", 'currency': "[{$currency->name}]",
'value': iArtQuantity*[{$d3PriceObject->getPrice()}], 'value': iArtQuantity*[{$d3PriceObject->getPrice()}],
'items': [ 'items': [
{ {
'item_id': '[{$gtmProduct->getFieldData('oxartnum')}]', 'item_id': '[{$gtmProduct->getFieldData('oxartnum')}]',
'item_name': '[{$gtmProduct->getFieldData('oxtitle')}]', 'item_name': '[{$gtmProduct->getFieldData('oxtitle')}]',
'price': [{$d3PriceObject->getPrice()}], 'price': [{$d3PriceObject->getPrice()}],
'item_brand': '[{if $gtmManufacturer}][{$gtmManufacturer->oxmanufacturers__oxtitle->value}][{/if}]', 'item_brand': '[{if $gtmManufacturer}][{$gtmManufacturer->oxmanufacturers__oxtitle->value}][{/if}]',
'item_variant': '[{if $gtmProduct->getFieldData('oxvarselect')}][{$gtmProduct->getFieldData('oxvarselect')}][{/if}]', 'item_variant': '[{if $gtmProduct->getFieldData('oxvarselect')}][{$gtmProduct->getFieldData('oxvarselect')}][{/if}]',
[{if $gtmCategory}] 'item_category': itemCategories[0] || 'no category',
'item_category': '[{$gtmCategory->getSplitCategoryArray(0)}]', 'item_category_2':itemCategories[1] || '',
'item_category_2':'[{$gtmCategory->getSplitCategoryArray(1)}]', 'item_category_3':itemCategories[2] || '',
'item_category_3':'[{$gtmCategory->getSplitCategoryArray(2)}]', 'item_category_4':itemCategories[3] || '',
'item_category_4':'[{$gtmCategory->getSplitCategoryArray(3)}]', 'quantity': iArtQuantity
'item_list_name':'[{$gtmCategory->getSplitCategoryArray()}]', }
[{/if}] ]
'quantity': iArtQuantity }
} });
] });
}[{if $oViewConf->isDebugModeOn()}], [{/block}]
'debug_mode': 'true' [{/capture}]
[{/if}] [{oxscript add=$d3_ga4_add_to_cart}]
});
}); [{strip}]
[{/strip}] [{* variable $gtmProduct is passed from parent tempalte *}]
[{/capture}]
[{oxscript add=$d3_ga4_add_to_cart}] [{assign var="gtmCurrency" value=$oView->getActCurrency()}]
[{/block}] [{assign var="gtmManufacturer" value=$gtmProduct->getManufacturer()}]
[{assign var="gtmCategory" value=$gtmProduct->getCategory()}]
<script>
dataLayer.push({"event": null, "eventLabel": null, "ecommerce": null}); /* Clear the previous ecommerce object. */
let itemCategories = '[{if $gtmCategory}][{$gtmCategory->getLink()|parse_url:5|ltrim:"/"|rtrim:"/"}][{else}]no category[{/if}]'.split('/');
</script>
[{/strip}]

View File

@ -1,48 +0,0 @@
[{$smarty.block.parent}]
[{block name="d3_ga4_remove_from_cart_block"}]
[{if $hasBeenReloaded}]
[{assign var="d3BasketPrice" value=$oxcmp_basket->getPrice()}]
[{capture assign=d3_ga4_remove_from_cart}]
[{strip}]
dataLayer.push({"event": null, "eventLabel": null, "ecommerce": null}); /* Clear the previous ecommerce object. */
dataLayer.push({
'isRemoveFromCart': true,
'event': 'remove_from_cart',
'eventLabel':'remove_from_cart',
'ecommerce': {
'actionField': "step: 1",
'currency': "[{$currency->name}]",
'value': [{$d3BasketPrice->getPrice()}],
'coupon': '[{foreach from=$oxcmp_basket->getVouchers() item=sVoucher key=key name=Voucher}][{$sVoucher->sVoucherNr}][{if !$smarty.foreach.Voucher.last}], [{/if}][{/foreach}]',
'items': [
[{foreach from=$toRemoveArticles->getArray() name=gtmRemovedItems item=rmItem key=rmItemindex}]
[{assign var="d3oItemPrice" value=$rmItem->getPrice()}]
[{assign var="gtmBasketItemCategory" value=$rmItem->getCategory()}]
{
'item_id': '[{$rmItem->getFieldData('oxartnum')}]',
'item_name': '[{$rmItem->getFieldData('oxtitle')}]',
'item_variant': '[{$rmItem->getFieldData('oxvarselect')}]',
[{if $gtmBasketItemCategory}]
'item_category': '[{$gtmBasketItemCategory->getSplitCategoryArray(0)}]',
'item_category_2': '[{$gtmBasketItemCategory->getSplitCategoryArray(1)}]',
'item_category_3': '[{$gtmBasketItemCategory->getSplitCategoryArray(2)}]',
'item_category_4': '[{$gtmBasketItemCategory->getSplitCategoryArray(3)}]',
'item_list_name': '[{$gtmBasketItemCategory->getSplitCategoryArray()}]',
[{/if}]
'price': [{$d3oItemPrice->getPrice()}],
'coupon': '[{foreach from=$oxcmp_basket->getVouchers() item=sVoucher key=key name=Voucher}][{$sVoucher->sVoucherNr}][{if !$smarty.foreach.Voucher.last}], [{/if}][{/foreach}]',
'quantity': '[{$rmItem->getFieldData('d3AmountThatGotRemoved')}]',
'position': [{$smarty.foreach.gtmRemovedItems.index}]
}[{if !$smarty.foreach.gtmRemovedItems.last}],[{/if}]
[{/foreach}]
]
}[{if $oViewConf->isDebugModeOn()}],
'debug_mode': 'true'
[{/if}]
});
[{/strip}]
[{/capture}]
[{oxscript add=$d3_ga4_remove_from_cart}]
[{/if}]
[{/block}]

View File

@ -0,0 +1,33 @@
[{$smarty.block.parent}]
[{assign var="gtmProducts" value=$oView->getArticleList()}]
[{if $gtmProducts|@count}]
[{strip}]
<script>
dataLayer.push({"event": null, "eventLabel": null, "ecommerce": null}); /* Clear the previous ecommerce object. */
dataLayer.push({
'event': 'view_search_result',
'eventLabel':'view_search_result',
'ecommerce': {
'search_term': '[{$searchparamforhtml}]',
'items': [
[{foreach from=$gtmProducts name="gtmProducts" item="gtmProduct"}]
[{assign var="d3PriceObject" value=$gtmProduct->getPrice()}]
[{assign var="gtmManufacturer" value=$gtmProduct->getManufacturer()}]
[{if !$gtmCategory}][{assign var="gtmCategory" value=$gtmProduct->getCategory()}][{/if}]
{
'item_id': '[{$gtmProduct->getFieldData("oxartnum")}]',
'item_name': '[{$gtmProduct->getFieldData("oxtitle")}]',
'price': [{$d3PriceObject->getPrice()}],
'item_brand': '[{if $gtmManufacturer}][{$gtmManufacturer->oxmanufacturers__oxtitle->value}][{/if}]',
'item_category': '[{if $gtmCategory}][{$gtmCategory->getLink()|parse_url:5|ltrim:"/"|rtrim:"/"}][{else}]-[{/if}]',
'quantity': 1
}[{if !$smarty.foreach.gtmProducts.last}],[{/if}]
[{/foreach}]
]
}
});
</script>
[{/strip}]
[{/if}]

View File

@ -1,46 +1,36 @@
[{$smarty.block.parent}] [{$smarty.block.parent}]
[{assign var="gtmProducts" value=$oView->getArticleList()}] [{assign var="gtmProducts" value=$oView->getArticleList()}]
[{assign var="gtmCategory" value=$oView->getActiveCategory()}]
[{assign var="breadCrumb" value=''}]
[{assign var="breadCrumb" value=''}]
[{if $gtmProducts|@count}]
[{block name="d3_ga4_view_item_list_block"}] [{strip}]
[{if $gtmProducts|@count}] <script>
[{capture assign=d3_ga4_view_item_list}] /* ga4 */
[{strip}] dataLayer.push({ecommerce: null});
dataLayer.push({ecommerce: null}); dataLayer.push({
dataLayer.push({ 'event':'view_item_list',
'event':'view_item_list', 'event_name': 'view_item_list',
'event_name': 'view_item_list', 'ecommerce': {
'ecommerce': { 'item_list_id': '[{$oView->getCategoryId()}]',
'item_list_id': '[{$oView->getCategoryId()}]', 'item_list_name': '[{foreach from=$oView->getBreadCrumb() item=sCrum}][{if $sCrum.title }][{$breadCrumb|cat:$sCrum.title|cat:" > "}][{/if}][{/foreach}]',
'item_list_name': '[{foreach from=$oView->getBreadCrumb() item=sCrum}][{if $sCrum.title }][{$breadCrumb|cat:$sCrum.title|cat:" > "}][{/if}][{/foreach}]', 'items': [
'items': [ [{foreach from=$gtmProducts name="gtmProducts" item="gtmProduct"}]
[{foreach from=$gtmProducts name="gtmProducts" item="gtmProduct"}] [{assign var="d3PriceObject" value=$gtmProduct->getPrice()}]
[{assign var="d3PriceObject" value=$gtmProduct->getPrice()}] [{assign var="gtmManufacturer" value=$gtmProduct->getManufacturer()}]
[{assign var="gtmManufacturer" value=$gtmProduct->getManufacturer()}] [{if !$gtmCategory}][{assign var="gtmCategory" value=$gtmProduct->getCategory()}][{/if}]
[{if !$gtmCategory}][{assign var="gtmCategory" value=$gtmProduct->getCategory()}][{/if}] {
{ 'item_id': '[{$gtmProduct->getFieldData("oxartnum")}]',
'item_id': '[{$gtmProduct->getFieldData("oxartnum")}]', 'item_name': '[{$gtmProduct->getFieldData("oxtitle")}]',
'item_name': '[{$gtmProduct->getFieldData("oxtitle")}]', 'price': [{$d3PriceObject->getPrice()}],
'price': [{$d3PriceObject->getPrice()}], 'item_brand': '[{if $gtmManufacturer}][{$gtmManufacturer->oxmanufacturers__oxtitle->value}][{/if}]',
'item_brand': '[{if $gtmManufacturer}][{$gtmManufacturer->oxmanufacturers__oxtitle->value}][{/if}]', 'item_category': '[{if $gtmCategory}][{$gtmCategory->getLink()|parse_url:5|ltrim:"/"|rtrim:"/"}][{else}]-[{/if}]',
[{if $gtmCategory}] 'quantity': 1
'item_category': '[{$gtmCategory->getSplitCategoryArray(0)}]', }[{if !$smarty.foreach.gtmProducts.last}],[{/if}]
'item_category_2':'[{$gtmCategory->getSplitCategoryArray(1)}]', [{/foreach}]
'item_category_3':'[{$gtmCategory->getSplitCategoryArray(2)}]', ]
'item_category_4':'[{$gtmCategory->getSplitCategoryArray(3)}]', }
[{/if}] });
'quantity': 1 </script>
}[{if !$smarty.foreach.gtmProducts.last}],[{/if}] [{/strip}]
[{/foreach}] [{/if}]
]
}[{if $oViewConf->isDebugModeOn()}],
'debug_mode': 'true'
[{/if}]
});
[{/strip}]
[{/capture}]
[{oxscript add=$d3_ga4_view_item_list}]
[{/if}]
[{/block}]

View File

@ -1,44 +0,0 @@
[{$smarty.block.parent}]
[{assign var="gtmProducts" value=$oView->getArticleList()}]
[{block name="d3_ga4_view_search_result_block"}]
[{if $gtmProducts|@count}]
[{capture assign=d3_ga4_view_search_result}]
[{strip}]
dataLayer.push({"event": null, "eventLabel": null, "ecommerce": null}); /* Clear the previous ecommerce object. */
dataLayer.push({
'event': 'view_search_result',
'eventLabel':'view_search_result[{if $oViewConf->isDebugModeOn()}]_test[{/if}]',
'ecommerce': {
'search_term': '[{$searchparamforhtml}]',
'items': [
[{foreach from=$gtmProducts name="gtmProducts" item="gtmProduct"}]
[{assign var="d3PriceObject" value=$gtmProduct->getPrice()}]
[{assign var="gtmManufacturer" value=$gtmProduct->getManufacturer()}]
[{assign var="gtmCategory" value=$gtmProduct->getCategory()}]
{
'item_id': '[{$gtmProduct->getFieldData("oxartnum")}]',
'item_name': '[{$gtmProduct->getFieldData("oxtitle")}]',
'price': [{$d3PriceObject->getPrice()}],
'item_brand': '[{if $gtmManufacturer}][{$gtmManufacturer->oxmanufacturers__oxtitle->value}][{/if}]',
[{if $gtmCategory}]
'item_category': '[{$gtmCategory->getSplitCategoryArray(0)}]',
'item_category_2':'[{$gtmCategory->getSplitCategoryArray(1)}]',
'item_category_3':'[{$gtmCategory->getSplitCategoryArray(2)}]',
'item_category_4':'[{$gtmCategory->getSplitCategoryArray(3)}]',
'item_list_name':'[{$gtmCategory->getSplitCategoryArray()}]',
[{/if}]
'quantity': 1
}[{if !$smarty.foreach.gtmProducts.last}],[{/if}]
[{/foreach}]
]
}[{if $oViewConf->isDebugModeOn()}],
'debug_mode': 'true'
[{/if}]
});
[{/strip}]
[{/capture}]
[{oxscript add=$d3_ga4_view_search_result}]
[{/if}]
[{/block}]

View File

@ -4,50 +4,69 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
## [1.11.0](https://git.d3data.de/D3Public/GoogleAnalytics4/compare/1.10.0...1.11.0) - 2023-08-16 ## [2.6.0](https://git.d3data.de/D3Public/GoogleAnalytics4/compare/2.5.0...2.6.0) - 2023-05-31
### Added ### Added
- remove_from_cart - add settings to explicit choose an external service (usercentrics/ consentmanager)
- auto debug_mode setter - position to block-extension
- manufacturer extension for breadcrumb - extended instructions to check for in readme
### Changed
- general template cleanup
## [1.10.0](https://git.d3data.de/D3Public/GoogleAnalytics4/compare/1.9.0...1.10.0) - 2023-06-27
### Added
- Following Entries to dedicated event-templates
- coupon
- paymentType
- item_list_name
- item_category
- Method to get the in order used Payment-Name
- Method to get the current Article Category
### Changed
- cookieManager handling
- general template cleanup
- renaming the template to a more intuitive name
## [1.9.0](https://git.d3data.de/D3Public/GoogleAnalytics4/compare/1.8.0...1.9.0) - 2023-06-19
### Changed
- add_to_cart event template-structure
## [1.8.0](https://git.d3data.de/D3Public/GoogleAnalytics4/compare/1.7.0...1.8.0) - 2023-05-31
### Fixed ### Fixed
- bug in explicit manager selection - usercentrics script
- missing right articleList-getter
## [1.7.0](https://git.d3data.de/D3Public/GoogleAnalytics4/compare/1.6.0...1.7.0) - 2023-05-31
### Added
- extended call to read the technical documentation
### Changed ### Changed
- block-extension for view_item_list - view_item_list-template block extension
- way of getting list-articles in view_item_list - cookieManager handling
### Removed
- additional check for cookieManagerType
## [1.6.0](https://git.d3data.de/D3Public/GoogleAnalytics4/compare/1.5.0...1.6.0) - 2023-05-30 ## [2.5.0](https://git.d3data.de/D3Public/GoogleAnalytics4/compare/2.4.0...2.5.0) - 2023-05-23
### Added ### Added
- possibility to choose between consentmanager && usercentrics - additional settings to explicitly indicate that consentmanager is used
- position to block extension ### Fixed
- unnecessary converting of int to str
- missing PriceObject-bug
### Changed ### Changed
- genuine code cleanup - genuine code cleanup
- usercentrics includation script
## [2.4.0](https://git.d3data.de/D3Public/GoogleAnalytics4/compare/2.3.3...2.4.0) - 2023-05-02
### Added
- "OXID Cookie Management powered by usercentrics" compatibility
- usercentrics defined script attributes
- cookie-manager evaluation
### Changed
- genuine clean up of base-js-files
## [2.3.3](https://git.d3data.de/D3Public/GoogleAnalytics4/compare/2.3.2...2.3.3) - 2023-03-20
### Fixed
- metadata file path for view_item
## [2.3.2](https://git.d3data.de/D3Public/GoogleAnalytics4/compare/2.2.2...2.3.2) - 2023-03-17
### Added
- Aggrosoft-Cookie-Consent compatibility
### Fixed
- wrong function for pageview on thankyou page
### Deleted
- unused files
## [2.2.2](https://git.d3data.de/D3Public/GoogleAnalytics4/compare/2.2.1...2.2.2) - 2023-02-22
### Fixed
- price formatting in view_cart
## [2.2.1](https://git.d3data.de/D3Public/GoogleAnalytics4/compare/2.1.1...2.2.1) - 2023-02-21
### Added
- cookie handling
## [2.1.1](https://git.d3data.de/D3Public/GoogleAnalytics4/compare/2.1...2.1.1) - 2023-01-27
### Fixed
- add missing class import
## [2.1](https://git.d3data.de/D3Public/GoogleAnalytics4/compare/2.0...2.1) - 2023-01-27
### Added
- block section for add_to_basket js
- template block order positions
## [2.0](https://git.d3data.de/D3Public/GoogleAnalytics4/compare/1.1...2.0) - 2023-01-20
### Added
- using of ContainerFactory in ViewConfig
## [1.5.0](https://git.d3data.de/D3Public/GoogleAnalytics4/compare/1.4.0...1.5.0) - 2023-05-23 ## [1.5.0](https://git.d3data.de/D3Public/GoogleAnalytics4/compare/1.4.0...1.5.0) - 2023-05-23
### Added ### Added

View File

@ -12,7 +12,7 @@ Für den geregelten Ablauf sind folgende Blöcke nötig:
- Datei: page/search/search.tpl - Datei: page/search/search.tpl
- GA4 Event: view_search_results - GA4 Event: view_search_results
- Artikelliste - Artikelliste
- Blockname: page_list_productlist - Blockname: page_list_productlist (muss hinzugefĂĽgt werden)
- Datei: page/list/list.tpl - Datei: page/list/list.tpl
- GA4 Event: view_item_list - GA4 Event: view_item_list
- Detailseite - Detailseite
@ -23,10 +23,6 @@ Für den geregelten Ablauf sind folgende Blöcke nötig:
- Blockname: details_productmain_tobasket - Blockname: details_productmain_tobasket
- Datei: page/details/inc/productmain.tpl - Datei: page/details/inc/productmain.tpl
- GA4 Event: add_to_cart - GA4 Event: add_to_cart
- aus dem WK entfernen
- Blockname: checkout_basket_main
- Datei: page/checkout/basket.tpl
- GA4 Event: remove_from_cart
- Warenkorb - Warenkorb
- Blockname: checkout_basket_main - Blockname: checkout_basket_main
- Datei: page/checkout/basket.tpl - Datei: page/checkout/basket.tpl
@ -69,12 +65,4 @@ Aktivieren Sie anschlieĂźend diese Weiche. Setzen Sie den Haken bei "Eigenen Coo
- [OXID Cookie Management powered by usercentrics](https://docs.oxid-esales.com/modules/usercentrics/de/latest/einfuehrung.html) - [OXID Cookie Management powered by usercentrics](https://docs.oxid-esales.com/modules/usercentrics/de/latest/einfuehrung.html)
- In der Usercentrics-Verwaltung die Services "Google Analytics" und "Google Tag Manager" anlegen - In der Usercentrics-Verwaltung die Services "Google Analytics" und "Google Tag Manager" anlegen
- Den Service ```Google Tag Manager``` in den Moduleinstellungen des 'Google Analytics 4' unter - Den Service ```Google Tag Manager``` in den Moduleinstellungen des 'Google Analytics 4' unter
Google Tag Manager eintragen ```Einstell. > Cookie Manager Einstellungen > Cookie-ID``` eintragen
-
- [Consent Management Provider](https://www.consentmanager.net/)
- In der Consentmanager-Oberfläche den Anbieter "Google Tag Manager" mit der ID s905 hinzufügen
- Im Frontend, im consentmanager-Pop-up nach dem 'Google Tag Manager' suchen
- kleines Fragezeichen neben den Namen anklicken und ganz runter scrollen
- prĂĽfen, ob ein Cookie vorgegeben ist
- sonst, in der Consentmanager-Oberfläche Cookie-Liste entsprechendes Cookie suchen und im Admin unter
```Einstell. > Cookie Manager Einstellungen > Cookie-ID``` eintragen

View File

@ -15,14 +15,4 @@
namespace D3\GoogleAnalytics4\Modules\Core{ namespace D3\GoogleAnalytics4\Modules\Core{
class ViewConfig_parent extends \OxidEsales\Eshop\Core\ViewConfig{} class ViewConfig_parent extends \OxidEsales\Eshop\Core\ViewConfig{}
}
namespace D3\GoogleAnalytics4\Modules\Application\Model{
class Category_parent extends \OxidEsales\Eshop\Application\Model\Category {}
class Basket_parent extends \OxidEsales\Eshop\Application\Model\Basket {}
}
namespace D3\GoogleAnalytics4\Modules\Application\Controller{
class BasketController_parent extends \OxidEsales\Eshop\Application\Controller\BasketController {}
class ThankYouController_parent extends \OxidEsales\Eshop\Application\Controller\ThankYouController {}
} }

View File

@ -1,103 +0,0 @@
<?php
namespace D3\GoogleAnalytics4\Modules\Application\Controller;
use OxidEsales\Eshop\Application\Component\BasketComponent;
use OxidEsales\Eshop\Application\Model\Article;
use OxidEsales\Eshop\Application\Model\ArticleList;
use OxidEsales\Eshop\Core\Registry;
use oxSystemComponentException;
class BasketController extends BasketController_parent
{
/**
* @throws oxSystemComponentException
*/
public function render()
{
$return = parent::render();
$this->d3GA4getRemovedArticlesListObject();
return $return;
}
/**
* @return void
* @throws oxSystemComponentException
*/
public function d3GA4getRemovedArticlesListObject() :void
{
$this->addTplParam('hasBeenReloaded', false);
// collecting items to add
$aProducts = Registry::getRequest()->getRequestEscapedParameter('aproducts');
// collecting specified item
$sProductId = $sProductId ?? Registry::getRequest()->getRequestEscapedParameter('aid');
if ($sProductId) {
// additionally fetching current product info
$dAmount = $dAmount ?? Registry::getRequest()->getRequestEscapedParameter('am');
// select lists
$aSel = $aSel ?? Registry::getRequest()->getRequestEscapedParameter('sel');
// persistent parameters
if (empty($aPersParam)) {
/** @var BasketComponent $oBasketComponent */
$oBasketComponent = $this->getComponent('oxcmp_basket');
$aPersParam = $oBasketComponent->__call('getPersistedParameters', []);
}
$sBasketItemId = Registry::getRequest()->getRequestEscapedParameter('bindex');
$aProducts[$sProductId] = ['am' => $dAmount,
'sel' => $aSel,
'persparam' => $aPersParam,
'basketitemid' => $sBasketItemId
];
}
if (is_array($aProducts) && count($aProducts)) {
$toRemoveArticleIdList = [];
$artIdOnArtAmountList = [];
if (Registry::getRequest()->getRequestEscapedParameter('removeBtn') !== null
or Registry::getRequest()->getRequestParameter('updateBtn') !== null) {
//setting amount to 0 if removing article from basket
foreach ($aProducts as $sProductId => $aProduct) {
if ((isset($aProduct['remove']) && $aProduct['remove']) or intval($aProduct['am']) === 0) {
if (!in_array($aProduct, $toRemoveArticleIdList)) {
$toRemoveArticleIdList[] = $aProduct['aid'];
$artIdOnArtAmountList[$aProduct['aid']] = $aProduct['am'];
}
$aProducts[$sProductId]['am'] = 0;
#for GA4 Event
$this->addTplParam('hasBeenReloaded', true);
} else {
unset($aProducts[$sProductId]);
}
}
}
$oArtList = oxNew(ArticleList::class);
$oArtList->loadIds($toRemoveArticleIdList);
#dumpVar($this->getBasketArticles());
/** @var Article $item */
foreach ($oArtList->getArray() as $item){
foreach ($artIdOnArtAmountList as $artId => $artAmount){
if ($item->getId() === $artId){
$item->assign(['d3AmountThatGotRemoved' => $artAmount]);
}
}
}
$this->addTplParam('toRemoveArticles', $oArtList);
}
}
}

View File

@ -1,22 +0,0 @@
<?php
namespace D3\GoogleAnalytics4\Modules\Application\Controller;
use OxidEsales\Eshop\Application\Model\Country;
class ThankYouController extends ThankYouController_parent
{
/**
* @return Country
*/
public function d3GAGetUserCountry()
{
$sCountryId = $this->getOrder()->getFieldData('oxbillcountryid');
/** @var Country $oCountry */
$oCountry = oxNew(Country::class);
$oCountry->load($sCountryId);
return $oCountry;
}
}

View File

@ -1,23 +0,0 @@
<?php
namespace D3\GoogleAnalytics4\Modules\Application\Model;
use OxidEsales\Eshop\Application\Model\Payment;
class Basket extends Basket_parent
{
/**
* @return void
*/
public function getPaymentOnPaymentId() :string
{
if ($this->getPaymentId()){
$oPayment = oxNew(Payment::class);
if ($oPayment->load($this->getPaymentId())){
return $oPayment->getFieldData('oxdesc');
}
}
return "couldn't load payment!";
}
}

View File

@ -1,44 +0,0 @@
<?php
namespace D3\GoogleAnalytics4\Modules\Application\Model;
class Category extends Category_parent
{
/**
* @param int $indexOfArray
* @return string
*/
public function getSplitCategoryArray(int $indexOfArray = -1) :string
{
if ($indexOfArray > -1){
$splitCatArray =
array_values(
array_filter(
explode(
'/',
trim(
parse_url(
$this->getLink(),
5
)
)
)
)
);
if ($splitCatArray[$indexOfArray]){
return $splitCatArray[$indexOfArray];
}else{
return "";
}
}
return
trim(
parse_url(
$this->getLink(),
5
)
);
}
}

View File

@ -1,44 +0,0 @@
<?php
namespace D3\GoogleAnalytics4\Modules\Application\Model;
class Manufacturer extends Manufacturer_parent
{
/**
* @param int $indexOfArray
* @return string
*/
public function getSplitCategoryArray(int $indexOfArray = -1) :string
{
if ($indexOfArray > -1){
$splitCatArray =
array_values(
array_filter(
explode(
'/',
trim(
parse_url(
$this->getLink(),
5
)
)
)
)
);
if ($splitCatArray[$indexOfArray]){
return $splitCatArray[$indexOfArray];
}else{
return "";
}
}
return
trim(
parse_url(
$this->getLink(),
5
)
);
}
}

View File

@ -17,6 +17,8 @@ use D3\GoogleAnalytics4\Application\Model\ManagerTypes;
use OxidEsales\Eshop\Application\Controller\FrontendController; use OxidEsales\Eshop\Application\Controller\FrontendController;
use OxidEsales\Eshop\Core\Config; use OxidEsales\Eshop\Core\Config;
use OxidEsales\Eshop\Core\Registry; use OxidEsales\Eshop\Core\Registry;
use OxidEsales\EshopCommunity\Internal\Container\ContainerFactory;
use OxidEsales\EshopCommunity\Internal\Framework\Module\Configuration\Bridge\ModuleSettingBridgeInterface;
class ViewConfig extends ViewConfig_parent class ViewConfig extends ViewConfig_parent
{ {
@ -29,7 +31,10 @@ class ViewConfig extends ViewConfig_parent
{ {
if ($this->sContainerId === null) if ($this->sContainerId === null)
{ {
$this->sContainerId = $this->getConfig()->getConfigParam('d3_gtm_sContainerID'); $this->sContainerId = ContainerFactory::getInstance()
->getContainer()
->get(ModuleSettingBridgeInterface::class)
->get('d3_gtm_sContainerID', 'd3googleanalytics4');
} }
return $this->sContainerId; return $this->sContainerId;
} }
@ -70,7 +75,7 @@ class ViewConfig extends ViewConfig_parent
$this->defineCookieManagerType(); $this->defineCookieManagerType();
$sCookieID = trim($oConfig->getConfigParam('d3_gtm_settings_cookieName')); $sCookieID = $oConfig->getConfigParam('d3_gtm_settings_cookieName');
// Netensio Cookie Manager // Netensio Cookie Manager
if ($this->sCookieManagerType === ManagerTypes::NET_COOKIE_MANAGER) { if ($this->sCookieManagerType === ManagerTypes::NET_COOKIE_MANAGER) {
@ -92,7 +97,6 @@ class ViewConfig extends ViewConfig_parent
$this->sCookieManagerType === ManagerTypes::USERCENTRICS_MODULE $this->sCookieManagerType === ManagerTypes::USERCENTRICS_MODULE
or $this->sCookieManagerType === ManagerTypes::USERCENTRICS_MANUALLY or $this->sCookieManagerType === ManagerTypes::USERCENTRICS_MANUALLY
or $this->sCookieManagerType === ManagerTypes::CONSENTMANAGER or $this->sCookieManagerType === ManagerTypes::CONSENTMANAGER
or $this->sCookieManagerType === ManagerTypes::COOKIEFIRST
or $this->sCookieManagerType === ManagerTypes::EXTERNAL_SERVICE or $this->sCookieManagerType === ManagerTypes::EXTERNAL_SERVICE
) )
{ {
@ -111,7 +115,8 @@ class ViewConfig extends ViewConfig_parent
*/ */
public function getGtmScriptAttributes() :string public function getGtmScriptAttributes() :string
{ {
$sCookieId = trim(Registry::getConfig()->getConfigParam('d3_gtm_settings_cookieName')); $oConfig = Registry::getConfig();
$sCookieId = $oConfig->getConfigParam('d3_gtm_settings_cookieName');
if (false === $this->shallUseOwnCookieManager()){ if (false === $this->shallUseOwnCookieManager()){
return ""; return "";
@ -139,10 +144,6 @@ class ViewConfig extends ViewConfig_parent
} }
} }
if ($this->sCookieManagerType === ManagerTypes::COOKIEFIRST){
return 'type="text/plain" data-cookiefirst-category="' . $sCookieId .'"';
}
return ""; return "";
} }
@ -152,7 +153,10 @@ class ViewConfig extends ViewConfig_parent
{ {
if ($this->blGA4enabled === null) if ($this->blGA4enabled === null)
{ {
$this->sContainerId = $this->getConfig()->getConfigParam('d3_gtm_blEnableGA4'); $this->sContainerId = ContainerFactory::getInstance()
->getContainer()
->get(ModuleSettingBridgeInterface::class)
->get('d3_gtm_blEnableGA4', 'd3googleanalytics4');
} }
return $this->blGA4enabled; return $this->blGA4enabled;
@ -195,11 +199,6 @@ class ViewConfig extends ViewConfig_parent
return json_encode([$dataLayer], JSON_PRETTY_PRINT); return json_encode([$dataLayer], JSON_PRETTY_PRINT);
} }
public function isDebugModeOn() :bool
{
return Registry::getConfig()->getConfigParam('d3_gtm_blEnableDebug');
}
public function isPromotionList($listId) public function isPromotionList($listId)
{ {
$oConfig = Registry::getConfig(); $oConfig = Registry::getConfig();

View File

@ -1,56 +1,56 @@
{ {
"name": "d3/google-analytics4", "name": "d3/google-analytics4",
"description": "Google Tag Manager with new Google Analytics 4 for OXID eShop v6", "description": "Google Tag Manager with new Google Analytics 4 for OXID eShop v6",
"type": "oxideshop-module", "type": "oxideshop-module",
"keywords": [ "keywords": [
"oxid", "oxid",
"modules", "modules",
"eShop", "eShop",
"d3", "d3",
"google", "google",
"ga4", "ga4",
"googleanalytics", "googleanalytics",
"gtm", "gtm",
"configuration" "configuration"
], ],
"homepage": "https://www.d3data.de", "homepage": "https://www.d3data.de",
"license": [ "license": [
"GPL-3.0" "GPL-3.0"
], ],
"authors": [ "authors": [
{ {
"name": "Marat Bedoev", "name": "Marat Bedoev",
"email": "hello@mb-dev.pro" "email": "hello@mb-dev.pro"
}, },
{ {
"name": "D3 Data Development (Inh. Thomas Dartsch)", "name": "D3 Data Development (Inh. Thomas Dartsch)",
"email": "info@shopmodule.com", "email": "info@shopmodule.com",
"homepage": "https://www.d3data.de" "homepage": "https://www.d3data.de"
} }
], ],
"support": { "support": {
"email": "support@shopmodule.com" "email": "support@shopmodule.com"
}, },
"extra": { "extra": {
"oxideshop": { "oxideshop": {
"blacklist-filter": [ "blacklist-filter": [
"*.md", "*.md",
"composer.json", "composer.json",
".php-cs-fixer.php", ".php-cs-fixer.php",
"*.xml", "*.xml",
"*.neon" "*.neon"
], ],
"target-directory": "d3/googleanalytics4" "target-directory": "d3/googleanalytics4"
} }
}, },
"require": { "require": {
"php": ">=7.1", "php": ">=7.1",
"oxid-esales/oxideshop-ce": "v6.0 - 6.3", "oxid-esales/oxideshop-ce": "^6.5",
"google/apiclient":" ^2.0" "google/apiclient":" ^2.0"
}, },
"autoload": { "autoload": {
"psr-4": { "psr-4": {
"D3\\GoogleAnalytics4\\": "../../../source/modules/d3/googleanalytics4" "D3\\GoogleAnalytics4\\": "../../../source/modules/d3/googleanalytics4"
} }
} }
} }

View File

@ -1,15 +1,5 @@
<?php <?php
use D3\GoogleAnalytics4\Modules\Application\Controller\BasketController;
use D3\GoogleAnalytics4\Modules\Application\Controller\ThankYouController;
use D3\GoogleAnalytics4\Modules\Application\Model\Basket as Basket;
use D3\GoogleAnalytics4\Modules\Application\Model\Category as Category;
use D3\GoogleAnalytics4\Modules\Core\ViewConfig; use D3\GoogleAnalytics4\Modules\Core\ViewConfig;
use OxidEsales\Eshop\Application\Controller\BasketController as OEBasketController;
use OxidEsales\Eshop\Application\Controller\ThankYouController as OEThankYouController;
use OxidEsales\Eshop\Application\Model\Basket as OEBasket;
use OxidEsales\Eshop\Application\Model\Category as OECategory;
use OxidEsales\Eshop\Application\Model\Manufacturer as OEManufacturer;
use OxidEsales\Eshop\Core\ViewConfig as OEViewConfig; use OxidEsales\Eshop\Core\ViewConfig as OEViewConfig;
$sMetadataVersion = '2.1'; $sMetadataVersion = '2.1';
@ -27,19 +17,19 @@ $aModule = [
Die Entwicklung basiert auf einem Fork von Marat Bedoev - <a href='https://github.com/vanilla-thunder/oxid-module-gtm'>Github-Link</a> Die Entwicklung basiert auf einem Fork von Marat Bedoev - <a href='https://github.com/vanilla-thunder/oxid-module-gtm'>Github-Link</a>
", ",
'thumbnail' => 'thumbnail.png', 'thumbnail' => 'thumbnail.png',
'version' => '1.11.0', 'version' => '2.6.0',
'author' => 'Data Development (Inh.: Thomas Dartsch)', 'author' => 'Data Development (Inh.: Thomas Dartsch)',
'email' => 'support@shopmodule.com', 'email' => 'support@shopmodule.com',
'url' => 'https://www.oxidmodule.com/', 'url' => 'https://www.oxidmodule.com/',
'extend' => [ 'extend' => [
OEViewConfig::class => ViewConfig::class, OEViewConfig::class => ViewConfig::class
OECategory::class => Category::class, ],
OEBasket::class => Basket::class, 'templates' => [
OEBasketController::class => BasketController::class, // GA4 events
OEManufacturer::class => Manufacturer::class, 'ga4_add_to_cart.tpl' => 'd3/googleanalytics4/Application/views/ga4/add_to_cart.tpl',
OEThankYouController::class => ThankYouController::class 'ga4_search.tpl' => 'd3/googleanalytics4/Application/views/ga4/search.tpl',
'ga4_view_item_list.tpl' => 'd3/googleanalytics4/Application/views/ga4/view_item_list.tpl',
], ],
'templates' => [],
'blocks' => [ 'blocks' => [
// tag manager js // tag manager js
[ [
@ -65,12 +55,12 @@ $aModule = [
[ [
'template' => 'page/checkout/basket.tpl', 'template' => 'page/checkout/basket.tpl',
'block' => 'checkout_basket_main', 'block' => 'checkout_basket_main',
'file' => '/Application/views/blocks/view_cart.tpl' 'file' => '/Application/views/blocks/checkout_s1.tpl'
], ],
[ [
'template' => 'page/checkout/thankyou.tpl', 'template' => 'page/checkout/thankyou.tpl',
'block' => 'checkout_thankyou_main', 'block' => 'checkout_thankyou_main',
'file' => '/Application/views/blocks/purchase.tpl' 'file' => '/Application/views/blocks/checkout_s5.tpl'
], ],
// Lists // Lists
// view_item_list // view_item_list
@ -84,7 +74,7 @@ $aModule = [
[ [
'template' => 'page/search/search.tpl', 'template' => 'page/search/search.tpl',
'block' => 'search_results', 'block' => 'search_results',
'file' => '/Application/views/ga4/view_search_result.tpl', 'file' => '/Application/views/ga4/search.tpl',
'position' => 150 'position' => 150
], ],
// add_to_cart // add_to_cart
@ -93,13 +83,6 @@ $aModule = [
'block' => 'details_productmain_tobasket', 'block' => 'details_productmain_tobasket',
'file' => '/Application/views/ga4/add_to_cart.tpl', 'file' => '/Application/views/ga4/add_to_cart.tpl',
'position' => 150 'position' => 150
],
// remove_from_cart
[
'template' => 'page/checkout/basket.tpl',
'block' => 'checkout_basket_main',
'file' => '/Application/views/ga4/remove_from_cart.tpl',
'position' => 150
] ]
], ],
'settings' => [ 'settings' => [
@ -143,7 +126,7 @@ $aModule = [
'name' => 'd3_gtm_settings_HAS_STD_MANAGER', 'name' => 'd3_gtm_settings_HAS_STD_MANAGER',
'type' => 'select', 'type' => 'select',
'value' => 'none', 'value' => 'none',
'constraints' => 'NONE|CONSENTMANAGER|USERCENTRICS|COOKIEFIRST', 'constraints' => 'NONE|CONSENTMANAGER|USERCENTRICS',
], ],
] ]
]; ];