Compare commits
13 Commits
2.20.1
...
dev_2.x__c
Author | SHA1 | Date | |
---|---|---|---|
a18bcd35c4 | |||
2ec373c95f | |||
6fcb9f8b84 | |||
53b3c878ce | |||
65b618e25c | |||
4b2c978035 | |||
2a27b25c5a | |||
48e2dc58ad | |||
98ddc51a4d | |||
48a598da51 | |||
bc1dafbbfa | |||
2a1f8f5794 | |||
7bc73893c3 |
15
Application/Component/Widget/d3GtmStartWidget.php
Normal file
15
Application/Component/Widget/d3GtmStartWidget.php
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
namespace D3\GoogleAnalytics4\Application\Component\Widget;
|
||||||
|
|
||||||
|
class d3GtmStartWidget extends \OxidEsales\Eshop\Application\Component\Widget\WidgetController
|
||||||
|
{
|
||||||
|
public function render()
|
||||||
|
{
|
||||||
|
parent::render();
|
||||||
|
|
||||||
|
return '';
|
||||||
|
}
|
||||||
|
}
|
@ -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
|
||||||
|
];
|
||||||
|
}
|
||||||
}
|
}
|
@ -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}]
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
|
|
||||||
[{if $d3CmpBasket && $d3CmpBasket->getAddToBasketDecision() && $d3CmpBasket->d3GtmRequestedArticleLoadedByAnid() !== null}]
|
[{if $d3CmpBasket && $d3CmpBasket->d3GtmRequestedArticleLoadedByAnid() !== null}]
|
||||||
[{assign var="oGtmProduct" value=$d3CmpBasket->d3GtmRequestedArticleLoadedByAnid()}]
|
[{assign var="oGtmProduct" value=$d3CmpBasket->d3GtmRequestedArticleLoadedByAnid()}]
|
||||||
[{assign var="oGtmAmountArticlesAdded" value=$d3CmpBasket->getD3GtmAddToCartAmountArticles()}]
|
[{assign var="oGtmAmountArticlesAdded" value=$d3CmpBasket->getD3GtmAddToCartAmountArticles()}]
|
||||||
[{*$smarty.block.parent*}]
|
[{*$smarty.block.parent*}]
|
||||||
@ -12,50 +12,50 @@
|
|||||||
[{block name="d3_ga4_add_to_cart_list_block"}]
|
[{block name="d3_ga4_add_to_cart_list_block"}]
|
||||||
[{capture name="d3_ga4_add_to_cart_listtpl"}]
|
[{capture name="d3_ga4_add_to_cart_listtpl"}]
|
||||||
[{strip}]
|
[{strip}]
|
||||||
dataLayer.push({"event": null, "eventLabel": null, "ecommerce": null}); /* Clear the previous ecommerce object. */
|
|
||||||
|
|
||||||
[{*** Debug cases ***}]
|
$(document).ready(function() {
|
||||||
[{*event.preventDefault();*}]
|
$('#toBasket').on('click', function() {
|
||||||
|
dataLayer.push({"event": null, "eventLabel": null, "ecommerce": null}); /* Clear the previous ecommerce object. */
|
||||||
|
|
||||||
let iArtQuantity = $("[{$htmlIdAmountOfArticles}]").val();
|
[{*** Debug cases ***}]
|
||||||
let iArtQuantityAdded = [{$oGtmAmountArticlesAdded}];
|
[{*event.preventDefault();*}]
|
||||||
|
|
||||||
if(!iArtQuantity && (iArtQuantityAdded === 1)){
|
let iArtQuantity = $("[{$htmlIdAmountOfArticles}]").val();
|
||||||
iArtQuantity = 1;
|
let iPriceValue = [{$d3PriceObject->getPrice()}];
|
||||||
}else{
|
let iSumPrice = iArtQuantity*iPriceValue;
|
||||||
iArtQuantity = iArtQuantityAdded;
|
|
||||||
}
|
|
||||||
|
|
||||||
dataLayer.push({
|
dataLayer.push({
|
||||||
'isAddToBasket': true,
|
'isAddToBasket': true,
|
||||||
'event':'add_to_cart',
|
'event':'add_to_cart',
|
||||||
'eventLabel': 'add_to_cart',
|
'eventLabel': 'add_to_cart',
|
||||||
'ecommerce': {
|
'ecommerce': {
|
||||||
'currency': "[{$currency->name}]",
|
'currency': "[{$currency->name}]",
|
||||||
'value': iArtQuantity*[{$d3PriceObject->getPrice()}],
|
'value': parseInt(iSumPrice.toFixed(2)),
|
||||||
'items': [
|
'items': [
|
||||||
{
|
{
|
||||||
'item_id': '[{$oGtmProduct->getFieldData('oxartnum')}]',
|
'item_id': '[{$oGtmProduct->getFieldData('oxartnum')}]',
|
||||||
'item_name': '[{$oGtmProduct->getFieldData('oxtitle')}]',
|
'item_name': '[{$oGtmProduct->getFieldData('oxtitle')}]',
|
||||||
'price': [{$d3PriceObject->getPrice()}],
|
'price': [{$d3PriceObject->getPrice()}],
|
||||||
'item_brand': '[{if $gtmManufacturer}][{$gtmManufacturer->oxmanufacturers__oxtitle->value}][{/if}]',
|
'item_brand': '[{if $gtmManufacturer}][{$gtmManufacturer->oxmanufacturers__oxtitle->value}][{/if}]',
|
||||||
'item_variant': '[{if $oGtmProduct->getFieldData('oxvarselect')}][{$oGtmProduct->getFieldData('oxvarselect')}][{/if}]',
|
'item_variant': '[{if $oGtmProduct->getFieldData('oxvarselect')}][{$oGtmProduct->getFieldData('oxvarselect')}][{/if}]',
|
||||||
[{if $gtmCategory}]
|
[{if $gtmCategory}]
|
||||||
'item_category': '[{$gtmCategory->getSplitCategoryArray(0, true)}]',
|
'item_category': '[{$gtmCategory->getSplitCategoryArray(0, true)}]',
|
||||||
'item_category_2':'[{$gtmCategory->getSplitCategoryArray(1, true)}]',
|
'item_category_2':'[{$gtmCategory->getSplitCategoryArray(1, true)}]',
|
||||||
'item_category_3':'[{$gtmCategory->getSplitCategoryArray(2, true)}]',
|
'item_category_3':'[{$gtmCategory->getSplitCategoryArray(2, true)}]',
|
||||||
'item_category_4':'[{$gtmCategory->getSplitCategoryArray(3, true)}]',
|
'item_category_4':'[{$gtmCategory->getSplitCategoryArray(3, true)}]',
|
||||||
'item_list_name':'[{$gtmCategory->getSplitCategoryArray()}]',
|
'item_list_name':'[{$gtmCategory->getSplitCategoryArray()}]',
|
||||||
[{/if}]
|
[{/if}]
|
||||||
'quantity': iArtQuantity
|
'quantity': iArtQuantity
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}[{if $oViewConf->isDebugModeOn()}],
|
}[{if $oViewConf->isDebugModeOn()}],
|
||||||
'debug_mode': 'true'
|
'debug_mode': 'true'
|
||||||
[{/if}]
|
[{/if}]
|
||||||
|
});
|
||||||
|
});
|
||||||
});
|
});
|
||||||
[{/strip}]
|
[{/strip}]
|
||||||
[{/capture}]
|
[{/capture}]
|
||||||
[{oxscript add=$smarty.capture.d3_ga4_add_to_cart_listtpl}]
|
[{oxscript add=$smarty.capture.d3_ga4_add_to_cart_listtpl}]
|
||||||
[{/block}]
|
[{/block}]
|
||||||
[{/if}]
|
[{/if}]
|
10
CHANGELOG.md
10
CHANGELOG.md
@ -6,6 +6,16 @@ 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
|
||||||
|
### Fixed
|
||||||
|
- missing parameters for widget.php call
|
||||||
|
|
||||||
## [2.20.1](https://git.d3data.de/D3Public/GoogleAnalytics4/compare/2.20.0...2.20.1) - 2024-09-11
|
## [2.20.1](https://git.d3data.de/D3Public/GoogleAnalytics4/compare/2.20.0...2.20.1) - 2024-09-11
|
||||||
### Fixed
|
### Fixed
|
||||||
- missing currency name in begin_checkout template
|
- missing currency name in begin_checkout template
|
||||||
|
@ -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 .'"';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
43
Modules/Core/WidgetControl.php
Normal file
43
Modules/Core/WidgetControl.php
Normal file
@ -0,0 +1,43 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace D3\GoogleAnalytics4\Modules\Core;
|
||||||
|
|
||||||
|
use OxidEsales\EshopCommunity\Core\Registry;
|
||||||
|
|
||||||
|
class WidgetControl extends WidgetControl_parent{
|
||||||
|
protected function getFrontendStartControllerKey() // phpcs:ignore PSR2.Methods.MethodDeclaration.Underscore
|
||||||
|
{
|
||||||
|
/*
|
||||||
|
* array (
|
||||||
|
'force_sid' => '2pistlaubiq58qtg3moudei0la',
|
||||||
|
'lang' => '0',
|
||||||
|
'actcontrol' => 'details',
|
||||||
|
'anid' => '064471',
|
||||||
|
'cl' => 'oxwarticledetails',
|
||||||
|
'cnid' => '159dd0f2fb2bd6e24ace53a0f1913797',
|
||||||
|
'listtype' => 'list',
|
||||||
|
'nocookie' => '1',
|
||||||
|
'oxwparent' => 'details',
|
||||||
|
'sid' => '2pistlaubiq58qtg3moudei0la',
|
||||||
|
'stoken' => 'A22D0F9E',
|
||||||
|
'varselid' =>
|
||||||
|
array (
|
||||||
|
0 => 'b842982bf522aa839bd88221f562fce8',
|
||||||
|
),
|
||||||
|
)
|
||||||
|
*/
|
||||||
|
$sScriptName = $_SERVER['SCRIPT_NAME'];
|
||||||
|
if($sScriptName !== '/widget.php')
|
||||||
|
{
|
||||||
|
return parent::getFrontendStartControllerKey();
|
||||||
|
}
|
||||||
|
|
||||||
|
$aParameter = $_GET;
|
||||||
|
if(is_null($aParameter['actcontrol']) and is_null($aParameter['oxwparent']))
|
||||||
|
{
|
||||||
|
return 'D3\GoogleAnalytics4\Application\Component\Widget\d3GtmStartWidget';
|
||||||
|
}
|
||||||
|
|
||||||
|
return parent::getFrontendStartControllerKey();
|
||||||
|
}
|
||||||
|
}
|
@ -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.20.1',
|
'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/',
|
||||||
@ -61,7 +61,8 @@ $aModule = [
|
|||||||
],
|
],
|
||||||
'extend' => [
|
'extend' => [
|
||||||
// Core
|
// Core
|
||||||
OEViewConfig::class => ViewConfig::class,
|
OEViewConfig::class => ViewConfig::class,
|
||||||
|
\OxidEsales\Eshop\Core\WidgetControl::class => \D3\GoogleAnalytics4\Modules\Core\WidgetControl::class,
|
||||||
|
|
||||||
// Model
|
// Model
|
||||||
OECategory::class => Category::class,
|
OECategory::class => Category::class,
|
||||||
|
Reference in New Issue
Block a user