From 7bc73893c38b95059cea08afad9628d3184f05cd Mon Sep 17 00:00:00 2001 From: MarkusGaertner Date: Thu, 8 Aug 2024 10:21:22 +0200 Subject: [PATCH 01/12] Prevent "OXID Logger.ERROR: D3\GoogleAnalytics4\Modules\Application\Controller\d3GtmStartController is not an instance of OxidEsales\Eshop\Application\Component\Widget\WidgetController" --- .../Component/Widget/d3GtmStartWidget.php | 10 ++++ Modules/Core/WidgetControl.php | 59 +++++++++++++++++++ metadata.php | 1 + 3 files changed, 70 insertions(+) create mode 100644 Application/Component/Widget/d3GtmStartWidget.php create mode 100644 Modules/Core/WidgetControl.php diff --git a/Application/Component/Widget/d3GtmStartWidget.php b/Application/Component/Widget/d3GtmStartWidget.php new file mode 100644 index 0000000..9403e84 --- /dev/null +++ b/Application/Component/Widget/d3GtmStartWidget.php @@ -0,0 +1,10 @@ + '2pistlaubiq58qtg3moudei0la', + 'lang' => '0', + 'actcontrol' => 'details', + 'anid' => '064471', + 'cl' => 'oxwarticledetails', + 'cnid' => '159dd0f2fb2bd6e24ace53a0f1913797', + 'listtype' => 'list', + 'nocookie' => '1', + 'oxwparent' => 'details', + 'sid' => '2pistlaubiq58qtg3moudei0la', + 'stoken' => 'A22D0F9E', + 'varselid' => + array ( + 0 => 'b842982bf522aa839bd88221f562fce8', + ), + ) + */ + + $aParameter = $_GET; + if( is_null($aParameter['actcontrol']) + && is_null($aParameter['actcontrol']) + && is_null($aParameter['actcontrol']) + ) + { + return 'D3\GoogleAnalytics4\Application\Component\Widget\d3GtmStartWidget'; + } + + return $this->getStartControllerKey(); + } + + protected function getStartControllerKey() + { + $controllerKey = Registry::getConfig()->getRequestControllerId(); + + // Use default route in case no controller id is given + if (!$controllerKey) { + $session = \OxidEsales\Eshop\Core\Registry::getSession(); + if ($this->isAdmin()) { + $controllerKey = $session->getVariable("auth") ? 'admin_start' : 'login'; + } else { + $controllerKey = $this->getFrontendStartControllerKey(); + } + $session->setVariable('cl', $controllerKey); + } + + return $controllerKey; + } +} \ No newline at end of file diff --git a/metadata.php b/metadata.php index 9addf64..4c311a9 100755 --- a/metadata.php +++ b/metadata.php @@ -60,6 +60,7 @@ $aModule = [ 'extend' => [ // Core OEViewConfig::class => ViewConfig::class, + \OxidEsales\Eshop\Core\WidgetControl::class => \D3\GoogleAnalytics4\Modules\Core\WidgetControl::class, // Model OECategory::class => Category::class, From 2a1f8f57949c78260520335e71bbb10e404e62d3 Mon Sep 17 00:00:00 2001 From: MarkusGaertner Date: Thu, 8 Aug 2024 10:36:55 +0200 Subject: [PATCH 02/12] Erweiterung verschieben --- Modules/Core/{WidgetControl.php => ShopControl.php} | 2 +- metadata.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) rename Modules/Core/{WidgetControl.php => ShopControl.php} (97%) diff --git a/Modules/Core/WidgetControl.php b/Modules/Core/ShopControl.php similarity index 97% rename from Modules/Core/WidgetControl.php rename to Modules/Core/ShopControl.php index b4c20c7..eeb04e5 100644 --- a/Modules/Core/WidgetControl.php +++ b/Modules/Core/ShopControl.php @@ -4,7 +4,7 @@ namespace D3\GoogleAnalytics4\Modules\Core; use OxidEsales\EshopCommunity\Core\Registry; -class WidgetControl extends WidgetControl_parent{ +class ShopControl extends ShopControl_parent{ protected function _getStartController() // phpcs:ignore PSR2.Methods.MethodDeclaration.Underscore { /* diff --git a/metadata.php b/metadata.php index 4c311a9..1de6d53 100755 --- a/metadata.php +++ b/metadata.php @@ -60,7 +60,7 @@ $aModule = [ 'extend' => [ // Core OEViewConfig::class => ViewConfig::class, - \OxidEsales\Eshop\Core\WidgetControl::class => \D3\GoogleAnalytics4\Modules\Core\WidgetControl::class, + \OxidEsales\Eshop\Core\ShopControl::class => \D3\GoogleAnalytics4\Modules\Core\ShopControl::class, // Model OECategory::class => Category::class, From bc1dafbbfaec6ee35f8815989c9ff03e45054f29 Mon Sep 17 00:00:00 2001 From: MarkusGaertner Date: Thu, 8 Aug 2024 14:16:25 +0200 Subject: [PATCH 03/12] Erweiterung verschieben --- .../{ShopControl.php => WidgetControl.php} | 33 ++++++------------- metadata.php | 2 +- 2 files changed, 11 insertions(+), 24 deletions(-) rename Modules/Core/{ShopControl.php => WidgetControl.php} (55%) diff --git a/Modules/Core/ShopControl.php b/Modules/Core/WidgetControl.php similarity index 55% rename from Modules/Core/ShopControl.php rename to Modules/Core/WidgetControl.php index eeb04e5..ce6940b 100644 --- a/Modules/Core/ShopControl.php +++ b/Modules/Core/WidgetControl.php @@ -4,7 +4,7 @@ namespace D3\GoogleAnalytics4\Modules\Core; use OxidEsales\EshopCommunity\Core\Registry; -class ShopControl extends ShopControl_parent{ +class WidgetControl extends WidgetControl_parent{ protected function _getStartController() // phpcs:ignore PSR2.Methods.MethodDeclaration.Underscore { /* @@ -27,33 +27,20 @@ class ShopControl extends ShopControl_parent{ ) */ + $sScriptName = $_SERVER['SCRIPT_NAME']; + if($sScriptName != '/widget.php') + { + return parent::getFrontendStartControllerKey(); + } + $aParameter = $_GET; - if( is_null($aParameter['actcontrol']) - && is_null($aParameter['actcontrol']) + if(is_null($aParameter['actcontrol']) && is_null($aParameter['actcontrol']) + && is_null($aParameter['oxwparent']) ) { return 'D3\GoogleAnalytics4\Application\Component\Widget\d3GtmStartWidget'; } - - return $this->getStartControllerKey(); - } - - protected function getStartControllerKey() - { - $controllerKey = Registry::getConfig()->getRequestControllerId(); - - // Use default route in case no controller id is given - if (!$controllerKey) { - $session = \OxidEsales\Eshop\Core\Registry::getSession(); - if ($this->isAdmin()) { - $controllerKey = $session->getVariable("auth") ? 'admin_start' : 'login'; - } else { - $controllerKey = $this->getFrontendStartControllerKey(); - } - $session->setVariable('cl', $controllerKey); - } - - return $controllerKey; + return parent::getFrontendStartControllerKey(); } } \ No newline at end of file diff --git a/metadata.php b/metadata.php index 1de6d53..4c311a9 100755 --- a/metadata.php +++ b/metadata.php @@ -60,7 +60,7 @@ $aModule = [ 'extend' => [ // Core OEViewConfig::class => ViewConfig::class, - \OxidEsales\Eshop\Core\ShopControl::class => \D3\GoogleAnalytics4\Modules\Core\ShopControl::class, + \OxidEsales\Eshop\Core\WidgetControl::class => \D3\GoogleAnalytics4\Modules\Core\WidgetControl::class, // Model OECategory::class => Category::class, From 48a598da515b77b552fe060e57296d5e4bd64345 Mon Sep 17 00:00:00 2001 From: MarkusGaertner Date: Thu, 8 Aug 2024 15:03:48 +0200 Subject: [PATCH 04/12] =?UTF-8?q?render()=20erg=C3=A4nzen?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Application/Component/Widget/d3GtmStartWidget.php | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/Application/Component/Widget/d3GtmStartWidget.php b/Application/Component/Widget/d3GtmStartWidget.php index 9403e84..92a7a79 100644 --- a/Application/Component/Widget/d3GtmStartWidget.php +++ b/Application/Component/Widget/d3GtmStartWidget.php @@ -6,5 +6,10 @@ namespace D3\GoogleAnalytics4\Application\Component\Widget; class d3GtmStartWidget extends \OxidEsales\Eshop\Application\Component\Widget\WidgetController { + public function render() + { + parent::render(); + return ''; + } } \ No newline at end of file From 98ddc51a4d80073240ee087cee3102499fd99d7c Mon Sep 17 00:00:00 2001 From: MaxBuhe01 Date: Sun, 18 Aug 2024 16:40:49 +0200 Subject: [PATCH 05/12] [Changed] clean code --- Modules/Core/WidgetControl.php | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/Modules/Core/WidgetControl.php b/Modules/Core/WidgetControl.php index ce6940b..f79c6c2 100644 --- a/Modules/Core/WidgetControl.php +++ b/Modules/Core/WidgetControl.php @@ -28,19 +28,17 @@ class WidgetControl extends WidgetControl_parent{ */ $sScriptName = $_SERVER['SCRIPT_NAME']; - if($sScriptName != '/widget.php') + if($sScriptName !== '/widget.php') { return parent::getFrontendStartControllerKey(); } $aParameter = $_GET; - if(is_null($aParameter['actcontrol']) - && is_null($aParameter['actcontrol']) - && is_null($aParameter['oxwparent']) - ) + if(is_null($aParameter['actcontrol']) and is_null($aParameter['oxwparent'])) { return 'D3\GoogleAnalytics4\Application\Component\Widget\d3GtmStartWidget'; } + return parent::getFrontendStartControllerKey(); } } \ No newline at end of file From 6bdf788ebf9916253e51cc33a347f8887fefa561 Mon Sep 17 00:00:00 2001 From: MaxBuhe01 Date: Tue, 20 Aug 2024 18:59:14 +0200 Subject: [PATCH 06/12] [Added] new Event "begin_checkout" - new block extension - new template for the event-data for GA - metadata adjustments for it - new version ( 2.20.0 ) --- Application/views/blocks/begin_checkout.tpl | 3 ++ Application/views/event/add_payment_info.tpl | 0 Application/views/event/begin_checkout.tpl | 51 ++++++++++++++++++++ CHANGELOG.md | 4 ++ metadata.php | 51 ++++++++++++-------- 5 files changed, 88 insertions(+), 21 deletions(-) create mode 100644 Application/views/blocks/begin_checkout.tpl create mode 100644 Application/views/event/add_payment_info.tpl create mode 100644 Application/views/event/begin_checkout.tpl diff --git a/Application/views/blocks/begin_checkout.tpl b/Application/views/blocks/begin_checkout.tpl new file mode 100644 index 0000000..de52b5f --- /dev/null +++ b/Application/views/blocks/begin_checkout.tpl @@ -0,0 +1,3 @@ +[{$smarty.block.parent}] + +[{include file="event/begin_checkout.tpl"}] \ No newline at end of file diff --git a/Application/views/event/add_payment_info.tpl b/Application/views/event/add_payment_info.tpl new file mode 100644 index 0000000..e69de29 diff --git a/Application/views/event/begin_checkout.tpl b/Application/views/event/begin_checkout.tpl new file mode 100644 index 0000000..8be3d14 --- /dev/null +++ b/Application/views/event/begin_checkout.tpl @@ -0,0 +1,51 @@ +[{*$oxcmp_basket|get_class_methods|dumpvar*}] + +[{assign var="d3BasketPrice" value=$oxcmp_basket->getPrice()}] +[{assign var="d3BasketObject" value=$oxcmp_basket}] +[{assign var='gtmCartArticles' value=$d3BasketObject->getBasketArticles()}] + +[{block name="d3_ga4_begin_checkout_block"}] + [{capture name="d3_ga4_begin_checkout"}] + [{strip}] + dataLayer.push({"event": null, "eventLabel": null, "ecommerce": null}); /* Clear the previous ecommerce object. */ + dataLayer.push({ + 'event': 'begin_checkout', + 'eventLabel':'Begin of checkout', + 'ecommerce': + { + 'actionField': "Begin", + '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, true)}]', + 'item_category_2': '[{$gtmBasketItemCategory->getSplitCategoryArray(1, true)}]', + 'item_category_3': '[{$gtmBasketItemCategory->getSplitCategoryArray(2, true)}]', + 'item_category_4': '[{$gtmBasketItemCategory->getSplitCategoryArray(3, true)}]', + '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=$smarty.capture.d3_ga4_begin_checkout}] +[{/block}] \ No newline at end of file diff --git a/CHANGELOG.md b/CHANGELOG.md index aa7cf0b..8ee449a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [unreleased](https://git.d3data.de/D3Public/GoogleAnalytics4/compare/2.17.2...rel_2.x) - 2024-x +## [2.20.0](https://git.d3data.de/D3Public/GoogleAnalytics4/compare/2.19.0...2.20.0) - 2024-08-20 +### Added +- new event "begin_checkout" + ## [2.19.0](https://git.d3data.de/D3Public/GoogleAnalytics4/compare/2.18.2...2.19.0) - 2024-08-10 ### Fixed - usage of not yet existing function diff --git a/metadata.php b/metadata.php index 0f88d92..b1cfeb3 100755 --- a/metadata.php +++ b/metadata.php @@ -50,7 +50,7 @@ $aModule = [ Die Entwicklung basiert auf einem Fork von Marat Bedoev - Github-Link ", 'thumbnail' => 'thumbnail.png', - 'version' => '2.19.0', + 'version' => 'DEV-2.20.0', 'author' => 'Data Development (Inh.: Thomas Dartsch)', 'email' => 'support@shopmodule.com', 'url' => 'https://www.oxidmodule.com/', @@ -84,13 +84,14 @@ $aModule = [ ], 'templates' => [ // Event files that store the GA4 Event-Information - 'event/add_to_cart.tpl' => 'd3/googleanalytics4/Application/views/event/add_to_cart.tpl', - 'event/view_item.tpl' => 'd3/googleanalytics4/Application/views/event/view_item.tpl', - 'event/view_cart.tpl' => 'd3/googleanalytics4/Application/views/event/view_cart.tpl', - 'event/purchase.tpl' => 'd3/googleanalytics4/Application/views/event/purchase.tpl', - 'event/view_item_list.tpl' => 'd3/googleanalytics4/Application/views/event/view_item_list.tpl', - 'event/view_search_result.tpl' => 'd3/googleanalytics4/Application/views/event/view_search_result.tpl', - 'event/remove_from_cart.tpl' => 'd3/googleanalytics4/Application/views/event/remove_from_cart.tpl', + 'event/add_to_cart.tpl' => 'd3/googleanalytics4/Application/views/event/add_to_cart.tpl', + 'event/view_item.tpl' => 'd3/googleanalytics4/Application/views/event/view_item.tpl', + 'event/view_item.tpl' => 'd3/googleanalytics4/Application/views/event/view_item.tpl', + 'event/begin_checkout.tpl' => 'd3/googleanalytics4/Application/views/event/begin_checkout.tpl', + 'event/purchase.tpl' => 'd3/googleanalytics4/Application/views/event/purchase.tpl', + 'event/view_item_list.tpl' => 'd3/googleanalytics4/Application/views/event/view_item_list.tpl', + 'event/view_search_result.tpl' => 'd3/googleanalytics4/Application/views/event/view_search_result.tpl', + 'event/remove_from_cart.tpl' => 'd3/googleanalytics4/Application/views/event/remove_from_cart.tpl', // complete overwritten file of OXID-Originals // the path of the template-name is the original path to the file in OXID-context from tpl/-> @@ -123,12 +124,26 @@ $aModule = [ 'file' => '/Application/views/blocks/view_item.tpl', 'position' => 150 ], - // checkout + // View Cart [ 'template' => 'page/checkout/basket.tpl', 'block' => 'checkout_basket_main', 'file' => '/Application/views/blocks/view_cart.tpl' ], + // add_to_cart + [ + 'template' => 'page/details/inc/productmain.tpl', + 'block' => 'details_productmain_tobasket', + 'file' => '/Application/views/blocks/details_productmain_tobasket.tpl', + 'position' => 150 + ], + // remove_from_cart + [ + 'template' => 'page/checkout/basket.tpl', + 'block' => 'checkout_basket_main', + 'file' => '/Application/views/blocks/remove_from_cart.tpl', + 'position' => 150 + ], [ 'template' => 'page/checkout/thankyou.tpl', 'block' => 'checkout_thankyou_main', @@ -149,13 +164,6 @@ $aModule = [ 'file' => '/Application/views/blocks/view_search_result.tpl', 'position' => 150 ], - // add_to_cart - [ - 'template' => 'page/details/inc/productmain.tpl', - 'block' => 'details_productmain_tobasket', - 'file' => '/Application/views/blocks/details_productmain_tobasket.tpl', - 'position' => 150 - ], [ 'template' => 'page/list/list.tpl', 'block' => 'page_list_listbody', @@ -168,13 +176,14 @@ $aModule = [ 'file' => '/Application/views/blocks/start_welcome_text.tpl', 'position' => 150 ], - // remove_from_cart + // Checkout process + // Begin CHeckout [ - 'template' => 'page/checkout/basket.tpl', - 'block' => 'checkout_basket_main', - 'file' => '/Application/views/blocks/remove_from_cart.tpl', + 'template' => 'page/checkout/user.tpl', + 'block' => 'checkout_user_main', + 'file' => '/Application/views/blocks/begin_checkout.tpl', 'position' => 150 - ] + ], ], 'events' => [ 'onActivate' => '\D3\GoogleAnalytics4\Setup\Events::onActivate', From 79994eae69afe49cec2423dfcffdb1edf7453314 Mon Sep 17 00:00:00 2001 From: MaxBuhe01 Date: Tue, 20 Aug 2024 19:58:02 +0200 Subject: [PATCH 07/12] [Added] new Event "add_payment_info" - add Payment-Model extension for own small method - new block extension - new template for the event-data for GA - metadata adjustments for it --- Application/views/blocks/add_payment_info.tpl | 3 + Application/views/event/add_payment_info.tpl | 53 +++++++ CHANGELOG.md | 1 + IntelliSenseHelper.php | 5 + Modules/Application/Model/gtmPayment.php | 20 +++ metadata.php | 147 ++++++++++-------- 6 files changed, 162 insertions(+), 67 deletions(-) create mode 100644 Application/views/blocks/add_payment_info.tpl create mode 100644 Modules/Application/Model/gtmPayment.php diff --git a/Application/views/blocks/add_payment_info.tpl b/Application/views/blocks/add_payment_info.tpl new file mode 100644 index 0000000..e6a2f18 --- /dev/null +++ b/Application/views/blocks/add_payment_info.tpl @@ -0,0 +1,3 @@ +[{$smarty.block.parent}] + +[{include file="event/add_payment_info.tpl"}] \ No newline at end of file diff --git a/Application/views/event/add_payment_info.tpl b/Application/views/event/add_payment_info.tpl index e69de29..f79bddb 100644 --- a/Application/views/event/add_payment_info.tpl +++ b/Application/views/event/add_payment_info.tpl @@ -0,0 +1,53 @@ +[{*$oxcmp_basket|get_class_methods|dumpvar*}] + +[{assign var="gtmBasketPrice" value=$oxcmp_basket->getPrice()}] +[{assign var="gtmBasketObject" value=$oxcmp_basket}] +[{assign var='gtmCartArticles' value=$gtmBasketObject->getBasketArticles()}] +[{assign var="gtmPaymentObject" value=$oView->getPayment()}] + +[{block name="gtm_ga4_add_payment_info_block"}] + [{capture name="gtm_ga4_add_payment_info"}] + [{strip}] + dataLayer.push({"event": null, "eventLabel": null, "ecommerce": null}); /* Clear the previous ecommerce object. */ + dataLayer.push({ + 'event': 'add_payment_info', + 'eventLabel':'Checkout - Payment info', + 'payment_type':'[{$gtmPaymentObject->gtmGetSelectedPaymentName()}]', + 'ecommerce': + { + 'actionField': "Payment-Info", + 'currency': "[{$currency->name}]", + 'value': [{$gtmBasketPrice->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="gtmItemPriceObject" 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, true)}]', + 'item_category_2': '[{$gtmBasketItemCategory->getSplitCategoryArray(1, true)}]', + 'item_category_3': '[{$gtmBasketItemCategory->getSplitCategoryArray(2, true)}]', + 'item_category_4': '[{$gtmBasketItemCategory->getSplitCategoryArray(3, true)}]', + 'item_list_name': '[{$gtmBasketItemCategory->getSplitCategoryArray()}]', + [{/if}] + 'price': [{$gtmItemPriceObject->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=$smarty.capture.gtm_ga4_add_payment_info}] + [{/block}] \ No newline at end of file diff --git a/CHANGELOG.md b/CHANGELOG.md index 8ee449a..d98d45d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [2.20.0](https://git.d3data.de/D3Public/GoogleAnalytics4/compare/2.19.0...2.20.0) - 2024-08-20 ### Added - new event "begin_checkout" +- new event "add_payment_info" ## [2.19.0](https://git.d3data.de/D3Public/GoogleAnalytics4/compare/2.18.2...2.19.0) - 2024-08-10 ### Fixed diff --git a/IntelliSenseHelper.php b/IntelliSenseHelper.php index 4666e9e..5b71e72 100644 --- a/IntelliSenseHelper.php +++ b/IntelliSenseHelper.php @@ -18,9 +18,14 @@ namespace D3\GoogleAnalytics4\Modules\Core{ } namespace D3\GoogleAnalytics4\Modules\Application\Model{ + + use OxidEsales\Eshop\Application\Model\Payment; + class Category_parent extends \OxidEsales\Eshop\Application\Model\Category {} class Basket_parent extends \OxidEsales\Eshop\Application\Model\Basket {} class Manufacturer_parent extends \OxidEsales\Eshop\Application\Model\Manufacturer {} + + class gtmPayment_parent extends Payment {} } namespace D3\GoogleAnalytics4\Modules\Application\Controller{ diff --git a/Modules/Application/Model/gtmPayment.php b/Modules/Application/Model/gtmPayment.php new file mode 100644 index 0000000..b2baa61 --- /dev/null +++ b/Modules/Application/Model/gtmPayment.php @@ -0,0 +1,20 @@ +getFieldData('oxpayments__oxdesc')?: 'No payment name available'; + } +} \ No newline at end of file diff --git a/metadata.php b/metadata.php index b1cfeb3..aeced8b 100755 --- a/metadata.php +++ b/metadata.php @@ -16,6 +16,7 @@ use D3\GoogleAnalytics4\Modules\Application\Controller\d3GtmStartController; 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\gtmPayment as gtmPayment; use D3\GoogleAnalytics4\Modules\Application\Model\Manufacturer as Manufacturer; use D3\GoogleAnalytics4\Modules\Core\ViewConfig; use OxidEsales\Eshop\Application\Component\BasketComponent as OEBasketComponent; @@ -33,12 +34,13 @@ use OxidEsales\Eshop\Application\Controller\ThankYouController as OEThankYouCont 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\Application\Model\Payment as OEPayment; use OxidEsales\Eshop\Core\ViewConfig as OEViewConfig; $sMetadataVersion = '2.1'; -$aModule = [ - 'id' => Constants::OXID_MODULE_ID, - 'title' => 'Google Analytics 4', +$aModule = [ + 'id' => Constants::OXID_MODULE_ID, + 'title' => 'Google Analytics 4', 'description' => "Dieses Modul bietet die Möglichkeit in Ihrem OXID eShop (6.x) die neue 'Property' Google Analytics 4 (GA4) von Google zu integrieren.
Hierfür stehen Ihnen verschiedene 'templates' zur verfügung, @@ -49,144 +51,155 @@ $aModule = [
Die Entwicklung basiert auf einem Fork von Marat Bedoev - Github-Link ", - 'thumbnail' => 'thumbnail.png', - 'version' => 'DEV-2.20.0', - 'author' => 'Data Development (Inh.: Thomas Dartsch)', - 'email' => 'support@shopmodule.com', - 'url' => 'https://www.oxidmodule.com/', + 'thumbnail' => 'thumbnail.png', + 'version' => 'DEV-2.20.0', + 'author' => 'Data Development (Inh.: Thomas Dartsch)', + 'email' => 'support@shopmodule.com', + 'url' => 'https://www.oxidmodule.com/', 'controllers' => [ 'd3googleanalytics4_main' => GA4AdminUserInterfaceMainController::class ], - 'extend' => [ + 'extend' => [ // Core - OEViewConfig::class => ViewConfig::class, + OEViewConfig::class => ViewConfig::class, // Model - OECategory::class => Category::class, - OEBasket::class => Basket::class, - OEManufacturer::class => Manufacturer::class, + OECategory::class => Category::class, + OEBasket::class => Basket::class, + OEManufacturer::class => Manufacturer::class, + OEPayment::class => gtmPayment::class, // Controller - OEBasketController::class => BasketController::class, - OEThankYouController::class => ThankYouController::class, - OEArticleListController::class => ArticleListController_AddToCartHelpMethods::class, - OEArticleDetailsController::class => ArticleDetailsController::class, - OEAccountNoticeListController::class => d3GtmAccountNoticeListController::class, - OEAccountRecommlistController::class => d3GtmAccountRecommlistController::class, - OEAccountWishlistController::class => d3GtmAccountWishlistController::class, - OEStartController::class => d3GtmStartController::class, - OESearchController::class => d3GtmSearchController::class, - OEManufacturerListController::class => d3GtmManufacturerListController::class, + OEBasketController::class => BasketController::class, + OEThankYouController::class => ThankYouController::class, + OEArticleListController::class => ArticleListController_AddToCartHelpMethods::class, + OEArticleDetailsController::class => ArticleDetailsController::class, + OEAccountNoticeListController::class => d3GtmAccountNoticeListController::class, + OEAccountRecommlistController::class => d3GtmAccountRecommlistController::class, + OEAccountWishlistController::class => d3GtmAccountWishlistController::class, + OEStartController::class => d3GtmStartController::class, + OESearchController::class => d3GtmSearchController::class, + OEManufacturerListController::class => d3GtmManufacturerListController::class, // Component - OEArticleDetails::class => d3GtmWidgetArticleDetails::class, - OEBasketComponent::class => d3GtmBasketComponentExtension::class, + OEArticleDetails::class => d3GtmWidgetArticleDetails::class, + OEBasketComponent::class => d3GtmBasketComponentExtension::class, ], - 'templates' => [ + 'templates' => [ // Event files that store the GA4 Event-Information - 'event/add_to_cart.tpl' => 'd3/googleanalytics4/Application/views/event/add_to_cart.tpl', - 'event/view_item.tpl' => 'd3/googleanalytics4/Application/views/event/view_item.tpl', - 'event/view_item.tpl' => 'd3/googleanalytics4/Application/views/event/view_item.tpl', - 'event/begin_checkout.tpl' => 'd3/googleanalytics4/Application/views/event/begin_checkout.tpl', - 'event/purchase.tpl' => 'd3/googleanalytics4/Application/views/event/purchase.tpl', - 'event/view_item_list.tpl' => 'd3/googleanalytics4/Application/views/event/view_item_list.tpl', - 'event/view_search_result.tpl' => 'd3/googleanalytics4/Application/views/event/view_search_result.tpl', - 'event/remove_from_cart.tpl' => 'd3/googleanalytics4/Application/views/event/remove_from_cart.tpl', + 'event/add_to_cart.tpl' => 'd3/googleanalytics4/Application/views/event/add_to_cart.tpl', + 'event/view_item.tpl' => 'd3/googleanalytics4/Application/views/event/view_item.tpl', + 'event/view_item.tpl' => 'd3/googleanalytics4/Application/views/event/view_item.tpl', + 'event/begin_checkout.tpl' => 'd3/googleanalytics4/Application/views/event/begin_checkout.tpl', + 'event/add_payment_info.tpl' => 'd3/googleanalytics4/Application/views/event/add_payment_info.tpl', + 'event/purchase.tpl' => 'd3/googleanalytics4/Application/views/event/purchase.tpl', + 'event/view_item_list.tpl' => 'd3/googleanalytics4/Application/views/event/view_item_list.tpl', + 'event/view_search_result.tpl' => 'd3/googleanalytics4/Application/views/event/view_search_result.tpl', + 'event/remove_from_cart.tpl' => 'd3/googleanalytics4/Application/views/event/remove_from_cart.tpl', // complete overwritten file of OXID-Originals // the path of the template-name is the original path to the file in OXID-context from tpl/-> - 'page/account/d3gtmnoticelist.tpl' => 'd3/googleanalytics4/Application/views/tpl/page/account/d3gtmnoticelist.tpl', - 'page/account/d3gtmrecommendationlist.tpl' => 'd3/googleanalytics4/Application/views/tpl/page/account/d3gtmrecommendationlist.tpl', - 'page/account/d3gtmwishlist.tpl' => 'd3/googleanalytics4/Application/views/tpl/page/account/d3gtmwishlist.tpl', + 'page/account/d3gtmnoticelist.tpl' => 'd3/googleanalytics4/Application/views/tpl/page/account/d3gtmnoticelist.tpl', + 'page/account/d3gtmrecommendationlist.tpl' => 'd3/googleanalytics4/Application/views/tpl/page/account/d3gtmrecommendationlist.tpl', + 'page/account/d3gtmwishlist.tpl' => 'd3/googleanalytics4/Application/views/tpl/page/account/d3gtmwishlist.tpl', // Admin Templates - 'ga4/admin/d3ga4uimain.tpl' => 'd3/googleanalytics4/Application/views/admin/tpl/d3googleanalytics4_main.tpl', - 'ga4/admin/d3ga4uiheaditem.tpl' => 'd3/googleanalytics4/Application/views/admin/tpl/d3googleanalytics4_headitem.tpl', + 'ga4/admin/d3ga4uimain.tpl' => 'd3/googleanalytics4/Application/views/admin/tpl/d3googleanalytics4_main.tpl', + 'ga4/admin/d3ga4uiheaditem.tpl' => 'd3/googleanalytics4/Application/views/admin/tpl/d3googleanalytics4_headitem.tpl', ], - 'blocks' => [ + 'blocks' => [ // tag manager js [ 'template' => 'layout/base.tpl', - 'block' => 'head_meta_robots', - 'file' => '/Application/views/blocks/_gtm_js.tpl', + 'block' => 'head_meta_robots', + 'file' => '/Application/views/blocks/_gtm_js.tpl', 'position' => 150 ], // tag manager nojs [ 'template' => 'layout/base.tpl', - 'block' => 'theme_svg_icons', - 'file' => '/Application/views/blocks/_gtm_nojs.tpl' + 'block' => 'theme_svg_icons', + 'file' => '/Application/views/blocks/_gtm_nojs.tpl' ], // details [ 'template' => 'page/details/inc/productmain.tpl', - 'block' => 'details_productmain_title', - 'file' => '/Application/views/blocks/view_item.tpl', + 'block' => 'details_productmain_title', + 'file' => '/Application/views/blocks/view_item.tpl', 'position' => 150 ], // View Cart [ 'template' => 'page/checkout/basket.tpl', - 'block' => 'checkout_basket_main', - 'file' => '/Application/views/blocks/view_cart.tpl' + 'block' => 'checkout_basket_main', + 'file' => '/Application/views/blocks/view_cart.tpl' ], // add_to_cart [ 'template' => 'page/details/inc/productmain.tpl', - 'block' => 'details_productmain_tobasket', - 'file' => '/Application/views/blocks/details_productmain_tobasket.tpl', + 'block' => 'details_productmain_tobasket', + 'file' => '/Application/views/blocks/details_productmain_tobasket.tpl', 'position' => 150 ], // remove_from_cart [ 'template' => 'page/checkout/basket.tpl', - 'block' => 'checkout_basket_main', - 'file' => '/Application/views/blocks/remove_from_cart.tpl', + 'block' => 'checkout_basket_main', + 'file' => '/Application/views/blocks/remove_from_cart.tpl', 'position' => 150 ], [ 'template' => 'page/checkout/thankyou.tpl', - 'block' => 'checkout_thankyou_main', - 'file' => '/Application/views/blocks/purchase.tpl' + 'block' => 'checkout_thankyou_main', + 'file' => '/Application/views/blocks/purchase.tpl' ], // Lists // view_item_list [ 'template' => 'page/list/list.tpl', - 'block' => 'page_list_productlist', - 'file' => '/Application/views/blocks/view_item_list.tpl', + 'block' => 'page_list_productlist', + 'file' => '/Application/views/blocks/view_item_list.tpl', 'position' => 150 ], // view_search_result [ 'template' => 'page/search/search.tpl', - 'block' => 'search_results', - 'file' => '/Application/views/blocks/view_search_result.tpl', + 'block' => 'search_results', + 'file' => '/Application/views/blocks/view_search_result.tpl', 'position' => 150 ], [ 'template' => 'page/list/list.tpl', - 'block' => 'page_list_listbody', - 'file' => '/Application/views/blocks/page_list_listbody.tpl', + 'block' => 'page_list_listbody', + 'file' => '/Application/views/blocks/page_list_listbody.tpl', 'position' => 150 ], [ 'template' => 'page/shop/start.tpl', - 'block' => 'start_welcome_text', - 'file' => '/Application/views/blocks/start_welcome_text.tpl', + 'block' => 'start_welcome_text', + 'file' => '/Application/views/blocks/start_welcome_text.tpl', 'position' => 150 ], // Checkout process // Begin CHeckout [ 'template' => 'page/checkout/user.tpl', - 'block' => 'checkout_user_main', - 'file' => '/Application/views/blocks/begin_checkout.tpl', + 'block' => 'checkout_user_main', + 'file' => '/Application/views/blocks/begin_checkout.tpl', + 'position' => 150 + ], + // Add payment info + // We add it into checkout_order_main ( checkout/order.tpl ) to make sure a payment is actually added; + // we'll also do it like that in the future for add_shipping_info ( not planed yet ) + [ + 'template' => 'page/checkout/order.tpl', + 'block' => 'checkout_order_main', + 'file' => '/Application/views/blocks/add_payment_info.tpl', 'position' => 150 ], ], - 'events' => [ - 'onActivate' => '\D3\GoogleAnalytics4\Setup\Events::onActivate', - 'onDeactivate' => '\D3\GoogleAnalytics4\Setup\Events::onDeactivate', + 'events' => [ + 'onActivate' => '\D3\GoogleAnalytics4\Setup\Events::onActivate', + 'onDeactivate' => '\D3\GoogleAnalytics4\Setup\Events::onDeactivate', ], ]; \ No newline at end of file From f27040e7dd905c565bd3bdffecb7ddda904a2b97 Mon Sep 17 00:00:00 2001 From: MaxBuhe01 Date: Tue, 20 Aug 2024 20:14:56 +0200 Subject: [PATCH 08/12] [Bump] Metadata --- metadata.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/metadata.php b/metadata.php index aeced8b..578699a 100755 --- a/metadata.php +++ b/metadata.php @@ -52,7 +52,7 @@ $aModule = [ Die Entwicklung basiert auf einem Fork von Marat Bedoev - Github-Link ", 'thumbnail' => 'thumbnail.png', - 'version' => 'DEV-2.20.0', + 'version' => '2.20.0', 'author' => 'Data Development (Inh.: Thomas Dartsch)', 'email' => 'support@shopmodule.com', 'url' => 'https://www.oxidmodule.com/', From 48e2dc58adb6a7d74ba384cd8bdecb9d1c0527ed Mon Sep 17 00:00:00 2001 From: MarkusGaertner Date: Tue, 27 Aug 2024 14:25:55 +0200 Subject: [PATCH 09/12] Methode umbenannt --- Modules/Core/WidgetControl.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/Modules/Core/WidgetControl.php b/Modules/Core/WidgetControl.php index f79c6c2..a326a2b 100644 --- a/Modules/Core/WidgetControl.php +++ b/Modules/Core/WidgetControl.php @@ -5,7 +5,7 @@ namespace D3\GoogleAnalytics4\Modules\Core; use OxidEsales\EshopCommunity\Core\Registry; class WidgetControl extends WidgetControl_parent{ - protected function _getStartController() // phpcs:ignore PSR2.Methods.MethodDeclaration.Underscore + protected function getFrontendStartControllerKey() // phpcs:ignore PSR2.Methods.MethodDeclaration.Underscore { /* * array ( @@ -26,7 +26,6 @@ class WidgetControl extends WidgetControl_parent{ ), ) */ - $sScriptName = $_SERVER['SCRIPT_NAME']; if($sScriptName !== '/widget.php') { From 31bafa621bf0bee60262b57ee432086cc2aac44b Mon Sep 17 00:00:00 2001 From: MaxBuhe01 Date: Wed, 11 Sep 2024 17:23:04 +0200 Subject: [PATCH 10/12] [Fixed] currency in begin_checkout --- Application/views/event/begin_checkout.tpl | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Application/views/event/begin_checkout.tpl b/Application/views/event/begin_checkout.tpl index 8be3d14..951d0e2 100644 --- a/Application/views/event/begin_checkout.tpl +++ b/Application/views/event/begin_checkout.tpl @@ -3,6 +3,7 @@ [{assign var="d3BasketPrice" value=$oxcmp_basket->getPrice()}] [{assign var="d3BasketObject" value=$oxcmp_basket}] [{assign var='gtmCartArticles' value=$d3BasketObject->getBasketArticles()}] +[{assign var="gtmCurrency" value=$oView->getActCurrency()}] [{block name="d3_ga4_begin_checkout_block"}] [{capture name="d3_ga4_begin_checkout"}] @@ -14,7 +15,7 @@ 'ecommerce': { 'actionField': "Begin", - 'currency': "[{$currency->name}]", + 'currency': "[{$gtmCurrency->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': From a8ca33b10dd95da9da0d77175108581883abc873 Mon Sep 17 00:00:00 2001 From: MaxBuhe01 Date: Wed, 11 Sep 2024 17:26:58 +0200 Subject: [PATCH 11/12] Bump metadata && changelog --- CHANGELOG.md | 3 +++ metadata.php | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index d98d45d..3276b51 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [unreleased](https://git.d3data.de/D3Public/GoogleAnalytics4/compare/2.17.2...rel_2.x) - 2024-x +## [2.20.1](https://git.d3data.de/D3Public/GoogleAnalytics4/compare/2.20.0...2.20.1) - 2024-09-11 +### Fixed +- missing currency name in begin_checkout template ## [2.20.0](https://git.d3data.de/D3Public/GoogleAnalytics4/compare/2.19.0...2.20.0) - 2024-08-20 ### Added - new event "begin_checkout" diff --git a/metadata.php b/metadata.php index 578699a..f9109fa 100755 --- a/metadata.php +++ b/metadata.php @@ -52,7 +52,7 @@ $aModule = [ Die Entwicklung basiert auf einem Fork von Marat Bedoev - Github-Link ", 'thumbnail' => 'thumbnail.png', - 'version' => '2.20.0', + 'version' => '2.20.1', 'author' => 'Data Development (Inh.: Thomas Dartsch)', 'email' => 'support@shopmodule.com', 'url' => 'https://www.oxidmodule.com/', From 4b2c9780351e98dd3bd1d3fa0ced76c07c000172 Mon Sep 17 00:00:00 2001 From: MaxBuhe01 Date: Thu, 19 Sep 2024 16:20:19 +0200 Subject: [PATCH 12/12] [Bump] Metadata && Changelog --- CHANGELOG.md | 4 ++++ metadata.php | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3276b51..98bcbe8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [unreleased](https://git.d3data.de/D3Public/GoogleAnalytics4/compare/2.17.2...rel_2.x) - 2024-x +## [2.21.0](https://git.d3data.de/D3Public/GoogleAnalytics4/compare/2.20.1...2.21.0) - 2024-09-19 +### Fixed +- missing parameters for widget.php call + ## [2.20.1](https://git.d3data.de/D3Public/GoogleAnalytics4/compare/2.20.0...2.20.1) - 2024-09-11 ### Fixed - missing currency name in begin_checkout template diff --git a/metadata.php b/metadata.php index a6df6b2..402be97 100755 --- a/metadata.php +++ b/metadata.php @@ -52,7 +52,7 @@ $aModule = [ Die Entwicklung basiert auf einem Fork von Marat Bedoev - Github-Link ", 'thumbnail' => 'thumbnail.png', - 'version' => '2.20.1', + 'version' => '2.21.0', 'author' => 'Data Development (Inh.: Thomas Dartsch)', 'email' => 'support@shopmodule.com', 'url' => 'https://www.oxidmodule.com/',