diff --git a/Application/views/blocks/begin_checkout.tpl b/Application/views/blocks/begin_checkout.tpl new file mode 100644 index 0000000..6371ec6 --- /dev/null +++ b/Application/views/blocks/begin_checkout.tpl @@ -0,0 +1,50 @@ +[{$smarty.block.parent}] + +[{*$oxcmp_basket|get_class_methods|dumpvar*}] + +[{assign var="d3BasketPrice" value=$oxcmp_basket->getPrice()}] +[{assign var='gtmCartArticles' value=$oView->getBasketArticles()}] + +[{block name="d3_ga4_begin_checkout_block"}] + [{capture assign=d3_ga4_begin_checkout}] + [{strip}] + dataLayer.push({"event": null, "eventLabel": null, "ecommerce": null}); /* Clear the previous ecommerce object. */ + dataLayer.push({ + 'event': 'begin_checkout', + 'eventLabel':'Checkout Step 2', + 'ecommerce': { + 'actionField': "step: 2", + '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_begin_checkout}] +[{/block}] \ No newline at end of file diff --git a/CHANGELOG.md b/CHANGELOG.md index f004a60..83e4570 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,9 @@ 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). +## [2.10.1](https://git.d3data.de/D3Public/GoogleAnalytics4/compare/2.10.0...2.10.1) - 2023-08-23 +### Added +- new Event "begin_checkout" ## [2.10.0](https://git.d3data.de/D3Public/GoogleAnalytics4/compare/2.9.2...2.10.0) - 2023-08-02 ### Added diff --git a/Docs/README.md b/Docs/README.md index 0834df1..c268f09 100644 --- a/Docs/README.md +++ b/Docs/README.md @@ -27,6 +27,10 @@ Für den geregelten Ablauf sind folgende Blöcke nötig: - Blockname: checkout_basket_main - Datei: page/checkout/basket.tpl - GA4 Event: view_cart +- Checkout starten + - Blockname: checkout_user_main + - Datei: page/checkout/user.tpl + - GA4 Event: begin_checkout - abgeschlossener Kauf - Blockname: checkout_thankyou_main - Datei: page/checkout/thankyou.tpl diff --git a/metadata.php b/metadata.php index 4cdb6da..b25b47f 100755 --- a/metadata.php +++ b/metadata.php @@ -22,7 +22,7 @@ Die Entwicklung basiert auf einem Fork von Marat Bedoev - Github-Link ", 'thumbnail' => 'thumbnail.png', - 'version' => '2.10.0', + 'version' => '2.10.1', 'author' => 'Data Development (Inh.: Thomas Dartsch)', 'email' => 'support@shopmodule.com', 'url' => 'https://www.oxidmodule.com/', @@ -59,6 +59,11 @@ 'block' => 'checkout_basket_main', 'file' => '/Application/views/blocks/view_cart.tpl' ], + [ + 'template' => 'page/checkout/user.tpl', + 'block' => 'checkout_user_main', + 'file' => '/Application/views/blocks/begin_checkout.tpl' + ], [ 'template' => 'page/checkout/thankyou.tpl', 'block' => 'checkout_thankyou_main',