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',