Compare commits

...

15 Commits
2.4.0 ... 2.5.0

Author SHA1 Message Date
MaxBUhe 000c49c56b bump version && changelog to 2.5.0 2023-05-23 11:32:20 +02:00
MaxBUhe 002cc69d2a switch metadata entries; fix getPrice-bug 2023-05-23 10:06:21 +02:00
MaxBUhe af78809ae5 add settings-entry; add consentmanager-option 2023-05-15 15:06:25 +02:00
MaxBUhe d531ba648b fix unnecessary convert of int to str 2023-05-12 14:08:52 +02:00
MaxBUhe a0c650fca3 Merge branch 'rel_2.x' 2023-05-11 15:26:45 +02:00
MaxBUhe af341a984b Merge branch 'rel_1.x'
# Conflicts:
#	CHANGELOG.md
#	metadata.php
2023-05-11 15:26:31 +02:00
MaxBUhe 122dd4cf53 genuine code cleanup; switch hard-getter to methods and use price-object 2023-05-10 15:01:56 +02:00
MaxBUhe 6d155d310b bump version && changelog to 1.4.0 2023-05-02 14:21:43 +02:00
Christoph Staeblein 6e62f39b71 OXID UserCentrics support, general overhaul for cookie managers
taken from pull-request; thank you C. Stäblein
2023-04-04 10:15:15 +02:00
MaxBUhe 616f31ecba Merge remote-tracking branch 'remotes/origin/rel_2.x' 2023-03-20 15:46:58 +01:00
MaxBuhe01 718b60e12c Merge remote-tracking branch 'remotes/origin/rel_2.x' 2023-03-17 15:31:34 +01:00
MaxBUhe 9cb3a54824 Merge remote-tracking branch 'remotes/origin/rel_2.x' 2023-02-22 14:35:22 +01:00
MaxBuhe01 1c0d55bdc3 Merge remote-tracking branch 'remotes/origin/rel_2.x' 2023-02-21 12:47:38 +01:00
MaxBuhe01 7c1f99e678 Merge remote-tracking branch 'remotes/origin/rel_2.x' 2023-02-21 12:47:02 +01:00
MaxBUhe 126e746651 missing changelog-entry 2023-02-21 12:46:34 +01:00
10 changed files with 138 additions and 86 deletions

View File

@ -31,5 +31,8 @@ $aLang = [
// for cookie manager settings
'SHOP_MODULE_GROUP_d3_gtm_settings_cookiemanager' => 'Cookie Manager Einstellungen',
'SHOP_MODULE_d3_gtm_settings_hasOwnCookieManager' => 'Cookie Manager nutzen?',
'SHOP_MODULE_d3_gtm_settings_cookieName' => 'CookieID',
'SHOP_MODULE_d3_gtm_settings_HAS_CONSENTMANAGER' => 'Nutzen Sie die Consentmanager-Einbindung?',
'SHOP_MODULE_d3_gtm_settings_HAS_CONSENTMANAGER_NO' => 'Nein',
'SHOP_MODULE_d3_gtm_settings_HAS_CONSENTMANAGER_YES' => 'Ja',
'SHOP_MODULE_d3_gtm_settings_cookieName' => 'CookieID',
];

View File

@ -2,10 +2,10 @@
[{*$oxcmp_basket|get_class_methods|dumpvar*}]
[{assign var="d3BasketPrice" value=$oxcmp_basket->getPrice()}]
[{assign var='gtmCartArticles' value=$oView->getBasketArticles()}]
[{strip}][{capture assign=d3_ga4_view_cart}]
let iPrice = "[{oxprice price=$oxcmp_basket->getPrice()}]";
dataLayer.push({"event": null, "eventLabel": null, "ecommerce": null}); /* Clear the previous ecommerce object. */
dataLayer.push({
'event': 'view_cart',
@ -13,15 +13,15 @@
'ecommerce': {
'actionField': "step: 1",
'currency': "[{$currency->name}]",
'value': iPrice.replace("€", ""),
'value': [{$d3BasketPrice->getPrice()}],
'items': [
[{foreach from=$oxcmp_basket->getContents() item=basketitem name=gtmCartContents key=basketindex}]
[{assign var='_price' value=$basketitem->getUnitPrice()}]
[{assign var="d3oItemPrice" value=$basketitem->getPrice()}]
{
'item_id': '[{$gtmCartArticles[$basketindex]->oxarticles__oxartnum->value}]',
'item_name': '[{$gtmCartArticles[$basketindex]->oxarticles__oxtitle->value}]',
'item_variant': '[{$gtmCartArticles[$basketindex]->oxarticles__oxvarselect->value}]',
'price': [{$_price->getPrice()}],
'item_id': '[{$gtmCartArticles[$basketindex]->getFieldData('oxartnum')}]',
'item_name': '[{$gtmCartArticles[$basketindex]->getFieldData('oxtitle')}]',
'item_variant': '[{$gtmCartArticles[$basketindex]->getFieldData('oxvarselect')}]',
'price': [{$d3oItemPrice->getPrice()}],
'quantity':[{$basketitem->getAmount()}],
'position':[{$smarty.foreach.gtmCartContents.index}]
}[{if !$smarty.foreach.gtmCartContents.last}],[{/if}]

View File

@ -10,21 +10,22 @@
'event': 'purchase',
'eventLabel':'Checkout Step 5',
'ecommerce': {
'transaction_id': '[{$_gtmOrder->oxorder__oxordernr->value}]',
'affiliation': '[{$oxcmp_shop->oxshops__oxname->value}]',
'value': '[{$_gtmOrder->oxorder__oxtotalordersum->value}]',
'tax': '[{math equation="x+y" x=$_gtmOrder->oxorder__oxartvatprice1->value y=$_gtmOrder->oxorder__oxartvatprice2->value }]',
'shipping': '[{$_gtmOrder->oxorder__oxdelcost->value}]',
'transaction_id': '[{$_gtmOrder->getFieldData("oxordernr")}]',
'affiliation': '[{$oxcmp_shop->getFieldData("oxname")}]',
'value': [{$_gtmOrder->getTotalOrderSum()}],
'tax': [{math equation="x+y" x=$_gtmOrder->getFieldData("oxartvatprice1") y=$_gtmOrder->getFieldData("oxartvatprice2") }],
'shipping': [{$_gtmOrder->getFieldData("oxdelcost")}],
'currency': '[{$_gtmOrder->getFieldData('oxcurrency')}]',
'items':
[
[{foreach from=$_gtmArticles item="_gtmArticle" name="gtmArticles"}]
[{foreach from=$_gtmArticles item="d3BasketArticle" name="gtmArticles"}]
[{assign var="d3oArticlePrice" value=$d3BasketArticle->getPrice()}]
{
'id': '[{$_gtmArticle->oxorderarticles__oxartnum->value}]',
'name': '[{$_gtmArticle->oxorderarticles__oxtitle->value}]',
'variant': '[{$_gtmArticle->oxorderarticles__oxselvariant->value}]',
'price': [{$_gtmArticle->oxorderarticles__oxprice->value}],
'quantity': [{$_gtmArticle->oxorderarticles__oxamount->value}],
'id': '[{$d3BasketArticle->getFieldData("oxartnum")}]',
'name': '[{$d3BasketArticle->getFieldData("oxtitle")}]',
'variant': '[{$d3BasketArticle->getFieldData("oxselvariant")}]',
'price': [{$d3oArticlePrice->getPrice()}],
'quantity': [{$d3BasketArticle->getFieldData("oxamount")}],
'position': [{$smarty.foreach.gtmArticles.iteration}]
}[{if !$smarty.foreach.gtmArticles.last}],[{/if}]
[{/foreach}]

View File

@ -12,12 +12,13 @@
'currency': '[{$currency->name}]',
'items': [
{
'item_name': '[{$gtmProduct->oxarticles__oxtitle->value}]',
'item_id': '[{$gtmProduct->oxarticles__oxartnum->value}]',
'item_name': '[{$gtmProduct->getFieldData("oxtitle")}]',
'item_id': '[{$gtmProduct->getFieldData("oxartnum")}]',
'item_brand': '[{if $gtmManufacturer}][{$gtmManufacturer->oxmanufacturers__oxtitle->value}][{/if}]',
'item_category': '[{if $gtmCategory}][{$gtmCategory->getLink()|parse_url:5|ltrim:"/"|rtrim:"/"}][{else}]-[{/if}]',
'item_variant': '[{if $gtmProduct->oxarticles__oxvarselect->value}][{$gtmProduct->oxarticles__oxvarselect->value}][{/if}]',
'price': [{$gtmProduct->oxarticles__oxprice->value}]
'item_variant': '[{if $gtmProduct->getFieldData("oxvarselect")}][{$gtmProduct->getFieldData("oxvarselect")}][{/if}]',
[{assign var="d3PriceObject" value=$gtmProduct->getPrice()}]
'price': [{$d3PriceObject->getPrice()}]
}
]
}

View File

@ -1,6 +1,7 @@
[{$smarty.block.parent}]
[{*$gtmProduct|get_class_methods|dumpvar*}]
[{assign var="d3ProductObject" value=$oView->getProduct()}]
[{assign var="d3PriceObject" value=$d3ProductObject->getPrice()}]
[{capture assign=d3_ga4_add_to_cart}]
[{block name="d3_ga4_add_to_basket"}]
@ -17,23 +18,18 @@
'eventLabel': 'add_to_cart',
'ecommerce': {
'currency': "[{$currency->name}]",
'value': iArtQuantity*[{$gtmProduct->getFieldData('oxprice')}],
'value': iArtQuantity*[{$d3PriceObject->getPrice()}],
'items': [
{
'item_id': '[{$gtmProduct->getFieldData('oxartnum')}]',
'item_name': '[{$gtmProduct->getFieldData('oxtitle')}]',
'price': '[{$gtmProduct->getFieldData('oxprice')}]',
'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] || '',
[{if false}]
'item_list_name': 'Search Results', // If associated with a list selection.
'item_list_id': 'SR123', // If associated with a list selection.
'index': 1, // If associated with a list selection.
[{/if}]
'quantity': iArtQuantity
}
]

View File

@ -13,12 +13,13 @@
'search_term': '[{$searchparamforhtml}]',
'items': [
[{foreach from=$gtmProducts name="gtmProducts" item="gtmProduct"}]
[{assign var="d3PriceObject" value=$gtmProduct->getPrice()}]
[{assign var="gtmManufacturer" value=$gtmProduct->getManufacturer()}]
[{if !$gtmCategory}][{assign var="gtmCategory" value=$gtmProduct->getCategory()}][{/if}]
{
'item_id': '[{$gtmProduct->getFieldData("oxartnum")}]',
'item_name': '[{$gtmProduct->getFieldData("oxtitle")}]',
'price': [{$gtmProduct->oxarticles__oxprice->value|default:'0'}],
'price': [{$d3PriceObject->getPrice()}],
'item_brand': '[{if $gtmManufacturer}][{$gtmManufacturer->oxmanufacturers__oxtitle->value}][{/if}]',
'item_category': '[{if $gtmCategory}][{$gtmCategory->getLink()|parse_url:5|ltrim:"/"|rtrim:"/"}][{else}]-[{/if}]',
'quantity': 1

View File

@ -1,34 +1,36 @@
[{assign var="gtmProducts" value=$products}]
[{assign var="breadCrumb" value=''}]
[{if $gtmProducts|@count}]
[{strip}]
<script>
/* ga4 */
dataLayer.push({ecommerce: null});
dataLayer.push({
'event':'view_item_list',
'event_name': 'view_item_list',
'ecommerce': {
'item_list_id': '[{$oView->getCategoryId()}]',
'item_list_name': '[{foreach from=$oView->getBreadCrumb() item=sCrum}][{if $sCrum.title }][{$breadCrumb|cat:$sCrum.title|cat:" > "}][{/if}][{/foreach}]',
'items': [
[{foreach from=$gtmProducts name="gtmProducts" item="gtmProduct"}]
[{assign var="gtmManufacturer" value=$gtmProduct->getManufacturer()}]
[{if !$gtmCategory}][{assign var="gtmCategory" value=$gtmProduct->getCategory()}][{/if}]
{
'item_id': '[{$gtmProduct->getFieldData("oxartnum")}]',
'item_name': '[{$gtmProduct->getFieldData("oxtitle")}]',
'price': [{$gtmProduct->oxarticles__oxprice->value|default:'0'}],
'item_brand': '[{if $gtmManufacturer}][{$gtmManufacturer->oxmanufacturers__oxtitle->value}][{/if}]',
'item_category': '[{if $gtmCategory}][{$gtmCategory->getLink()|parse_url:5|ltrim:"/"|rtrim:"/"}][{else}]-[{/if}]',
'quantity': 1
}[{if !$smarty.foreach.gtmProducts.last}],[{/if}]
[{/foreach}]
]
}
});
</script>
[{/strip}]
[{$smarty.block.parent}]
[{assign var="gtmProducts" value=$products}]
[{assign var="breadCrumb" value=''}]
[{if $gtmProducts|@count}]
[{strip}]
<script>
/* ga4 */
dataLayer.push({ecommerce: null});
dataLayer.push({
'event':'view_item_list',
'event_name': 'view_item_list',
'ecommerce': {
'item_list_id': '[{$oView->getCategoryId()}]',
'item_list_name': '[{foreach from=$oView->getBreadCrumb() item=sCrum}][{if $sCrum.title }][{$breadCrumb|cat:$sCrum.title|cat:" > "}][{/if}][{/foreach}]',
'items': [
[{foreach from=$gtmProducts name="gtmProducts" item="gtmProduct"}]
[{assign var="d3PriceObject" value=$gtmProduct->getPrice()}]
[{assign var="gtmManufacturer" value=$gtmProduct->getManufacturer()}]
[{if !$gtmCategory}][{assign var="gtmCategory" value=$gtmProduct->getCategory()}][{/if}]
{
'item_id': '[{$gtmProduct->getFieldData("oxartnum")}]',
'item_name': '[{$gtmProduct->getFieldData("oxtitle")}]',
'price': [{$d3PriceObject->getPrice()}],
'item_brand': '[{if $gtmManufacturer}][{$gtmManufacturer->oxmanufacturers__oxtitle->value}][{/if}]',
'item_category': '[{if $gtmCategory}][{$gtmCategory->getLink()|parse_url:5|ltrim:"/"|rtrim:"/"}][{else}]-[{/if}]',
'quantity': 1
}[{if !$smarty.foreach.gtmProducts.last}],[{/if}]
[{/foreach}]
]
}
});
</script>
[{/strip}]
[{/if}]

View File

@ -4,6 +4,15 @@ 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.5.0](https://git.d3data.de/D3Public/GoogleAnalytics4/compare/2.4.0...2.5.0) - 2023-05-23
### Added
- additional settings to explicitly indicate that consentmanager is used
### Fixed
- unnecessary converting of int to str
- missing PriceObject-bug
### Changed
- genuine code cleanup
## [2.4.0](https://git.d3data.de/D3Public/GoogleAnalytics4/compare/2.3.3...2.4.0) - 2023-05-02
### Added
- "OXID Cookie Management powered by usercentrics" compatibility
@ -45,6 +54,14 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Added
- using of ContainerFactory in ViewConfig
## [1.4.0](https://git.d3data.de/D3Public/GoogleAnalytics4/compare/1.3.1...1.4.0) - 2023-05-02
### Added
- "OXID Cookie Management powered by usercentrics" compatibility
- usercentrics defined script attributes
- cookie-manager evaluation
### Changed
- genuine clean up of base-js-files
## [1.3.1](https://git.d3data.de/D3Public/GoogleAnalytics4/compare/1.2.1...1.3.1) - 2023-03-17
### Added
- Aggrosoft-Cookie-Consent compatibility
@ -53,7 +70,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
## [1.2.1](https://git.d3data.de/D3Public/GoogleAnalytics4/compare/1.2...1.2.1) - 2023-02-22
### Fixed
- price formatting view_cart
- price formatting in view_cart
## [1.2](https://git.d3data.de/D3Public/GoogleAnalytics4/compare/1.1...1.2) - 2023-02-01
### Added
@ -67,7 +84,6 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Changed
- switched price formatting
## [1.0](https://git.d3data.de/D3Public/GoogleAnalytics4/releases/tag/1.0) - 2023-01-20
## [1.0](https://git.d3data.de/D3Public/GoogleAnalytics4/compare/1.0...1.0) - 2023-01-20
### Added
- publication of app features

View File

@ -13,6 +13,7 @@
namespace D3\GoogleAnalytics4\Modules\Core;
use OxidEsales\Eshop\Application\Controller\FrontendController;
use OxidEsales\Eshop\Core\Config;
use OxidEsales\Eshop\Core\Registry;
use OxidEsales\EshopCommunity\Internal\Container\ContainerFactory;
use OxidEsales\EshopCommunity\Internal\Framework\Module\Configuration\Bridge\ModuleSettingBridgeInterface;
@ -36,6 +37,11 @@ class ViewConfig extends ViewConfig_parent
return $this->sContainerId;
}
public function getModuleConsentmanagerSettingSelectValue() :bool
{
return Registry::getConfig()->getConfigParam('d3_gtm_settings_HAS_CONSENTMANAGER') === 'YES';
}
public function getCookieManagerType()
{
if ($this->sCookieManagerType === null)
@ -55,6 +61,11 @@ class ViewConfig extends ViewConfig_parent
}
}
}
if ($this->sCookieManagerType === false and $this->getModuleConsentmanagerSettingSelectValue()){
return "consentmanager";
}
return $this->sCookieManagerType;
}
@ -63,7 +74,8 @@ class ViewConfig extends ViewConfig_parent
*/
public function D3blShowGtmScript()
{
$oConfig = $this->getConfig();
/** @var Config $oConfig */
$oConfig = Registry::getConfig();
// No Cookie Manager in use
if (!$oConfig->getConfigParam('d3_gtm_settings_hasOwnCookieManager')) {
@ -88,7 +100,7 @@ class ViewConfig extends ViewConfig_parent
}
// UserCentrics
if ($this->getCookieManagerType() == "oxps_usercentrics") {
if ($this->getCookieManagerType() === "oxps_usercentrics" or $this->getCookieManagerType() === 'consentmanager') {
// Always needs the script-tags delivered to the DOM.
return true;
}
@ -104,8 +116,9 @@ class ViewConfig extends ViewConfig_parent
*/
public function getGtmScriptAttributes()
{
$oConfig = Registry::getConfig();
if ($this->getCookieManagerType() == "oxps_usercentrics") {
$oConfig = $this->getConfig();
$sCookieId = $oConfig->getConfigParam('d3_gtm_settings_cookieName');
if ($sCookieId) {
@ -113,6 +126,19 @@ class ViewConfig extends ViewConfig_parent
}
}
if ($this->getCookieManagerType() == "consentmanager") {
$sCookieId = $oConfig->getConfigParam('d3_gtm_settings_cookieName');
if ($sCookieId) {
return 'async
type="text/plain"
data-cmp-src="https://www.googletagmanager.com/gtm.js?id='.$this->getGtmContainerId().'"
class="cmplazyload"
data-cmp-vendor="s905"
';
}
}
return "";
}

View File

@ -17,7 +17,7 @@ $aModule = [
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.4.0',
'version' => '2.5.0',
'author' => 'Data Development (Inh.: Thomas Dartsch)',
'email' => 'support@shopmodule.com',
'url' => 'https://www.oxidmodule.com/',
@ -43,18 +43,6 @@ $aModule = [
'block' => 'theme_svg_icons',
'file' => '/Application/views/blocks/_gtm_nojs.tpl'
],
// checkout
// view_cart
[
'template' => 'page/checkout/basket.tpl',
'block' => 'checkout_basket_main',
'file' => '/Application/views/blocks/checkout_s1.tpl'
],
[
'template' => 'page/checkout/thankyou.tpl',
'block' => 'checkout_thankyou_main',
'file' => '/Application/views/blocks/checkout_s5.tpl'
],
// details
[
'template' => 'page/details/inc/productmain.tpl',
@ -62,11 +50,22 @@ $aModule = [
'file' => '/Application/views/blocks/view_item.tpl',
'position' => 150
],
// checkout
[
'template' => 'page/checkout/basket.tpl',
'block' => 'checkout_basket_main',
'file' => '/Application/views/blocks/checkout_s1.tpl'
],
[
'template' => 'page/checkout/thankyou.tpl',
'block' => 'checkout_thankyou_main',
'file' => '/Application/views/blocks/checkout_s5.tpl'
],
// Lists
// view_item_list
[
'template' => 'widget/product/list.tpl',
'block' => 'd3Ga4_view_item_list',
'block' => 'widget_product_list',
'file' => '/Application/views/ga4/view_item_list.tpl',
'position' => 150
],
@ -121,5 +120,12 @@ $aModule = [
'value' => 'example',
'position' => 999
],
[
'group' => 'd3_gtm_settings_cookiemanager',
'name' => 'd3_gtm_settings_HAS_CONSENTMANAGER',
'type' => 'select',
'value' => 'none',
'constraints' => 'NO|YES',
],
]
];