Compare commits
68 Commits
Author | SHA1 | Date | |
---|---|---|---|
e48b21022c | |||
b4bf91660e | |||
3d62993dfc | |||
679a49823c | |||
106fea9c91 | |||
13132e6da0 | |||
5c478124bc | |||
12613357b3 | |||
95e0cab68c | |||
1d194d445a | |||
bf3fee5ce5 | |||
3c280a3adb | |||
6217524828 | |||
5ef600ff2a | |||
a40d922f42 | |||
dae5f66f81 | |||
347e551194 | |||
000c49c56b | |||
002cc69d2a | |||
af78809ae5 | |||
d531ba648b | |||
a0c650fca3 | |||
af341a984b | |||
122dd4cf53 | |||
27798703b0 | |||
8eb734be8a | |||
616f31ecba | |||
527eec1355 | |||
1966d3008e | |||
bd51b37159 | |||
718b60e12c | |||
d4df87bfff | |||
63007e9b02 | |||
5fe656988c | |||
9cb3a54824 | |||
2f6fd8a31c | |||
8f9ed021d6 | |||
0ef3d3373a | |||
fd2b4a5bbe | |||
1c0d55bdc3 | |||
7c1f99e678 | |||
126e746651 | |||
1c45a16356 | |||
1589f202a9 | |||
55bd7b7fb4 | |||
3c1e6a11ff | |||
9ac78a0d43 | |||
e2bcb34051 | |||
4ea0c19d7b | |||
56740f1f10 | |||
daed30a585 | |||
48d411ac3f | |||
b530366cb8 | |||
975d07056a | |||
24bf113d30 | |||
ca6a810fa3 | |||
62b382eadf | |||
45d8e45137 | |||
70f2308575 | |||
6eb15ec080 | |||
d722c46a74 | |||
d847a34e99 | |||
7b55d1d57c | |||
a25be1069c | |||
5200232a32 | |||
bcd785774b | |||
5ba613df30 | |||
a1dc0a6a58 |
53
Application/Model/ManagerHandler.php
Normal file
53
Application/Model/ManagerHandler.php
Normal file
@ -0,0 +1,53 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace D3\GoogleAnalytics4\Application\Model;
|
||||||
|
|
||||||
|
use OxidEsales\Eshop\Core\Registry;
|
||||||
|
use OxidEsales\Eshop\Core\ViewConfig;
|
||||||
|
|
||||||
|
class ManagerHandler
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function getCurrManager() :string
|
||||||
|
{
|
||||||
|
/** @var ManagerTypes $oManagerTypes */
|
||||||
|
$oManagerTypes = oxNew(ManagerTypes::class);
|
||||||
|
|
||||||
|
/** @var ViewConfig $oViewConfig */
|
||||||
|
$oViewConfig = oxNew(ViewConfig::class);
|
||||||
|
|
||||||
|
$aManagerList = $oManagerTypes->getManagerList();
|
||||||
|
|
||||||
|
foreach ($aManagerList as $managerName){
|
||||||
|
if ($oViewConfig->isModuleActive($managerName)){
|
||||||
|
return $managerName;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return $this->getExplicitManager();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function getModuleSettingExplicitManagerSelectValue() :string
|
||||||
|
{
|
||||||
|
return Registry::getConfig()->getConfigParam('d3_gtm_settings_HAS_STD_MANAGER');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function getExplicitManager() :string
|
||||||
|
{
|
||||||
|
$sPotentialManagerName = $this->getModuleSettingExplicitManagerSelectValue();
|
||||||
|
|
||||||
|
/** @var ManagerTypes $oManagerTypes */
|
||||||
|
$oManagerTypes = oxNew(ManagerTypes::class);
|
||||||
|
return $oManagerTypes->isManagerInList($sPotentialManagerName)
|
||||||
|
? $sPotentialManagerName
|
||||||
|
: "NONE";
|
||||||
|
}
|
||||||
|
}
|
60
Application/Model/ManagerTypes.php
Normal file
60
Application/Model/ManagerTypes.php
Normal file
@ -0,0 +1,60 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace D3\GoogleAnalytics4\Application\Model;
|
||||||
|
|
||||||
|
class ManagerTypes
|
||||||
|
{
|
||||||
|
#ToDo: make own classes for each of the manager
|
||||||
|
|
||||||
|
|
||||||
|
const EXTERNAL_SERVICE = "externalService";
|
||||||
|
const NET_COOKIE_MANAGER = "net_cookie_manager";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Further information's:
|
||||||
|
* https://github.com/aggrosoft/oxid-cookie-compliance
|
||||||
|
*/
|
||||||
|
const AGCOOKIECOMPLIANCE = "agcookiecompliance";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Used the OXID Module.
|
||||||
|
*
|
||||||
|
* Further information's:
|
||||||
|
* https://docs.oxid-esales.com/modules/usercentrics/de/latest/einfuehrung.html
|
||||||
|
*
|
||||||
|
* Usercentrics homepage:
|
||||||
|
* https://usercentrics.com
|
||||||
|
*/
|
||||||
|
const USERCENTRICS_MODULE = "oxps_usercentrics";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* manually included usercentrics script
|
||||||
|
*/
|
||||||
|
const USERCENTRICS_MANUALLY = "USERCENTRICS";
|
||||||
|
|
||||||
|
const CONSENTMANAGER = "CONSENTMANAGER";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
public function getManagerList(): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
"externalService" => self::EXTERNAL_SERVICE,
|
||||||
|
"agcookiecompliance" => self::AGCOOKIECOMPLIANCE,
|
||||||
|
"net_cookie_manager" => self::NET_COOKIE_MANAGER,
|
||||||
|
"oxps_usercentrics" => self::USERCENTRICS_MODULE,
|
||||||
|
"usercentrics" => self::USERCENTRICS_MANUALLY,
|
||||||
|
"consentmanager" => self::CONSENTMANAGER
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param string $sManager
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
|
public function isManagerInList(string $sManager) :bool
|
||||||
|
{
|
||||||
|
return in_array($sManager, $this->getManagerList(), true);
|
||||||
|
}
|
||||||
|
}
|
@ -1,56 +1,47 @@
|
|||||||
[{$smarty.block.parent}]
|
[{$smarty.block.parent}]
|
||||||
|
|
||||||
[{assign var="d3ProductObject" value=$oView->getProduct()}]
|
[{* variable $gtmProduct is passed from parent tempalte *}]
|
||||||
[{assign var="d3PriceObject" value=$d3ProductObject->getPrice()}]
|
[{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}]
|
[{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) {
|
$("#toBasket").click(function(event) {
|
||||||
|
dataLayer.push({"event": null, "eventLabel": null, "ecommerce": null}); /* Clear the previous ecommerce object. */
|
||||||
|
|
||||||
[{*** Debug cases ***}]
|
let itemCategories = '[{if $gtmCategory}][{$gtmCategory->getLink()|parse_url:5|ltrim:"/"|rtrim:"/"}][{else}]no category[{/if}]'.split('/');
|
||||||
[{*event.preventDefault();*}]
|
|
||||||
|
|
||||||
let iArtQuantity = $("#amountToBasket").val();
|
[{*** Debug cases ***}]
|
||||||
|
[{*event.preventDefault();*}]
|
||||||
|
|
||||||
dataLayer.push({
|
let iArtQuantity = $("#amountToBasket").val();
|
||||||
'isAddToBasket': true,
|
|
||||||
'event':'add_to_cart',
|
dataLayer.push({
|
||||||
'eventLabel': 'add_to_cart',
|
'isAddToBasket': true,
|
||||||
'ecommerce': {
|
'event':'add_to_cart',
|
||||||
'currency': "[{$currency->name}]",
|
'eventLabel': 'add_to_cart',
|
||||||
'value': iArtQuantity*[{$d3PriceObject->getPrice()}],
|
'ecommerce': {
|
||||||
'items': [
|
'currency': "[{$currency->name}]",
|
||||||
{
|
'value': iArtQuantity*[{$d3PriceObject->getPrice()}],
|
||||||
'item_id': '[{$gtmProduct->getFieldData('oxartnum')}]',
|
'items': [
|
||||||
'item_name': '[{$gtmProduct->getFieldData('oxtitle')}]',
|
{
|
||||||
'price': [{$d3PriceObject->getPrice()}],
|
'item_id': '[{$gtmProduct->getFieldData('oxartnum')}]',
|
||||||
'item_brand': '[{if $gtmManufacturer}][{$gtmManufacturer->oxmanufacturers__oxtitle->value}][{/if}]',
|
'item_name': '[{$gtmProduct->getFieldData('oxtitle')}]',
|
||||||
'item_variant': '[{if $gtmProduct->getFieldData('oxvarselect')}][{$gtmProduct->getFieldData('oxvarselect')}][{/if}]',
|
'price': [{$d3PriceObject->getPrice()}],
|
||||||
'item_category': itemCategories[0] || 'no category',
|
'item_brand': '[{if $gtmManufacturer}][{$gtmManufacturer->oxmanufacturers__oxtitle->value}][{/if}]',
|
||||||
'item_category_2':itemCategories[1] || '',
|
'item_variant': '[{if $gtmProduct->getFieldData('oxvarselect')}][{$gtmProduct->getFieldData('oxvarselect')}][{/if}]',
|
||||||
'item_category_3':itemCategories[2] || '',
|
'item_category': itemCategories[0] || 'no category',
|
||||||
'item_category_4':itemCategories[3] || '',
|
'item_category_2':itemCategories[1] || '',
|
||||||
'quantity': iArtQuantity
|
'item_category_3':itemCategories[2] || '',
|
||||||
}
|
'item_category_4':itemCategories[3] || '',
|
||||||
]
|
'quantity': iArtQuantity
|
||||||
|
}
|
||||||
|
]
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
[{/block}]
|
[{/block}]
|
||||||
[{/capture}]
|
[{/capture}]
|
||||||
[{oxscript add=$d3_ga4_add_to_cart}]
|
[{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()}]
|
|
||||||
|
|
||||||
<script>
|
|
||||||
dataLayer.push({"event": null, "eventLabel": null, "ecommerce": null}); /* Clear the previous ecommerce object. */
|
|
||||||
|
|
||||||
let itemCategories = '[{if $gtmCategory}][{$gtmCategory->getLink()|parse_url:5|ltrim:"/"|rtrim:"/"}][{else}]no category[{/if}]'.split('/');
|
|
||||||
|
|
||||||
</script>
|
|
||||||
[{/strip}]
|
|
@ -1,36 +1,36 @@
|
|||||||
[{$smarty.block.parent}]
|
[{$smarty.block.parent}]
|
||||||
[{assign var="gtmProducts" value=$oView->getArticleList()}]
|
[{assign var="gtmProducts" value=$oView->getArticleList()}]
|
||||||
|
|
||||||
[{assign var="breadCrumb" value=''}]
|
[{assign var="breadCrumb" value=''}]
|
||||||
|
|
||||||
[{if $gtmProducts|@count}]
|
[{if $gtmProducts|@count}]
|
||||||
[{strip}]
|
[{strip}]
|
||||||
<script>
|
<script>
|
||||||
/* ga4 */
|
/* ga4 */
|
||||||
dataLayer.push({ecommerce: null});
|
dataLayer.push({ecommerce: null});
|
||||||
dataLayer.push({
|
dataLayer.push({
|
||||||
'event':'view_item_list',
|
'event':'view_item_list',
|
||||||
'event_name': 'view_item_list',
|
'event_name': 'view_item_list',
|
||||||
'ecommerce': {
|
'ecommerce': {
|
||||||
'item_list_id': '[{$oView->getCategoryId()}]',
|
'item_list_id': '[{$oView->getCategoryId()}]',
|
||||||
'item_list_name': '[{foreach from=$oView->getBreadCrumb() item=sCrum}][{if $sCrum.title }][{$breadCrumb|cat:$sCrum.title|cat:" > "}][{/if}][{/foreach}]',
|
'item_list_name': '[{foreach from=$oView->getBreadCrumb() item=sCrum}][{if $sCrum.title }][{$breadCrumb|cat:$sCrum.title|cat:" > "}][{/if}][{/foreach}]',
|
||||||
'items': [
|
'items': [
|
||||||
[{foreach from=$gtmProducts name="gtmProducts" item="gtmProduct"}]
|
[{foreach from=$gtmProducts name="gtmProducts" item="gtmProduct"}]
|
||||||
[{assign var="d3PriceObject" value=$gtmProduct->getPrice()}]
|
[{assign var="d3PriceObject" value=$gtmProduct->getPrice()}]
|
||||||
[{assign var="gtmManufacturer" value=$gtmProduct->getManufacturer()}]
|
[{assign var="gtmManufacturer" value=$gtmProduct->getManufacturer()}]
|
||||||
[{if !$gtmCategory}][{assign var="gtmCategory" value=$gtmProduct->getCategory()}][{/if}]
|
[{if !$gtmCategory}][{assign var="gtmCategory" value=$gtmProduct->getCategory()}][{/if}]
|
||||||
{
|
{
|
||||||
'item_id': '[{$gtmProduct->getFieldData("oxartnum")}]',
|
'item_id': '[{$gtmProduct->getFieldData("oxartnum")}]',
|
||||||
'item_name': '[{$gtmProduct->getFieldData("oxtitle")}]',
|
'item_name': '[{$gtmProduct->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_category': '[{if $gtmCategory}][{$gtmCategory->getLink()|parse_url:5|ltrim:"/"|rtrim:"/"}][{else}]-[{/if}]',
|
'item_category': '[{if $gtmCategory}][{$gtmCategory->getLink()|parse_url:5|ltrim:"/"|rtrim:"/"}][{else}]-[{/if}]',
|
||||||
'quantity': 1
|
'quantity': 1
|
||||||
}[{if !$smarty.foreach.gtmProducts.last}],[{/if}]
|
}[{if !$smarty.foreach.gtmProducts.last}],[{/if}]
|
||||||
[{/foreach}]
|
[{/foreach}]
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
[{/strip}]
|
[{/strip}]
|
||||||
[{/if}]
|
[{/if}]
|
68
CHANGELOG.md
68
CHANGELOG.md
@ -4,6 +4,74 @@ 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/),
|
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).
|
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
||||||
|
|
||||||
|
## [2.7.0](https://git.d3data.de/D3Public/GoogleAnalytics4/compare/2.6.0...2.7.0) - 2023-06-19
|
||||||
|
### Changed
|
||||||
|
- add_to_cart event template-structure
|
||||||
|
|
||||||
|
## [2.6.0](https://git.d3data.de/D3Public/GoogleAnalytics4/compare/2.5.0...2.6.0) - 2023-05-31
|
||||||
|
### Added
|
||||||
|
- add settings to explicit choose an external service (usercentrics/ consentmanager)
|
||||||
|
- position to block-extension
|
||||||
|
- extended instructions to check for in readme
|
||||||
|
### Fixed
|
||||||
|
- usercentrics script
|
||||||
|
- missing right articleList-getter
|
||||||
|
### Changed
|
||||||
|
- view_item_list-template block extension
|
||||||
|
- cookieManager handling
|
||||||
|
### Removed
|
||||||
|
- additional check for cookieManagerType
|
||||||
|
|
||||||
|
## [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
|
||||||
|
- usercentrics defined script attributes
|
||||||
|
- cookie-manager evaluation
|
||||||
|
### Changed
|
||||||
|
- genuine clean up of base-js-files
|
||||||
|
|
||||||
|
## [2.3.3](https://git.d3data.de/D3Public/GoogleAnalytics4/compare/2.3.2...2.3.3) - 2023-03-20
|
||||||
|
### Fixed
|
||||||
|
- metadata file path for view_item
|
||||||
|
|
||||||
|
## [2.3.2](https://git.d3data.de/D3Public/GoogleAnalytics4/compare/2.2.2...2.3.2) - 2023-03-17
|
||||||
|
### Added
|
||||||
|
- Aggrosoft-Cookie-Consent compatibility
|
||||||
|
### Fixed
|
||||||
|
- wrong function for pageview on thankyou page
|
||||||
|
### Deleted
|
||||||
|
- unused files
|
||||||
|
|
||||||
|
## [2.2.2](https://git.d3data.de/D3Public/GoogleAnalytics4/compare/2.2.1...2.2.2) - 2023-02-22
|
||||||
|
### Fixed
|
||||||
|
- price formatting in view_cart
|
||||||
|
|
||||||
|
## [2.2.1](https://git.d3data.de/D3Public/GoogleAnalytics4/compare/2.1.1...2.2.1) - 2023-02-21
|
||||||
|
### Added
|
||||||
|
- cookie handling
|
||||||
|
|
||||||
|
## [2.1.1](https://git.d3data.de/D3Public/GoogleAnalytics4/compare/2.1...2.1.1) - 2023-01-27
|
||||||
|
### Fixed
|
||||||
|
- add missing class import
|
||||||
|
|
||||||
|
## [2.1](https://git.d3data.de/D3Public/GoogleAnalytics4/compare/2.0...2.1) - 2023-01-27
|
||||||
|
### Added
|
||||||
|
- block section for add_to_basket js
|
||||||
|
- template block order positions
|
||||||
|
|
||||||
|
## [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
|
## [1.8.0](https://git.d3data.de/D3Public/GoogleAnalytics4/compare/1.7.0...1.8.0) - 2023-05-31
|
||||||
### Fixed
|
### Fixed
|
||||||
- bug in explicit manager selection
|
- bug in explicit manager selection
|
||||||
|
@ -12,7 +12,7 @@ Für den geregelten Ablauf sind folgende Blöcke nötig:
|
|||||||
- Datei: page/search/search.tpl
|
- Datei: page/search/search.tpl
|
||||||
- GA4 Event: view_search_results
|
- GA4 Event: view_search_results
|
||||||
- Artikelliste
|
- Artikelliste
|
||||||
- Blockname: page_list_productlist
|
- Blockname: page_list_productlist (muss hinzugefügt werden)
|
||||||
- Datei: page/list/list.tpl
|
- Datei: page/list/list.tpl
|
||||||
- GA4 Event: view_item_list
|
- GA4 Event: view_item_list
|
||||||
- Detailseite
|
- Detailseite
|
||||||
@ -65,4 +65,12 @@ Aktivieren Sie anschließend diese Weiche. Setzen Sie den Haken bei "Eigenen Coo
|
|||||||
- [OXID Cookie Management powered by usercentrics](https://docs.oxid-esales.com/modules/usercentrics/de/latest/einfuehrung.html)
|
- [OXID Cookie Management powered by usercentrics](https://docs.oxid-esales.com/modules/usercentrics/de/latest/einfuehrung.html)
|
||||||
- In der Usercentrics-Verwaltung die Services "Google Analytics" und "Google Tag Manager" anlegen
|
- In der Usercentrics-Verwaltung die Services "Google Analytics" und "Google Tag Manager" anlegen
|
||||||
- Den Service ```Google Tag Manager``` in den Moduleinstellungen des 'Google Analytics 4' unter
|
- Den Service ```Google Tag Manager``` in den Moduleinstellungen des 'Google Analytics 4' unter
|
||||||
```Einstell. > Cookie Manager Einstellungen > Cookie-ID``` eintragen
|
Google Tag Manager eintragen
|
||||||
|
-
|
||||||
|
- [Consent Management Provider](https://www.consentmanager.net/)
|
||||||
|
- In der Consentmanager-Oberfläche den Anbieter "Google Tag Manager" mit der ID s905 hinzufügen
|
||||||
|
- Im Frontend, im consentmanager-Pop-up nach dem 'Google Tag Manager' suchen
|
||||||
|
- kleines Fragezeichen neben den Namen anklicken und ganz runter scrollen
|
||||||
|
- prüfen, ob ein Cookie vorgegeben ist
|
||||||
|
- sonst, in der Consentmanager-Oberfläche Cookie-Liste entsprechendes Cookie suchen und im Admin unter
|
||||||
|
```Einstell. > Cookie Manager Einstellungen > Cookie-ID``` eintragen
|
@ -12,9 +12,13 @@
|
|||||||
|
|
||||||
namespace D3\GoogleAnalytics4\Modules\Core;
|
namespace D3\GoogleAnalytics4\Modules\Core;
|
||||||
|
|
||||||
|
use D3\GoogleAnalytics4\Application\Model\ManagerHandler;
|
||||||
|
use D3\GoogleAnalytics4\Application\Model\ManagerTypes;
|
||||||
use OxidEsales\Eshop\Application\Controller\FrontendController;
|
use OxidEsales\Eshop\Application\Controller\FrontendController;
|
||||||
use OxidEsales\Eshop\Core\Config;
|
use OxidEsales\Eshop\Core\Config;
|
||||||
use OxidEsales\Eshop\Core\Registry;
|
use OxidEsales\Eshop\Core\Registry;
|
||||||
|
use OxidEsales\EshopCommunity\Internal\Container\ContainerFactory;
|
||||||
|
use OxidEsales\EshopCommunity\Internal\Framework\Module\Configuration\Bridge\ModuleSettingBridgeInterface;
|
||||||
|
|
||||||
class ViewConfig extends ViewConfig_parent
|
class ViewConfig extends ViewConfig_parent
|
||||||
{
|
{
|
||||||
@ -27,59 +31,31 @@ class ViewConfig extends ViewConfig_parent
|
|||||||
{
|
{
|
||||||
if ($this->sContainerId === null)
|
if ($this->sContainerId === null)
|
||||||
{
|
{
|
||||||
$this->sContainerId = $this->getConfig()->getConfigParam('d3_gtm_sContainerID');
|
$this->sContainerId = ContainerFactory::getInstance()
|
||||||
|
->getContainer()
|
||||||
|
->get(ModuleSettingBridgeInterface::class)
|
||||||
|
->get('d3_gtm_sContainerID', 'd3googleanalytics4');
|
||||||
}
|
}
|
||||||
return $this->sContainerId;
|
return $this->sContainerId;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return mixed
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function getModuleSettingExplicitManagerSelectValue()
|
public function defineCookieManagerType() :void
|
||||||
{
|
|
||||||
return Registry::getConfig()->getConfigParam('d3_gtm_settings_HAS_STD_MANAGER');
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return false|mixed
|
|
||||||
*/
|
|
||||||
public function getExplicitManager()
|
|
||||||
{
|
|
||||||
$sManagerName = $this->getModuleSettingExplicitManagerSelectValue();
|
|
||||||
return $sManagerName === "NONE" ? false : $sManagerName;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getCookieManagerType()
|
|
||||||
{
|
{
|
||||||
if ($this->sCookieManagerType === null)
|
if ($this->sCookieManagerType === null)
|
||||||
{
|
{
|
||||||
$this->sCookieManagerType = false;
|
/** @var ManagerHandler $oManagerHandler */
|
||||||
|
$oManagerHandler = oxNew(ManagerHandler::class);
|
||||||
$allowedManagerTypes = [
|
$this->sCookieManagerType = $oManagerHandler->getCurrManager();
|
||||||
'net_cookie_manager',
|
|
||||||
'agcookiecompliance',
|
|
||||||
'oxps_usercentrics'
|
|
||||||
];
|
|
||||||
|
|
||||||
foreach ($allowedManagerTypes as $type) {
|
|
||||||
if ($this->isModuleActive($type)) {
|
|
||||||
$this->sCookieManagerType = $type;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($this->sCookieManagerType === false and $this->getExplicitManager()){
|
|
||||||
return "externalService";
|
|
||||||
}
|
|
||||||
|
|
||||||
return $this->sCookieManagerType;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
public function shallUseOwnCookieManager()
|
public function shallUseOwnCookieManager() :bool
|
||||||
{
|
{
|
||||||
return (bool) Registry::getConfig()->getConfigParam('d3_gtm_settings_hasOwnCookieManager');
|
return (bool) Registry::getConfig()->getConfigParam('d3_gtm_settings_hasOwnCookieManager');
|
||||||
}
|
}
|
||||||
@ -93,33 +69,42 @@ class ViewConfig extends ViewConfig_parent
|
|||||||
$oConfig = Registry::getConfig();
|
$oConfig = Registry::getConfig();
|
||||||
|
|
||||||
// No Cookie Manager in use
|
// No Cookie Manager in use
|
||||||
if (false === $this->shallUseOwnCookieManager()) {
|
if (!$this->shallUseOwnCookieManager()) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$this->defineCookieManagerType();
|
||||||
|
|
||||||
$sCookieID = $oConfig->getConfigParam('d3_gtm_settings_cookieName');
|
$sCookieID = $oConfig->getConfigParam('d3_gtm_settings_cookieName');
|
||||||
|
|
||||||
// Netensio Cookie Manager
|
// Netensio Cookie Manager
|
||||||
if ($this->getCookieManagerType() == "net_cookie_manager") {
|
if ($this->sCookieManagerType === ManagerTypes::NET_COOKIE_MANAGER) {
|
||||||
$oSession = Registry::getSession();
|
$oSession = Registry::getSession();
|
||||||
$aCookies = $oSession->getVariable("aCookieSel");
|
$aCookies = $oSession->getVariable("aCookieSel");
|
||||||
|
|
||||||
return (!is_null($aCookies) && is_array($aCookies) && array_key_exists($sCookieID, $aCookies) && $aCookies[$sCookieID] == "1");
|
return (is_array($aCookies) && array_key_exists($sCookieID, $aCookies) && $aCookies[$sCookieID] == "1");
|
||||||
}
|
}
|
||||||
|
|
||||||
// Aggrosoft Cookie Consent
|
// Aggrosoft Cookie Consent
|
||||||
if ($this->getCookieManagerType() == "agcookiecompliance") {
|
if ($this->sCookieManagerType === ManagerTypes::AGCOOKIECOMPLIANCE) {
|
||||||
if (method_exists($this, "isCookieCategoryEnabled")) {
|
if (method_exists($this, "isCookieCategoryEnabled")) {
|
||||||
return $this->isCookieCategoryEnabled($sCookieID);
|
return $this->isCookieCategoryEnabled($sCookieID);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// UserCentrics or consentmanager
|
// UserCentrics or consentmanager
|
||||||
if ($this->getCookieManagerType() === "oxps_usercentrics" or $this->getCookieManagerType() === 'externalService') {
|
if (
|
||||||
|
$this->sCookieManagerType === ManagerTypes::USERCENTRICS_MODULE
|
||||||
|
or $this->sCookieManagerType === ManagerTypes::USERCENTRICS_MANUALLY
|
||||||
|
or $this->sCookieManagerType === ManagerTypes::CONSENTMANAGER
|
||||||
|
or $this->sCookieManagerType === ManagerTypes::EXTERNAL_SERVICE
|
||||||
|
)
|
||||||
|
{
|
||||||
// Always needs the script-tags delivered to the DOM.
|
// Always needs the script-tags delivered to the DOM.
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Cookie Manager not (yet) supported
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -128,25 +113,27 @@ class ViewConfig extends ViewConfig_parent
|
|||||||
* This is especially important for UserCentrics.
|
* This is especially important for UserCentrics.
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
public function getGtmScriptAttributes()
|
public function getGtmScriptAttributes() :string
|
||||||
{
|
{
|
||||||
$oConfig = Registry::getConfig();
|
$oConfig = Registry::getConfig();
|
||||||
|
$sCookieId = $oConfig->getConfigParam('d3_gtm_settings_cookieName');
|
||||||
|
|
||||||
if (false === $this->shallUseOwnCookieManager()){
|
if (false === $this->shallUseOwnCookieManager()){
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($this->getCookieManagerType() === "oxps_usercentrics" or $this->getExplicitManager() === 'USERCENTRICS') {
|
if (
|
||||||
$sCookieId = $oConfig->getConfigParam('d3_gtm_settings_cookieName');
|
$this->sCookieManagerType === ManagerTypes::USERCENTRICS_MODULE
|
||||||
|
or $this->sCookieManagerType === ManagerTypes::USERCENTRICS_MANUALLY
|
||||||
|
)
|
||||||
|
{
|
||||||
if ($sCookieId) {
|
if ($sCookieId) {
|
||||||
return 'data-usercentrics="' . $sCookieId . '" type="text/plain" async=""';
|
return 'data-usercentrics="' . $sCookieId . '" type="text/plain" async=""';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($this->getCookieManagerType() === "externalService" and $this->getExplicitManager() === 'CONSENTMANAGER') {
|
if ($this->sCookieManagerType === ManagerTypes::CONSENTMANAGER)
|
||||||
$sCookieId = $oConfig->getConfigParam('d3_gtm_settings_cookieName');
|
{
|
||||||
|
|
||||||
if ($sCookieId) {
|
if ($sCookieId) {
|
||||||
return 'async
|
return 'async
|
||||||
type="text/plain"
|
type="text/plain"
|
||||||
@ -166,7 +153,10 @@ class ViewConfig extends ViewConfig_parent
|
|||||||
{
|
{
|
||||||
if ($this->blGA4enabled === null)
|
if ($this->blGA4enabled === null)
|
||||||
{
|
{
|
||||||
$this->sContainerId = $this->getConfig()->getConfigParam('d3_gtm_blEnableGA4');
|
$this->sContainerId = ContainerFactory::getInstance()
|
||||||
|
->getContainer()
|
||||||
|
->get(ModuleSettingBridgeInterface::class)
|
||||||
|
->get('d3_gtm_blEnableGA4', 'd3googleanalytics4');
|
||||||
}
|
}
|
||||||
|
|
||||||
return $this->blGA4enabled;
|
return $this->blGA4enabled;
|
||||||
|
@ -23,16 +23,16 @@ Dieses Paket erfordert einen mit Composer installierten OXID eShop in einer in d
|
|||||||
Öffnen Sie eine Kommandozeile und navigieren Sie zum Stammverzeichnis des Shops (Elternverzeichnis von source und vendor). Führen Sie den folgenden Befehl aus. Passen Sie die Pfadangaben an Ihre Installationsumgebung an.
|
Öffnen Sie eine Kommandozeile und navigieren Sie zum Stammverzeichnis des Shops (Elternverzeichnis von source und vendor). Führen Sie den folgenden Befehl aus. Passen Sie die Pfadangaben an Ihre Installationsumgebung an.
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
php composer require d3/google-analytics4:^1
|
php composer require d3/google-analytics4:^2
|
||||||
```
|
```
|
||||||
|
|
||||||
Sofern nötig, bestätigen Sie bitte, dass Sie `package-name` erlauben, Code auszuführen.
|
Sofern nötig, bestätigen Sie bitte, dass Sie `package-name` erlauben, Code auszuführen.
|
||||||
|
|
||||||
Aktivieren Sie das Modul im Shopadmin unter "Erweiterungen -> Module".
|
Aktivieren Sie das Modul im Shopadmin unter "Erweiterungen -> Module".
|
||||||
|
|
||||||
> ### Wichtig!
|
### Wichtig!
|
||||||
> Bitte stellen Sie sicher, dass die nötigen Blöcke im OXID-Shop zur Verfügung stehen.
|
Bitte stellen Sie sicher, dass die nötigen Template-Blöcke im OXID-Shop zur Verfügung stehen.
|
||||||
> Lesen Sie mehr in der [technischen Doku](./Docs/README.md) unter "Blöcke"!
|
Lesen Sie mehr in der [technischen Doku](./Docs/README.md) unter "Blöcke"!
|
||||||
|
|
||||||
## Verwendung
|
## Verwendung
|
||||||
### Grundfunktionalität
|
### Grundfunktionalität
|
||||||
|
@ -45,7 +45,7 @@
|
|||||||
},
|
},
|
||||||
"require": {
|
"require": {
|
||||||
"php": ">=7.1",
|
"php": ">=7.1",
|
||||||
"oxid-esales/oxideshop-ce": "v6.0 - 6.3",
|
"oxid-esales/oxideshop-ce": "^6.5",
|
||||||
"google/apiclient":" ^2.0"
|
"google/apiclient":" ^2.0"
|
||||||
},
|
},
|
||||||
"autoload": {
|
"autoload": {
|
||||||
|
@ -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>
|
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' => '1.8.0',
|
'version' => '2.7.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/',
|
||||||
|
Reference in New Issue
Block a user