Compare commits

...

5 Commits

Author SHA1 Message Date
3f34973638 [Changed] trigger and payment receiving 2024-10-25 21:08:52 +02:00
2ec373c95f [Bump] Metadata && Changelog 2024-09-21 16:23:06 +02:00
6fcb9f8b84 [Changed] add "internal_names" to constant 2024-09-21 16:20:48 +02:00
53b3c878ce [Fixed] Consentmanager doesn't get delivered
false value given for important decision-making. Since the value was false, we got "false" as return for D3blShowGtmScript() which made consentmanager not send the data to GTM
2024-09-21 16:08:08 +02:00
65b618e25c [Removed] unnecessary "none" entry for CMP-choosability 2024-09-21 16:06:32 +02:00
6 changed files with 91 additions and 60 deletions

View File

@ -7,19 +7,25 @@ use D3\GoogleAnalytics4\Application\Model\CMP\Usercentrics;
class ManagerTypes class ManagerTypes
{ {
const EXTERNAL_SERVICE = "eigener Service"; const EXTERNAL_SERVICE = "eigener Service";
const INTERNAL_EXTERNAL_SERVICE = "externalService";
const NET_COOKIE_MANAGER = "Netensio Cookie Manager"; const NET_COOKIE_MANAGER = "Netensio Cookie Manager";
const INTERNAL_NET_COOKIE_MANAGER = "net_cookie_manager";
/** /**
* Further information's: * Further information's:
* https://github.com/aggrosoft/oxid-cookie-compliance * https://github.com/aggrosoft/oxid-cookie-compliance
*/ */
const AGCOOKIECOMPLIANCE = "Aggrosoft Cookie Compliance"; const AGCOOKIECOMPLIANCE = "Aggrosoft Cookie Compliance";
const INTERNAL_AGCOOKIECOMPLIANCE = "agcookiecompliance";
const CONSENTMANAGER = "Consentmanager"; const CONSENTMANAGER = "Consentmanager";
const INTERNAL_CONSENTMANAGER = "cmconsentmanager";
const COOKIEFIRST = "Cookiefirst"; const COOKIEFIRST = "Cookiefirst";
const INTERNAL_COOKIEFIRST = "cookiefirst";
const COOKIEBOT = "Cookiebot"; const COOKIEBOT = "Cookiebot";
const INTERNAL_COOKIEBOT = "cookiebot";
/** /**
* @return array * @return array
@ -27,14 +33,14 @@ class ManagerTypes
public function getManagerList(): array public function getManagerList(): array
{ {
return [ return [
"externalService" => self::EXTERNAL_SERVICE, self::INTERNAL_EXTERNAL_SERVICE => self::EXTERNAL_SERVICE,
"agcookiecompliance" => self::AGCOOKIECOMPLIANCE, self::INTERNAL_AGCOOKIECOMPLIANCE => self::AGCOOKIECOMPLIANCE,
"net_cookie_manager" => self::NET_COOKIE_MANAGER, self::INTERNAL_NET_COOKIE_MANAGER => self::NET_COOKIE_MANAGER,
Usercentrics::sModuleIncludationInternalName => Usercentrics::sModuleIncludationPublicName, Usercentrics::sModuleIncludationInternalName => Usercentrics::sModuleIncludationPublicName,
Usercentrics::sExternalIncludationInternalName => Usercentrics::sExternalIncludationPublicName, Usercentrics::sExternalIncludationInternalName => Usercentrics::sExternalIncludationPublicName,
"cmconsentmanager" => self::CONSENTMANAGER, self::INTERNAL_CONSENTMANAGER => self::CONSENTMANAGER,
"cookiefirst" => self::COOKIEFIRST, self::INTERNAL_COOKIEFIRST => self::COOKIEFIRST,
"cookiebot" => self::COOKIEBOT, self::INTERNAL_COOKIEBOT => self::COOKIEBOT,
]; ];
} }
@ -46,4 +52,21 @@ class ManagerTypes
{ {
return in_array($sManager, array_keys($this->getManagerList()), true); return in_array($sManager, array_keys($this->getManagerList()), true);
} }
/**
* @return array
*
* the CMP from this method always needs the script tag delivered to the dom.
*/
public function scriptTagDeliveredByDefaultArray() :array
{
return [
Usercentrics::sModuleIncludationInternalName,
Usercentrics::sExternalIncludationInternalName,
ManagerTypes::INTERNAL_CONSENTMANAGER,
ManagerTypes::INTERNAL_COOKIEFIRST,
ManagerTypes::INTERNAL_COOKIEBOT,
ManagerTypes::INTERNAL_EXTERNAL_SERVICE
];
}
} }

View File

@ -80,7 +80,6 @@
[{oxmultilang ident="D3CMP"}] [{oxmultilang ident="D3CMP"}]
</label> </label>
<select class="form-select w-50" name="editval[select][_HAS_STD_MANAGER]" aria-label="Default select example"> <select class="form-select w-50" name="editval[select][_HAS_STD_MANAGER]" aria-label="Default select example">
<option value="NONE" selected>[{oxmultilang ident="D3NONE"}]</option>
[{foreach from=$d3ManagerTypeArray key="sInternalName" item="sPublicName" name="editval[aCmpNameArray]"}] [{foreach from=$d3ManagerTypeArray key="sInternalName" item="sPublicName" name="editval[aCmpNameArray]"}]
<option value="[{$sInternalName}]" [{if $sInternalName === $d3CurrentCMP}]SELECTED[{/if}]>[{$sPublicName}]</option> <option value="[{$sInternalName}]" [{if $sInternalName === $d3CurrentCMP}]SELECTED[{/if}]>[{$sPublicName}]</option>
[{/foreach}] [{/foreach}]

View File

@ -3,49 +3,54 @@
[{assign var="gtmBasketPrice" value=$oxcmp_basket->getPrice()}] [{assign var="gtmBasketPrice" value=$oxcmp_basket->getPrice()}]
[{assign var="gtmBasketObject" value=$oxcmp_basket}] [{assign var="gtmBasketObject" value=$oxcmp_basket}]
[{assign var='gtmCartArticles' value=$gtmBasketObject->getBasketArticles()}] [{assign var='gtmCartArticles' value=$gtmBasketObject->getBasketArticles()}]
[{assign var="gtmPaymentObject" value=$oView->getPayment()}]
[{block name="gtm_ga4_add_payment_info_block"}] [{block name="gtm_ga4_add_payment_info_block"}]
[{capture name="gtm_ga4_add_payment_info"}] [{capture name="gtm_ga4_add_payment_info"}]
[{strip}] [{strip}]
dataLayer.push({"event": null, "eventLabel": null, "ecommerce": null}); /* Clear the previous ecommerce object. */ $(document).ready(function() {
dataLayer.push({ $('#orderStep, #paymentNextStepBottom').on('click', function() {
'event': 'add_payment_info', let selectedPaymentMethod = document.querySelector('input[type="radio"]:checked');
'eventLabel':'Checkout - Payment info',
'payment_type':'[{$gtmPaymentObject->gtmGetSelectedPaymentName()}]', dataLayer.push({"event": null, "eventLabel": null, "ecommerce": null}); /* Clear the previous ecommerce object. */
'ecommerce': dataLayer.push({
{ 'event': 'add_payment_info',
'actionField': "Payment-Info", 'eventLabel':'Checkout - Payment info',
'currency': "[{$currency->name}]", 'payment_type': selectedPaymentMethod.value,
'value': [{$gtmBasketPrice->getPrice()}], 'ecommerce':
'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="gtmItemPriceObject" value=$basketitem->getPrice()}]
[{assign var="gtmBasketItem" value=$basketitem->getArticle()}]
[{assign var="gtmBasketItemCategory" value=$gtmBasketItem->getCategory()}]
{ {
'item_id': '[{$gtmCartArticles[$basketindex]->getFieldData('oxartnum')}]', 'actionField': "Payment-Info",
'item_name': '[{$gtmCartArticles[$basketindex]->getFieldData('oxtitle')}]', 'currency': "[{$currency->name}]",
'item_variant': '[{$gtmCartArticles[$basketindex]->getFieldData('oxvarselect')}]', 'value': [{$gtmBasketPrice->getPrice()}],
[{if $gtmBasketItemCategory}] 'coupon': '[{foreach from=$oxcmp_basket->getVouchers() item=sVoucher key=key name=Voucher}][{$sVoucher->sVoucherNr}][{if !$smarty.foreach.Voucher.last}], [{/if}][{/foreach}]',
'item_category': '[{$gtmBasketItemCategory->getSplitCategoryArray(0, true)}]', 'items':
'item_category_2': '[{$gtmBasketItemCategory->getSplitCategoryArray(1, true)}]', [
'item_category_3': '[{$gtmBasketItemCategory->getSplitCategoryArray(2, true)}]', [{foreach from=$oxcmp_basket->getContents() item=basketitem name=gtmCartContents key=basketindex}]
'item_category_4': '[{$gtmBasketItemCategory->getSplitCategoryArray(3, true)}]', [{assign var="gtmItemPriceObject" value=$basketitem->getPrice()}]
'item_list_name': '[{$gtmBasketItemCategory->getSplitCategoryArray()}]', [{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': [{$gtmItemPriceObject->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}] [{/if}]
'price': [{$gtmItemPriceObject->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}] [{/strip}]
[{/capture}] [{/capture}]

View File

@ -6,6 +6,12 @@ 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 ## [unreleased](https://git.d3data.de/D3Public/GoogleAnalytics4/compare/2.17.2...rel_2.x) - 2024-x
## [2.22.0](https://git.d3data.de/D3Public/GoogleAnalytics4/compare/2.21.0...2.22.0) - 2024-09-21
### Fixed
- Consentmanager didn't get delivered
### Changed
- write "internal_names" of CMP to constants
## [2.21.0](https://git.d3data.de/D3Public/GoogleAnalytics4/compare/2.20.1...2.21.0) - 2024-09-19 ## [2.21.0](https://git.d3data.de/D3Public/GoogleAnalytics4/compare/2.20.1...2.21.0) - 2024-09-19
### Fixed ### Fixed
- missing parameters for widget.php call - missing parameters for widget.php call

View File

@ -88,7 +88,7 @@ class ViewConfig extends ViewConfig_parent
$sCookieID = trim($this->d3GetModuleConfigParam('_sControlParameter')); $sCookieID = trim($this->d3GetModuleConfigParam('_sControlParameter'));
// Netensio Cookie Manager // Netensio Cookie Manager
if ($this->sCookieManagerType === ManagerTypes::NET_COOKIE_MANAGER) { if ($this->sCookieManagerType === ManagerTypes::INTERNAL_NET_COOKIE_MANAGER) {
$oSession = Registry::getSession(); $oSession = Registry::getSession();
$aCookies = $oSession->getVariable("aCookieSel"); $aCookies = $oSession->getVariable("aCookieSel");
@ -96,20 +96,18 @@ class ViewConfig extends ViewConfig_parent
} }
// Aggrosoft Cookie Consent // Aggrosoft Cookie Consent
if ($this->sCookieManagerType === ManagerTypes::AGCOOKIECOMPLIANCE) { if ($this->sCookieManagerType === ManagerTypes::INTERNAL_AGCOOKIECOMPLIANCE) {
if (method_exists($this, "isCookieCategoryEnabled")) { if (method_exists($this, "isCookieCategoryEnabled")) {
return $this->isCookieCategoryEnabled($sCookieID); return $this->isCookieCategoryEnabled($sCookieID);
} }
} }
// UserCentrics or consentmanager
if ( if (
$this->sCookieManagerType === Usercentrics::sModuleIncludationInternalName in_array
or $this->sCookieManagerType === Usercentrics::sExternalIncludationInternalName (
or $this->sCookieManagerType === ManagerTypes::CONSENTMANAGER $this->sCookieManagerType,
or $this->sCookieManagerType === ManagerTypes::COOKIEFIRST (oxNew(ManagerTypes::class)->scriptTagDeliveredByDefaultArray())
or $this->sCookieManagerType === ManagerTypes::COOKIEBOT )
or $this->sCookieManagerType === ManagerTypes::EXTERNAL_SERVICE
) )
{ {
// Always needs the script-tags delivered to the DOM. // Always needs the script-tags delivered to the DOM.
@ -141,16 +139,16 @@ class ViewConfig extends ViewConfig_parent
return 'data-usercentrics="' . $sControlParameter . '" type="text/plain" async=""'; return 'data-usercentrics="' . $sControlParameter . '" type="text/plain" async=""';
} }
if ($this->sCookieManagerType === ManagerTypes::CONSENTMANAGER) if ($this->sCookieManagerType === ManagerTypes::INTERNAL_CONSENTMANAGER)
{ {
return 'type="text/plain" class="cmplazyload" data-cmp-vendor="'.$sControlParameter.'"'; return 'type="text/plain" class="cmplazyload" data-cmp-vendor="'.$sControlParameter.'"';
} }
if ($this->sCookieManagerType === ManagerTypes::COOKIEFIRST){ if ($this->sCookieManagerType === ManagerTypes::INTERNAL_COOKIEFIRST){
return 'type="text/plain" data-cookiefirst-category="' . $sControlParameter .'"'; return 'type="text/plain" data-cookiefirst-category="' . $sControlParameter .'"';
} }
if ($this->sCookieManagerType === ManagerTypes::COOKIEBOT){ if ($this->sCookieManagerType === ManagerTypes::INTERNAL_COOKIEBOT){
return 'type="text/plain" data-cookieconsent="' . $sControlParameter .'"'; return 'type="text/plain" data-cookieconsent="' . $sControlParameter .'"';
} }

View File

@ -52,7 +52,7 @@ $aModule = [
Die Entwicklung basiert auf einem Fork von Marat Bedoev - <a href='https://github.com/vanilla-thunder/oxid-module-gtm'>Github-Link</a> 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', 'thumbnail' => 'thumbnail.png',
'version' => '2.21.0', 'version' => '2.22.0',
'author' => 'Data Development (Inh.: Thomas Dartsch)', 'author' => 'Data Development (Inh.: Thomas Dartsch)',
'email' => 'support@shopmodule.com', 'email' => 'support@shopmodule.com',
'url' => 'https://www.oxidmodule.com/', 'url' => 'https://www.oxidmodule.com/',
@ -193,8 +193,8 @@ $aModule = [
// We add it into checkout_order_main ( checkout/order.tpl ) to make sure a payment is actually added; // We add it into checkout_order_main ( checkout/order.tpl ) to make sure a payment is actually added;
// we'll also do it like that in the future for add_shipping_info ( not planed yet ) // we'll also do it like that in the future for add_shipping_info ( not planed yet )
[ [
'template' => 'page/checkout/order.tpl', 'template' => 'page/checkout/payment.tpl',
'block' => 'checkout_order_main', 'block' => 'checkout_payment_main',
'file' => '/Application/views/blocks/add_payment_info.tpl', 'file' => '/Application/views/blocks/add_payment_info.tpl',
'position' => 150 'position' => 150
], ],