From 5355b0a7ade52e1849f614f9a715ce7764892dfd Mon Sep 17 00:00:00 2001 From: MarkusGaertner Date: Tue, 15 Aug 2023 11:59:27 +0200 Subject: [PATCH 01/18] extend Manufacturer --- Modules/Application/Model/Manufacturer.php | 44 ++++++++++++++++++++++ metadata.php | 2 + 2 files changed, 46 insertions(+) create mode 100644 Modules/Application/Model/Manufacturer.php diff --git a/Modules/Application/Model/Manufacturer.php b/Modules/Application/Model/Manufacturer.php new file mode 100644 index 0000000..8ecae9a --- /dev/null +++ b/Modules/Application/Model/Manufacturer.php @@ -0,0 +1,44 @@ + -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 + ) + ); + } +} \ No newline at end of file diff --git a/metadata.php b/metadata.php index e080aab..71e1f51 100755 --- a/metadata.php +++ b/metadata.php @@ -5,6 +5,7 @@ use D3\GoogleAnalytics4\Modules\Application\Model\Category as Category; use D3\GoogleAnalytics4\Modules\Core\ViewConfig; 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; $sMetadataVersion = '2.1'; @@ -29,6 +30,7 @@ $aModule = [ 'extend' => [ OEViewConfig::class => ViewConfig::class, OECategory::class => Category::class, + OEManufacturer::class => Manufacturer::class, OEBasket::class => Basket::class ], 'templates' => [], From 216c53fa90c500590d53554946c287fa74c44151 Mon Sep 17 00:00:00 2001 From: MaxBUhe Date: Thu, 17 Aug 2023 08:50:15 +0200 Subject: [PATCH 02/18] general structure rework, debug_mode setter --- Application/views/blocks/purchase.tpl | 97 +++++++++++--------- Application/views/blocks/view_cart.tpl | 78 +++++++++------- Application/views/blocks/view_item.tpl | 59 +++++++----- Application/views/ga4/add_to_cart.tpl | 74 ++++++++------- Application/views/ga4/view_item_list.tpl | 74 ++++++++------- Application/views/ga4/view_search_result.tpl | 73 ++++++++------- 6 files changed, 249 insertions(+), 206 deletions(-) diff --git a/Application/views/blocks/purchase.tpl b/Application/views/blocks/purchase.tpl index b97219e..3419a43 100644 --- a/Application/views/blocks/purchase.tpl +++ b/Application/views/blocks/purchase.tpl @@ -1,49 +1,56 @@ [{$smarty.block.parent}] -[{strip}] - -[{/strip}] + { + '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}] \ No newline at end of file diff --git a/Application/views/blocks/view_cart.tpl b/Application/views/blocks/view_cart.tpl index 79279c0..765bfe8 100644 --- a/Application/views/blocks/view_cart.tpl +++ b/Application/views/blocks/view_cart.tpl @@ -5,38 +5,46 @@ [{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()}], - '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')}]', - '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()}]', - '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}] - ] - } - }); -[{/capture}][{/strip}] -[{oxscript add=$d3_ga4_view_cart}] \ No newline at end of file +[{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}] \ No newline at end of file diff --git a/Application/views/blocks/view_item.tpl b/Application/views/blocks/view_item.tpl index 3e4b60a..e79852e 100644 --- a/Application/views/blocks/view_item.tpl +++ b/Application/views/blocks/view_item.tpl @@ -3,29 +3,38 @@ [{assign var="gtmCategory" value=$gtmProduct->getCategory()}] [{assign var="gtmManufacturer" value=$gtmProduct->getManufacturer()}] - \ No newline at end of file + dataLayer.push({ + 'event': 'view_item', + 'eventLabel':'Product View', + 'ecommerce': { + 'currency': '[{$currency->name}]', + 'items': [ + { + 'item_name': '[{$gtmProduct->getFieldData("oxtitle")}]', + 'item_id': '[{$gtmProduct->getFieldData("oxartnum")}]', + 'item_brand': '[{if $gtmManufacturer}][{$gtmManufacturer->oxmanufacturers__oxtitle->value}][{/if}]', + 'item_variant': '[{if $gtmProduct->getFieldData("oxvarselect")}][{$gtmProduct->getFieldData("oxvarselect")}][{/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}] + [{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}] \ No newline at end of file diff --git a/Application/views/ga4/add_to_cart.tpl b/Application/views/ga4/add_to_cart.tpl index adc990f..8a2b68e 100644 --- a/Application/views/ga4/add_to_cart.tpl +++ b/Application/views/ga4/add_to_cart.tpl @@ -6,41 +6,47 @@ [{assign var="gtmManufacturer" value=$gtmProduct->getManufacturer()}] [{assign var="gtmCategory" value=$gtmProduct->getCategory()}] -[{capture assign=d3_ga4_add_to_cart}] - [{block name="d3_ga4_add_to_basket"}] - $("#toBasket").click(function(event) { - dataLayer.push({"event": null, "eventLabel": null, "ecommerce": null}); /* Clear the previous ecommerce object. */ +[{block name="d3_ga4_add_to_cart_block"}] + [{capture assign=d3_ga4_add_to_cart}] + [{strip}] + $("#toBasket").click(function(event) { + dataLayer.push({"event": null, "eventLabel": null, "ecommerce": null}); /* Clear the previous ecommerce object. */ - [{*** Debug cases ***}] - [{*event.preventDefault();*}] + [{*** Debug cases ***}] + [{*event.preventDefault();*}] - let iArtQuantity = $("#amountToBasket").val(); + let iArtQuantity = $("#amountToBasket").val(); - dataLayer.push({ - 'isAddToBasket': true, - 'event':'add_to_cart', - 'eventLabel': 'add_to_cart', - 'ecommerce': { - 'currency': "[{$currency->name}]", - 'value': iArtQuantity*[{$d3PriceObject->getPrice()}], - 'items': [ - { - 'item_id': '[{$gtmProduct->getFieldData('oxartnum')}]', - 'item_name': '[{$gtmProduct->getFieldData('oxtitle')}]', - 'price': [{$d3PriceObject->getPrice()}], - 'item_brand': '[{if $gtmManufacturer}][{$gtmManufacturer->oxmanufacturers__oxtitle->value}][{/if}]', - 'item_variant': '[{if $gtmProduct->getFieldData('oxvarselect')}][{$gtmProduct->getFieldData('oxvarselect')}][{/if}]', - '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()}]', - 'quantity': iArtQuantity - } - ] - } - }); - }); - [{/block}] + dataLayer.push({ + 'isAddToBasket': true, + 'event':'add_to_cart', + 'eventLabel': 'add_to_cart', + 'ecommerce': { + 'currency': "[{$currency->name}]", + 'value': iArtQuantity*[{$d3PriceObject->getPrice()}], + 'items': [ + { + 'item_id': '[{$gtmProduct->getFieldData('oxartnum')}]', + 'item_name': '[{$gtmProduct->getFieldData('oxtitle')}]', + 'price': [{$d3PriceObject->getPrice()}], + 'item_brand': '[{if $gtmManufacturer}][{$gtmManufacturer->oxmanufacturers__oxtitle->value}][{/if}]', + 'item_variant': '[{if $gtmProduct->getFieldData('oxvarselect')}][{$gtmProduct->getFieldData('oxvarselect')}][{/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': iArtQuantity + } + ] + }[{if $oViewConf->isDebugModeOn()}], + 'debug_mode': 'true' + [{/if}] + }); + }); + [{/strip}] [{/capture}] -[{oxscript add=$d3_ga4_add_to_cart}] \ No newline at end of file + [{oxscript add=$d3_ga4_add_to_cart}] +[{/block}] \ No newline at end of file diff --git a/Application/views/ga4/view_item_list.tpl b/Application/views/ga4/view_item_list.tpl index 2be0f46..12fb5e8 100644 --- a/Application/views/ga4/view_item_list.tpl +++ b/Application/views/ga4/view_item_list.tpl @@ -4,37 +4,43 @@ [{assign var="breadCrumb" value=''}] -[{if $gtmProducts|@count}] -[{strip}] - -[{/strip}] -[{/if}] \ No newline at end of file +[{block name="d3_ga4_view_item_list_block"}] + [{if $gtmProducts|@count}] + [{capture assign=d3_ga4_view_item_list}] + [{strip}] + dataLayer.push({ecommerce: null}); + dataLayer.push({ + 'event':'view_item_list', + 'event_name': 'view_item_list', + 'ecommerce': { + 'item_list_id': '[{$oView->getCategoryId()}]', + 'item_list_name': '[{foreach from=$oView->getBreadCrumb() item=sCrum}][{if $sCrum.title }][{$breadCrumb|cat:$sCrum.title|cat:" > "}][{/if}][{/foreach}]', + '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}]', + [{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)}]', + [{/if}] + 'quantity': 1 + }[{if !$smarty.foreach.gtmProducts.last}],[{/if}] + [{/foreach}] + ] + }[{if $oViewConf->isDebugModeOn()}], + 'debug_mode': 'true' + [{/if}] + }); + [{/strip}] + [{/capture}] + [{oxscript add=$d3_ga4_view_item_list}] + [{/if}] +[{/block}] \ No newline at end of file diff --git a/Application/views/ga4/view_search_result.tpl b/Application/views/ga4/view_search_result.tpl index 92487ed..42e4c7b 100644 --- a/Application/views/ga4/view_search_result.tpl +++ b/Application/views/ga4/view_search_result.tpl @@ -2,36 +2,43 @@ [{assign var="gtmProducts" value=$oView->getArticleList()}] -[{if $gtmProducts|@count}] - [{strip}] - - [{/strip}] -[{/if}] \ No newline at end of file +[{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}] \ No newline at end of file From 443b456a0d7c55a6cbc9070381656474cf365cb1 Mon Sep 17 00:00:00 2001 From: MaxBUhe Date: Thu, 17 Aug 2023 08:50:41 +0200 Subject: [PATCH 03/18] add new method for debug-check --- Modules/Core/ViewConfig.php | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/Modules/Core/ViewConfig.php b/Modules/Core/ViewConfig.php index 6d9fc0c..5df7d64 100644 --- a/Modules/Core/ViewConfig.php +++ b/Modules/Core/ViewConfig.php @@ -195,6 +195,11 @@ class ViewConfig extends ViewConfig_parent return json_encode([$dataLayer], JSON_PRETTY_PRINT); } + public function isDebugModeOn() :bool + { + return Registry::getConfig()->getConfigParam('d3_gtm_blEnableDebug'); + } + public function isPromotionList($listId) { $oConfig = Registry::getConfig(); From 6b18c50b42c11c2f697b84ff1bf95d832f9319a9 Mon Sep 17 00:00:00 2001 From: MaxBUhe Date: Thu, 17 Aug 2023 08:51:02 +0200 Subject: [PATCH 04/18] add 'remove_from_cart' event --- Application/views/ga4/remove_from_cart.tpl | 48 ++++++++ IntelliSenseHelper.php | 4 + .../Controller/BasketController.php | 103 ++++++++++++++++++ metadata.php | 14 ++- 4 files changed, 167 insertions(+), 2 deletions(-) create mode 100644 Application/views/ga4/remove_from_cart.tpl create mode 100644 Modules/Application/Controller/BasketController.php diff --git a/Application/views/ga4/remove_from_cart.tpl b/Application/views/ga4/remove_from_cart.tpl new file mode 100644 index 0000000..8c41746 --- /dev/null +++ b/Application/views/ga4/remove_from_cart.tpl @@ -0,0 +1,48 @@ +[{$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}] \ No newline at end of file diff --git a/IntelliSenseHelper.php b/IntelliSenseHelper.php index 2291ade..f8ac44a 100644 --- a/IntelliSenseHelper.php +++ b/IntelliSenseHelper.php @@ -20,4 +20,8 @@ namespace D3\GoogleAnalytics4\Modules\Core{ 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 {} } \ No newline at end of file diff --git a/Modules/Application/Controller/BasketController.php b/Modules/Application/Controller/BasketController.php new file mode 100644 index 0000000..511f151 --- /dev/null +++ b/Modules/Application/Controller/BasketController.php @@ -0,0 +1,103 @@ +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); + } + } +} \ No newline at end of file diff --git a/metadata.php b/metadata.php index e080aab..cd5fd93 100755 --- a/metadata.php +++ b/metadata.php @@ -1,8 +1,10 @@ Github-Link ", 'thumbnail' => 'thumbnail.png', - 'version' => '1.10.0', + 'version' => '1.11.0', 'author' => 'Data Development (Inh.: Thomas Dartsch)', 'email' => 'support@shopmodule.com', 'url' => 'https://www.oxidmodule.com/', 'extend' => [ OEViewConfig::class => ViewConfig::class, OECategory::class => Category::class, - OEBasket::class => Basket::class + OEBasket::class => Basket::class, + OEBasketController::class => BasketController::class ], 'templates' => [], 'blocks' => [ @@ -85,6 +88,13 @@ $aModule = [ 'block' => 'details_productmain_tobasket', 'file' => '/Application/views/ga4/add_to_cart.tpl', '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' => [ From ea6b63fd2f87110c7bc5eba7dd543bb911997271 Mon Sep 17 00:00:00 2001 From: MaxBUhe Date: Thu, 17 Aug 2023 08:51:51 +0200 Subject: [PATCH 05/18] extended docs --- CHANGELOG.md | 7 +++++++ Docs/README.md | 14 +++++++++++++- 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3a58d8f..f58f019 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,13 @@ 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/), 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 +### Added +- remove_from_cart +- auto debug_mode setter +### 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 diff --git a/Docs/README.md b/Docs/README.md index 00468e1..039c19d 100644 --- a/Docs/README.md +++ b/Docs/README.md @@ -23,6 +23,10 @@ Für den geregelten Ablauf sind folgende Blöcke nötig: - Blockname: details_productmain_tobasket - Datei: page/details/inc/productmain.tpl - GA4 Event: add_to_cart +- aus dem WK entfernen + - Blockname: checkout_basket_main + - Datei: page/checkout/basket.tpl + - GA4 Event: remove_from_cart - Warenkorb - Blockname: checkout_basket_main - Datei: page/checkout/basket.tpl @@ -65,4 +69,12 @@ 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) - 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 - ```Einstell. > Cookie Manager Einstellungen > Cookie-ID``` eintragen \ No newline at end of file + Google Tag Manager 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 \ No newline at end of file From e90aba2c555ea8eb4367586c427a0c3fcc16a39a Mon Sep 17 00:00:00 2001 From: MaxBUhe Date: Thu, 17 Aug 2023 08:52:00 +0200 Subject: [PATCH 06/18] add gitignore --- .gitignore | 1 + 1 file changed, 1 insertion(+) create mode 100644 .gitignore diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..485dee6 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +.idea From a49c29d7aa6a9a48c8fd65389a9d34d36f7954da Mon Sep 17 00:00:00 2001 From: MaxBUhe Date: Thu, 17 Aug 2023 09:20:58 +0200 Subject: [PATCH 07/18] add CountryObjectGetter to ThankYouController --- IntelliSenseHelper.php | 1 + .../Controller/ThankYouController.php | 22 +++++++++++++++++++ metadata.php | 5 ++++- 3 files changed, 27 insertions(+), 1 deletion(-) create mode 100644 Modules/Application/Controller/ThankYouController.php diff --git a/IntelliSenseHelper.php b/IntelliSenseHelper.php index f8ac44a..08ac114 100644 --- a/IntelliSenseHelper.php +++ b/IntelliSenseHelper.php @@ -24,4 +24,5 @@ namespace D3\GoogleAnalytics4\Modules\Application\Model{ namespace D3\GoogleAnalytics4\Modules\Application\Controller{ class BasketController_parent extends \OxidEsales\Eshop\Application\Controller\BasketController {} + class ThankYouController_parent extends \OxidEsales\Eshop\Application\Controller\ThankYouController {} } \ No newline at end of file diff --git a/Modules/Application/Controller/ThankYouController.php b/Modules/Application/Controller/ThankYouController.php new file mode 100644 index 0000000..215503a --- /dev/null +++ b/Modules/Application/Controller/ThankYouController.php @@ -0,0 +1,22 @@ +getOrder()->getFieldData('oxbillcountryid'); + + /** @var Country $oCountry */ + $oCountry = oxNew(Country::class); + $oCountry->load($sCountryId); + + return $oCountry; + } +} \ No newline at end of file diff --git a/metadata.php b/metadata.php index cd5fd93..5e1513f 100755 --- a/metadata.php +++ b/metadata.php @@ -1,10 +1,12 @@ ViewConfig::class, OECategory::class => Category::class, OEBasket::class => Basket::class, - OEBasketController::class => BasketController::class + OEBasketController::class => BasketController::class, + OEThankYouController::class => ThankYouController::class ], 'templates' => [], 'blocks' => [ From aae6c437864337109a43fc9d6047f80c18ae8f0d Mon Sep 17 00:00:00 2001 From: MaxBUhe Date: Thu, 17 Aug 2023 10:30:19 +0200 Subject: [PATCH 08/18] extends changelog --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index f58f019..cc8fac3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Added - remove_from_cart - auto debug_mode setter +- manufacturer extension for breadcrumb ### Changed - general template cleanup From 2e6acbe675009e969906f274c25aeb9bfc7a1339 Mon Sep 17 00:00:00 2001 From: MaxBUhe Date: Thu, 17 Aug 2023 10:59:57 +0200 Subject: [PATCH 09/18] [fixed] metadata class entry --- CHANGELOG.md | 4 ++++ metadata.php | 1 + 2 files changed, 5 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index cc8fac3..cb728c8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,10 @@ 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/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## [1.11.1](https://git.d3data.de/D3Public/GoogleAnalytics4/compare/1.11.0...1.11.1) - 2023-08-17 +### Fixed +- metadata class entry + ## [1.11.0](https://git.d3data.de/D3Public/GoogleAnalytics4/compare/1.10.0...1.11.0) - 2023-08-16 ### Added - remove_from_cart diff --git a/metadata.php b/metadata.php index 059de45..c31936c 100755 --- a/metadata.php +++ b/metadata.php @@ -4,6 +4,7 @@ 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\Application\Model\Manufacturer as Manufacturer; use D3\GoogleAnalytics4\Modules\Core\ViewConfig; use OxidEsales\Eshop\Application\Controller\BasketController as OEBasketController; use OxidEsales\Eshop\Application\Controller\ThankYouController as OEThankYouController; From 575e35ffbc8217a65a310c1f2167bbf9587baf13 Mon Sep 17 00:00:00 2001 From: MaxBUhe Date: Fri, 18 Aug 2023 14:07:53 +0200 Subject: [PATCH 10/18] [changed] 'an article has been removed from basket'-check --- .../Controller/BasketController.php | 32 ++++++++++++++++--- 1 file changed, 28 insertions(+), 4 deletions(-) diff --git a/Modules/Application/Controller/BasketController.php b/Modules/Application/Controller/BasketController.php index 511f151..8e0bdff 100644 --- a/Modules/Application/Controller/BasketController.php +++ b/Modules/Application/Controller/BasketController.php @@ -52,7 +52,8 @@ class BasketController extends BasketController_parent $sBasketItemId = Registry::getRequest()->getRequestEscapedParameter('bindex'); - $aProducts[$sProductId] = ['am' => $dAmount, + $aProducts[$sProductId] = [ + 'am' => $dAmount, 'sel' => $aSel, 'persparam' => $aPersParam, 'basketitemid' => $sBasketItemId @@ -63,9 +64,7 @@ class BasketController extends BasketController_parent $toRemoveArticleIdList = []; $artIdOnArtAmountList = []; - if (Registry::getRequest()->getRequestEscapedParameter('removeBtn') !== null - or Registry::getRequest()->getRequestParameter('updateBtn') !== null) { - + if ($this->isArticleRemovedState($aProducts)) { //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) { @@ -100,4 +99,29 @@ class BasketController extends BasketController_parent $this->addTplParam('toRemoveArticles', $oArtList); } } + + /** + * @return bool + * + * checks, if we're in the short state of "an Article has been removed" + * We check by looking for the "'removeBtn' is not null", as a sign for it has been triggered/ clicked + * if that doesn't work, we check if there's an Article in the Products array, that has "'am' = 0" + * Which also shows we're in that state rn + */ + protected function isArticleRemovedState(array $productsArray) :bool + { + if (Registry::getRequest()->getRequestEscapedParameter('removeBtn') + or Registry::getRequest()->getRequestEscapedParameter('updateBtn') + ){ + return true; + }else{ + foreach ($productsArray as $aProduct) { + if (intval($aProduct['am']) === 0) { + return true; + } + } + } + + return false; + } } \ No newline at end of file From eb2c7f73b9c840c135d8aab932c16a8a18cbe7d9 Mon Sep 17 00:00:00 2001 From: MaxBUhe Date: Thu, 7 Sep 2023 15:08:06 +0200 Subject: [PATCH 11/18] add cookiebot essentials --- Application/Model/ManagerTypes.php | 5 ++++- Application/views/admin/de/module_options.php | 1 + Modules/Core/ViewConfig.php | 5 +++++ metadata.php | 2 +- 4 files changed, 11 insertions(+), 2 deletions(-) diff --git a/Application/Model/ManagerTypes.php b/Application/Model/ManagerTypes.php index 01c9db5..f12af76 100644 --- a/Application/Model/ManagerTypes.php +++ b/Application/Model/ManagerTypes.php @@ -36,6 +36,8 @@ class ManagerTypes const COOKIEFIRST = "COOKIEFIRST"; + const COOKIEBOT = "COOKIEBOT"; + /** * @return array */ @@ -48,7 +50,8 @@ class ManagerTypes "oxps_usercentrics" => self::USERCENTRICS_MODULE, "usercentrics" => self::USERCENTRICS_MANUALLY, "consentmanager" => self::CONSENTMANAGER, - "cookiefirst" => self::COOKIEFIRST + "cookiefirst" => self::COOKIEFIRST, + "cookiebot" => self::COOKIEBOT, ]; } diff --git a/Application/views/admin/de/module_options.php b/Application/views/admin/de/module_options.php index 8960fd6..144a01f 100755 --- a/Application/views/admin/de/module_options.php +++ b/Application/views/admin/de/module_options.php @@ -43,5 +43,6 @@ $aLang = [ '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_COOKIEFIRST' => 'cookiefirst', + 'SHOP_MODULE_d3_gtm_settings_HAS_STD_MANAGER_COOKIEBOT' => 'Cookiebot', 'SHOP_MODULE_d3_gtm_settings_cookieName' => 'CookieID', ]; diff --git a/Modules/Core/ViewConfig.php b/Modules/Core/ViewConfig.php index 5df7d64..c066386 100644 --- a/Modules/Core/ViewConfig.php +++ b/Modules/Core/ViewConfig.php @@ -93,6 +93,7 @@ class ViewConfig extends ViewConfig_parent or $this->sCookieManagerType === ManagerTypes::USERCENTRICS_MANUALLY or $this->sCookieManagerType === ManagerTypes::CONSENTMANAGER or $this->sCookieManagerType === ManagerTypes::COOKIEFIRST + or $this->sCookieManagerType === ManagerTypes::COOKIEBOT or $this->sCookieManagerType === ManagerTypes::EXTERNAL_SERVICE ) { @@ -143,6 +144,10 @@ class ViewConfig extends ViewConfig_parent return 'type="text/plain" data-cookiefirst-category="' . $sCookieId .'"'; } + if ($this->sCookieManagerType === ManagerTypes::COOKIEBOT){ + return 'type="text/plain" data-cookieconsent="' . $sCookieId .'"'; + } + return ""; } diff --git a/metadata.php b/metadata.php index c31936c..31f10ef 100755 --- a/metadata.php +++ b/metadata.php @@ -144,7 +144,7 @@ $aModule = [ 'name' => 'd3_gtm_settings_HAS_STD_MANAGER', 'type' => 'select', 'value' => 'none', - 'constraints' => 'NONE|CONSENTMANAGER|USERCENTRICS|COOKIEFIRST', + 'constraints' => 'NONE|CONSENTMANAGER|USERCENTRICS|COOKIEFIRST|COOKIEBOT', ], ] ]; \ No newline at end of file From 99af4cdfa93fb8f3ab00deb71c432166346cb48f Mon Sep 17 00:00:00 2001 From: MaxBUhe Date: Thu, 7 Sep 2023 15:16:54 +0200 Subject: [PATCH 12/18] bump metadata && changelog --- CHANGELOG.md | 4 ++++ Docs/README.md | 5 ++++- metadata.php | 2 +- 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index cb728c8..557760a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,10 @@ 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/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## [1.12.0](https://git.d3data.de/D3Public/GoogleAnalytics4/compare/1.11.1...1.12.0) - 2023-09-07 +### Added +- cookiebot functionality + ## [1.11.1](https://git.d3data.de/D3Public/GoogleAnalytics4/compare/1.11.0...1.11.1) - 2023-08-17 ### Fixed - metadata class entry diff --git a/Docs/README.md b/Docs/README.md index 039c19d..2dd0dc2 100644 --- a/Docs/README.md +++ b/Docs/README.md @@ -77,4 +77,7 @@ Aktivieren Sie anschließend diese Weiche. Setzen Sie den Haken bei "Eigenen Coo - 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 \ No newline at end of file + ```Einstell. > Cookie Manager Einstellungen > Cookie-ID``` eintragen + +- [Cookiebot](https://www.cookiebot.com) + - Nähere Informationen folgen bald! Bis dato, besuchen Sie bitte die offizielle Webseite. \ No newline at end of file diff --git a/metadata.php b/metadata.php index 31f10ef..f9dbe07 100755 --- a/metadata.php +++ b/metadata.php @@ -28,7 +28,7 @@ $aModule = [ Die Entwicklung basiert auf einem Fork von Marat Bedoev - Github-Link ", 'thumbnail' => 'thumbnail.png', - 'version' => '1.11.0', + 'version' => '1.12.0', 'author' => 'Data Development (Inh.: Thomas Dartsch)', 'email' => 'support@shopmodule.com', 'url' => 'https://www.oxidmodule.com/', From 36ac641233e9e6e97bda21b45727631a813dcc1b Mon Sep 17 00:00:00 2001 From: MaxBUhe Date: Wed, 13 Sep 2023 14:42:12 +0200 Subject: [PATCH 13/18] adjust Doku with further infos new cookieid -> Control parameter --- Application/views/admin/de/module_options.php | 7 ++++++- Docs/CMP/consentmanager.md | 18 ++++++++++++++++++ Docs/README.md | 10 ++++++++++ 3 files changed, 34 insertions(+), 1 deletion(-) create mode 100644 Docs/CMP/consentmanager.md diff --git a/Application/views/admin/de/module_options.php b/Application/views/admin/de/module_options.php index 144a01f..42c908d 100755 --- a/Application/views/admin/de/module_options.php +++ b/Application/views/admin/de/module_options.php @@ -44,5 +44,10 @@ $aLang = [ '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_HAS_STD_MANAGER_COOKIEBOT' => 'Cookiebot', - 'SHOP_MODULE_d3_gtm_settings_cookieName' => 'CookieID', + 'SHOP_MODULE_d3_gtm_settings_cookieName' => 'Steuerungsparameter', + 'HELP_SHOP_MODULE_d3_gtm_settings_cookieName' => 'Nähere infos zum "Steuerungsparameter"
+ Beachte:
+ Sofern Sie die consentmanager CMP verwenden, + bitte ich Sie, gründlichst, die Hinweise der Moduldokumentation/Consentmanager zu lesen. + ' ]; diff --git a/Docs/CMP/consentmanager.md b/Docs/CMP/consentmanager.md new file mode 100644 index 0000000..264536b --- /dev/null +++ b/Docs/CMP/consentmanager.md @@ -0,0 +1,18 @@ +# Consentmanager +## 1. Steuerungsparameter +Tragen Sie hier die gewünschte ID des zu prüfenden Anbieters (Vendor-ID) ein.
+Diese ID finden Sie in Ihrem Consentmanager-Dashboard, links, unter "CMP > Anbieter". + +Nähere Informationen hierzu suchen Sie bitte auf der offiziellen Webseite von [app.consentmanager](https://help.consentmanager.de/books/cmp/page/4-configuring-vendors-and-cookies). + +## 2. Gebräuchliche ID's +- s26 (Google Analytics/ GA/ GA4) +- s905 (Google Tag Manager/ GTM) + +## 3. Einrichtung GTM +Die von Ihnen eingetragene ID muss oder ist schlussendlich die ID, auf die im GTM-Umfeld geprüft wird. +Das heißt, dass sich die Eintragung nach GTM, oder umgekehrt, richtet. + +### Unterstützung benötigt? +Kein Problem! +Kontaktieren Sie uns gern unter [d3data.de](https://www.d3data.de) \ No newline at end of file diff --git a/Docs/README.md b/Docs/README.md index 2dd0dc2..8df6e03 100644 --- a/Docs/README.md +++ b/Docs/README.md @@ -5,6 +5,13 @@ Die Einbindung dieser Event-Templates erfolgt über TPL-Blöcke unter `source/mo *Hinweis: nicht alle templates sind bereits gefüllt. Wünschen Sie die Implementierung eines unausgefüllten templates? Kommen Sie auf uns zu unter https://www.d3data.de/ +## Steuerungsparameter +Tragen Sie hier im Normalfall die ID des zu prüfenden Cookies ein. +In bestimmten Fällen, müssen Sie hier alternative Werte eintragen. Diese Fälle sind bedingt +nach der gewählten CMP (Consent Manager Platform). + +> nähere Infos unter [CMP](#consent-manager-platform-cmp) + ## Blöcke Für den geregelten Ablauf sind folgende Blöcke nötig: - Suchergebnisse @@ -54,6 +61,9 @@ Dann tragen Sie in den Folgeeinstellungen unter "Cookie Manager Einstellungen", die Cookie-ID des zugehörigen Cookies ein. Aktivieren Sie anschließend diese Weiche. Setzen Sie den Haken bei "Eigenen Cookie Manager nutzen?". +## Consent Manager Platform (CMP) +- [Consentmanager](https://git.d3data.de/D3Public/GoogleAnalytics4/src/branch/master/Docs/CMP/consentmanager.md) + ### Unterstützung für - [aggrosoft - oxid-cookie-compliance](https://github.com/aggrosoft/oxid-cookie-compliance) - https://github.com/aggrosoft/oxid-cookie-compliance From b2d8d597fddb53d790421900b8a71739eb104d40 Mon Sep 17 00:00:00 2001 From: MaxBUhe Date: Wed, 13 Sep 2023 14:56:05 +0200 Subject: [PATCH 14/18] switch name of control-parameter; switch consentmanager-script-adjustments # Conflicts: # Modules/Core/ViewConfig.php --- Modules/Core/ViewConfig.php | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/Modules/Core/ViewConfig.php b/Modules/Core/ViewConfig.php index c066386..1ab7217 100644 --- a/Modules/Core/ViewConfig.php +++ b/Modules/Core/ViewConfig.php @@ -18,6 +18,10 @@ use OxidEsales\Eshop\Application\Controller\FrontendController; use OxidEsales\Eshop\Core\Config; use OxidEsales\Eshop\Core\Registry; + + + + class ViewConfig extends ViewConfig_parent { @@ -112,7 +116,7 @@ class ViewConfig extends ViewConfig_parent */ public function getGtmScriptAttributes() :string { - $sCookieId = trim(Registry::getConfig()->getConfigParam('d3_gtm_settings_cookieName')); + $sControlParameter = trim(Registry::getConfig()->getConfigParam('d3_gtm_settings_cookieName')); if (false === $this->shallUseOwnCookieManager()){ return ""; @@ -123,29 +127,24 @@ class ViewConfig extends ViewConfig_parent or $this->sCookieManagerType === ManagerTypes::USERCENTRICS_MANUALLY ) { - if ($sCookieId) { - return 'data-usercentrics="' . $sCookieId . '" type="text/plain" async=""'; + if ($sControlParameter) { + return 'data-usercentrics="' . $sControlParameter . '" type="text/plain" async=""'; } } if ($this->sCookieManagerType === ManagerTypes::CONSENTMANAGER) { - if ($sCookieId) { - return 'async - type="text/plain" - data-cmp-src="https://www.googletagmanager.com/gtm.js?id='.$this->getGtmContainerId().'" - class="cmplazyload" - data-cmp-vendor="s905" - '; + if ($sControlParameter) { + return 'type="text/plain" class="cmplazyload" data-cmp-vendor="'.$sControlParameter.'"'; } } if ($this->sCookieManagerType === ManagerTypes::COOKIEFIRST){ - return 'type="text/plain" data-cookiefirst-category="' . $sCookieId .'"'; + return 'type="text/plain" data-cookiefirst-category="' . $sControlParameter .'"'; } if ($this->sCookieManagerType === ManagerTypes::COOKIEBOT){ - return 'type="text/plain" data-cookieconsent="' . $sCookieId .'"'; + return 'type="text/plain" data-cookieconsent="' . $sControlParameter .'"'; } return ""; @@ -153,6 +152,7 @@ class ViewConfig extends ViewConfig_parent private $blGA4enabled = null; + public function isGA4enabled() { if ($this->blGA4enabled === null) From f64eb35763db752fbc7365214f7e0a23397a4d3f Mon Sep 17 00:00:00 2001 From: MaxBUhe Date: Wed, 13 Sep 2023 15:09:27 +0200 Subject: [PATCH 15/18] switch control-param name --- Application/views/admin/de/module_options.php | 4 ++-- Modules/Core/ViewConfig.php | 8 ++++---- metadata.php | 2 +- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/Application/views/admin/de/module_options.php b/Application/views/admin/de/module_options.php index 42c908d..555ae53 100755 --- a/Application/views/admin/de/module_options.php +++ b/Application/views/admin/de/module_options.php @@ -44,8 +44,8 @@ $aLang = [ '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_HAS_STD_MANAGER_COOKIEBOT' => 'Cookiebot', - 'SHOP_MODULE_d3_gtm_settings_cookieName' => 'Steuerungsparameter', - 'HELP_SHOP_MODULE_d3_gtm_settings_cookieName' => 'Nähere infos zum "Steuerungsparameter"
+ 'SHOP_MODULE_d3_gtm_settings_controlParameter' => 'Steuerungsparameter', + 'HELP_SHOP_MODULE_d3_gtm_settings_controlParameter' => 'Nähere infos zum "Steuerungsparameter"
Beachte:
Sofern Sie die consentmanager CMP verwenden, bitte ich Sie, gründlichst, die Hinweise der Moduldokumentation/Consentmanager zu lesen. diff --git a/Modules/Core/ViewConfig.php b/Modules/Core/ViewConfig.php index 1ab7217..c0cf07f 100644 --- a/Modules/Core/ViewConfig.php +++ b/Modules/Core/ViewConfig.php @@ -33,7 +33,7 @@ class ViewConfig extends ViewConfig_parent { if ($this->sContainerId === null) { - $this->sContainerId = $this->getConfig()->getConfigParam('d3_gtm_sContainerID'); + $this->sContainerId = Registry::getConfig()->getConfigParam('d3_gtm_sContainerID'); } return $this->sContainerId; } @@ -74,7 +74,7 @@ class ViewConfig extends ViewConfig_parent $this->defineCookieManagerType(); - $sCookieID = trim($oConfig->getConfigParam('d3_gtm_settings_cookieName')); + $sCookieID = trim($oConfig->getConfigParam('d3_gtm_settings_controlParameter')); // Netensio Cookie Manager if ($this->sCookieManagerType === ManagerTypes::NET_COOKIE_MANAGER) { @@ -116,7 +116,7 @@ class ViewConfig extends ViewConfig_parent */ public function getGtmScriptAttributes() :string { - $sControlParameter = trim(Registry::getConfig()->getConfigParam('d3_gtm_settings_cookieName')); + $sControlParameter = trim(Registry::getConfig()->getConfigParam('d3_gtm_settings_controlParameter')); if (false === $this->shallUseOwnCookieManager()){ return ""; @@ -157,7 +157,7 @@ class ViewConfig extends ViewConfig_parent { if ($this->blGA4enabled === null) { - $this->sContainerId = $this->getConfig()->getConfigParam('d3_gtm_blEnableGA4'); + $this->sContainerId = Registry::getConfig()->getConfigParam('d3_gtm_blEnableGA4'); } return $this->blGA4enabled; diff --git a/metadata.php b/metadata.php index f9dbe07..0d6ec7b 100755 --- a/metadata.php +++ b/metadata.php @@ -134,7 +134,7 @@ $aModule = [ ], [ 'group' => 'd3_gtm_settings_cookiemanager', - 'name' => 'd3_gtm_settings_cookieName', + 'name' => 'd3_gtm_settings_controlParameter', 'type' => 'str', 'value' => 'example', 'position' => 999 From 6fcee0671f50d3d3f6b13390216f0c9dad7198f3 Mon Sep 17 00:00:00 2001 From: MaxBUhe Date: Wed, 13 Sep 2023 15:13:35 +0200 Subject: [PATCH 16/18] adjust set-param check --- Modules/Core/ViewConfig.php | 10 +++------- metadata.php | 2 +- 2 files changed, 4 insertions(+), 8 deletions(-) diff --git a/Modules/Core/ViewConfig.php b/Modules/Core/ViewConfig.php index c0cf07f..4c0bc76 100644 --- a/Modules/Core/ViewConfig.php +++ b/Modules/Core/ViewConfig.php @@ -118,7 +118,7 @@ class ViewConfig extends ViewConfig_parent { $sControlParameter = trim(Registry::getConfig()->getConfigParam('d3_gtm_settings_controlParameter')); - if (false === $this->shallUseOwnCookieManager()){ + if (false === $this->shallUseOwnCookieManager() or ($sControlParameter === '')){ return ""; } @@ -127,16 +127,12 @@ class ViewConfig extends ViewConfig_parent or $this->sCookieManagerType === ManagerTypes::USERCENTRICS_MANUALLY ) { - if ($sControlParameter) { - return 'data-usercentrics="' . $sControlParameter . '" type="text/plain" async=""'; - } + return 'data-usercentrics="' . $sControlParameter . '" type="text/plain" async=""'; } if ($this->sCookieManagerType === ManagerTypes::CONSENTMANAGER) { - if ($sControlParameter) { - return 'type="text/plain" class="cmplazyload" data-cmp-vendor="'.$sControlParameter.'"'; - } + return 'type="text/plain" class="cmplazyload" data-cmp-vendor="'.$sControlParameter.'"'; } if ($this->sCookieManagerType === ManagerTypes::COOKIEFIRST){ diff --git a/metadata.php b/metadata.php index 0d6ec7b..1868be2 100755 --- a/metadata.php +++ b/metadata.php @@ -136,7 +136,7 @@ $aModule = [ 'group' => 'd3_gtm_settings_cookiemanager', 'name' => 'd3_gtm_settings_controlParameter', 'type' => 'str', - 'value' => 'example', + 'value' => '', 'position' => 999 ], [ From da2966626eef45528dd2c681f98d2eb1f2f0021a Mon Sep 17 00:00:00 2001 From: MaxBUhe Date: Wed, 13 Sep 2023 15:15:49 +0200 Subject: [PATCH 17/18] cleaning; adjust not set param handling --- Modules/Core/ViewConfig.php | 5 ----- 1 file changed, 5 deletions(-) diff --git a/Modules/Core/ViewConfig.php b/Modules/Core/ViewConfig.php index 4c0bc76..c3fb415 100644 --- a/Modules/Core/ViewConfig.php +++ b/Modules/Core/ViewConfig.php @@ -17,11 +17,6 @@ use D3\GoogleAnalytics4\Application\Model\ManagerTypes; use OxidEsales\Eshop\Application\Controller\FrontendController; use OxidEsales\Eshop\Core\Config; use OxidEsales\Eshop\Core\Registry; - - - - - class ViewConfig extends ViewConfig_parent { From 5c98d99d80269a8d8de4df288161685f34067cf8 Mon Sep 17 00:00:00 2001 From: MaxBUhe Date: Wed, 13 Sep 2023 16:02:49 +0200 Subject: [PATCH 18/18] bump metadata && changelog --- CHANGELOG.md | 9 +++++++++ metadata.php | 2 +- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 557760a..d1a2c51 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,15 @@ 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/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## [1.13.0](https://git.d3data.de/D3Public/GoogleAnalytics4/compare/1.12.0...1.13.0) - 2023-09-13 +### Added +- extended Docs +### Changed +- control-param name +- control-param function +- adjusted check for set control-param +- consentmanager-script-adjustments + ## [1.12.0](https://git.d3data.de/D3Public/GoogleAnalytics4/compare/1.11.1...1.12.0) - 2023-09-07 ### Added - cookiebot functionality diff --git a/metadata.php b/metadata.php index 1868be2..167f1b7 100755 --- a/metadata.php +++ b/metadata.php @@ -28,7 +28,7 @@ $aModule = [ Die Entwicklung basiert auf einem Fork von Marat Bedoev - Github-Link ", 'thumbnail' => 'thumbnail.png', - 'version' => '1.12.0', + 'version' => '1.13.0', 'author' => 'Data Development (Inh.: Thomas Dartsch)', 'email' => 'support@shopmodule.com', 'url' => 'https://www.oxidmodule.com/',