Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

new event "begin_checkout" #6

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 50 additions & 0 deletions Application/views/blocks/begin_checkout.tpl
Original file line number Diff line number Diff line change
@@ -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}]
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 4 additions & 0 deletions Docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
7 changes: 6 additions & 1 deletion metadata.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
Die Entwicklung basiert auf einem Fork von Marat Bedoev - <a href='https://github.com/vanilla-thunder/oxid-module-gtm'>Github-Link</a>
",
'thumbnail' => 'thumbnail.png',
'version' => '2.10.0',
'version' => '2.10.1',
'author' => 'Data Development (Inh.: Thomas Dartsch)',
'email' => 'support@shopmodule.com',
'url' => 'https://www.oxidmodule.com/',
Expand Down Expand Up @@ -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',
Expand Down