diff --git a/Application/views/ga4/add_to_cart.tpl b/Application/views/ga4/add_to_cart.tpl
index 0721a48..700d44b 100644
--- a/Application/views/ga4/add_to_cart.tpl
+++ b/Application/views/ga4/add_to_cart.tpl
@@ -1,56 +1,47 @@
[{$smarty.block.parent}]
-[{assign var="d3ProductObject" value=$oView->getProduct()}]
-[{assign var="d3PriceObject" value=$d3ProductObject->getPrice()}]
+[{* variable $gtmProduct is passed from parent tempalte *}]
+[{assign var="d3PriceObject" value=$gtmProduct->getPrice()}]
+[{assign var="gtmCurrency" value=$oView->getActCurrency()}]
+[{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"}]
+ [{block name="d3_ga4_add_to_basket"}]
$("#toBasket").click(function(event) {
+ dataLayer.push({"event": null, "eventLabel": null, "ecommerce": null}); /* Clear the previous ecommerce object. */
- [{*** Debug cases ***}]
- [{*event.preventDefault();*}]
+ let itemCategories = '[{if $gtmCategory}][{$gtmCategory->getLink()|parse_url:5|ltrim:"/"|rtrim:"/"}][{else}]no category[{/if}]'.split('/');
- let iArtQuantity = $("#amountToBasket").val();
+ [{*** Debug cases ***}]
+ [{*event.preventDefault();*}]
- 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': itemCategories[0] || 'no category',
- 'item_category_2':itemCategories[1] || '',
- 'item_category_3':itemCategories[2] || '',
- 'item_category_4':itemCategories[3] || '',
- 'quantity': iArtQuantity
- }
- ]
+ 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': itemCategories[0] || 'no category',
+ 'item_category_2':itemCategories[1] || '',
+ 'item_category_3':itemCategories[2] || '',
+ 'item_category_4':itemCategories[3] || '',
+ 'quantity': iArtQuantity
+ }
+ ]
}
});
});
-[{/block}]
-[{/capture}]
-[{oxscript add=$d3_ga4_add_to_cart}]
-
-[{strip}]
- [{* variable $gtmProduct is passed from parent tempalte *}]
-
- [{assign var="gtmCurrency" value=$oView->getActCurrency()}]
- [{assign var="gtmManufacturer" value=$gtmProduct->getManufacturer()}]
- [{assign var="gtmCategory" value=$gtmProduct->getCategory()}]
-
-
-[{/strip}]
\ No newline at end of file
+ [{/block}]
+ [{/capture}]
+[{oxscript add=$d3_ga4_add_to_cart}]
\ No newline at end of file
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 0c9155d..2d6eaf1 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -67,24 +67,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
## [2.0](https://git.d3data.de/D3Public/GoogleAnalytics4/compare/1.1...2.0) - 2023-01-20
### Added
- using of ContainerFactory in ViewConfig
-## [1.8.0](https://git.d3data.de/D3Public/GoogleAnalytics4/compare/1.7.0...1.8.0) - 2023-05-31
-### Fixed
-- bug in explicit manager selection
-## [1.7.0](https://git.d3data.de/D3Public/GoogleAnalytics4/compare/1.6.0...1.7.0) - 2023-05-31
-### Added
-- extended call to read the technical documentation
+## [1.9.0](https://git.d3data.de/D3Public/GoogleAnalytics4/compare/1.8.0...1.9.0) - 2023-06-19
### Changed
-- block-extension for view_item_list
-- way of getting list-articles in view_item_list
-
-## [1.6.0](https://git.d3data.de/D3Public/GoogleAnalytics4/compare/1.5.0...1.6.0) - 2023-05-30
-### Added
-- possibility to choose between consentmanager && usercentrics
-- position to block extension
-### Changed
-- genuine code cleanup
-- usercentrics includation script
+- add_to_cart event template-structure
## [1.8.0](https://git.d3data.de/D3Public/GoogleAnalytics4/compare/1.7.0...1.8.0) - 2023-05-31
### Fixed
diff --git a/metadata.php b/metadata.php
index a4d8b37..2ffaabb 100755
--- a/metadata.php
+++ b/metadata.php
@@ -17,7 +17,7 @@ $aModule = [
Die Entwicklung basiert auf einem Fork von Marat Bedoev - Github-Link
",
'thumbnail' => 'thumbnail.png',
- 'version' => '2.6.0',
+ 'version' => '1.9.0',
'author' => 'Data Development (Inh.: Thomas Dartsch)',
'email' => 'support@shopmodule.com',
'url' => 'https://www.oxidmodule.com/',