Compare commits
13 Commits
Author | SHA1 | Date |
---|---|---|
MaxBUhe | 106fea9c91 | |
MaxBUhe | 13132e6da0 | |
MaxBUhe | 5c478124bc | |
MaxBUhe | 12613357b3 | |
MaxBUhe | 95e0cab68c | |
MaxBUhe | 1d194d445a | |
MaxBUhe | bf3fee5ce5 | |
MaxBUhe | 3c280a3adb | |
MaxBUhe | 6217524828 | |
MaxBUhe | 5ef600ff2a | |
MaxBUhe | a40d922f42 | |
MaxBUhe | dae5f66f81 | |
MaxBUhe | 347e551194 |
|
@ -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";
|
||||
}
|
||||
}
|
|
@ -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);
|
||||
}
|
||||
}
|
|
@ -31,8 +31,10 @@ $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_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_HAS_STD_MANAGER' => 'Nutzen Sie eine der folgenden Einbindungen?<br>
|
||||
Dann wählen Sie bitte die zutreffende aus.',
|
||||
'SHOP_MODULE_d3_gtm_settings_HAS_STD_MANAGER_NONE' => '---',
|
||||
'SHOP_MODULE_d3_gtm_settings_HAS_STD_MANAGER_CONSENTMANAGER' => 'consentmanager',
|
||||
'SHOP_MODULE_d3_gtm_settings_HAS_STD_MANAGER_USERCENTRICS' => 'usercentrics',
|
||||
'SHOP_MODULE_d3_gtm_settings_cookieName' => 'CookieID',
|
||||
];
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
[{if $oViewConf->D3blShowGtmScript() && !$oViewConf->getCookieManagerType()}]
|
||||
[{if $oViewConf->D3blShowGtmScript()}]
|
||||
[{if $oViewConf->getGtmContainerId()}][{strip}]
|
||||
<!-- Google Tag Manager (noscript) -->
|
||||
<noscript>
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
[{$smarty.block.parent}]
|
||||
[{assign var="gtmProducts" value=$products}]
|
||||
[{assign var="gtmProducts" value=$oView->getArticleList()}]
|
||||
|
||||
[{assign var="breadCrumb" value=''}]
|
||||
|
||||
|
|
23
CHANGELOG.md
23
CHANGELOG.md
|
@ -4,6 +4,20 @@ 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.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
|
||||
|
@ -54,6 +68,15 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|||
### Added
|
||||
- using of ContainerFactory in ViewConfig
|
||||
|
||||
## [1.5.0](https://git.d3data.de/D3Public/GoogleAnalytics4/compare/1.4.0...1.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
|
||||
|
||||
## [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
|
||||
|
|
|
@ -12,8 +12,8 @@ Für den geregelten Ablauf sind folgende Blöcke nötig:
|
|||
- Datei: page/search/search.tpl
|
||||
- GA4 Event: view_search_results
|
||||
- Artikelliste
|
||||
- Blockname: d3Ga4_view_item_list (muss hinzugefügt werden)
|
||||
- Datei: widget/product/list.tpl
|
||||
- Blockname: page_list_productlist (muss hinzugefügt werden)
|
||||
- Datei: page/list/list.tpl
|
||||
- GA4 Event: view_item_list
|
||||
- Detailseite
|
||||
- Blockname: details_productmain_title
|
||||
|
@ -63,6 +63,6 @@ Aktivieren Sie anschließend diese Weiche. Setzen Sie den Haken bei "Eigenen Coo
|
|||
```Einstell. > Cookie Manager Einstellungen > Cookie-ID``` eintragen
|
||||
|
||||
- [OXID Cookie Management powered by usercentrics](https://docs.oxid-esales.com/modules/usercentrics/de/latest/einfuehrung.html)
|
||||
- In der Usercentrics-Verwaltung einen Service für Google Analytics anlegen
|
||||
- Den Service-Namen in den Moduleinstellungen des 'Google Analytics 4' unter
|
||||
- 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
|
||||
```Einstell. > Cookie Manager Einstellungen > Cookie-ID``` eintragen
|
|
@ -12,6 +12,8 @@
|
|||
|
||||
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\Core\Config;
|
||||
use OxidEsales\Eshop\Core\Registry;
|
||||
|
@ -37,36 +39,25 @@ 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()
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
public function defineCookieManagerType() :void
|
||||
{
|
||||
if ($this->sCookieManagerType === null)
|
||||
{
|
||||
$this->sCookieManagerType = false;
|
||||
|
||||
$allowedManagerTypes = [
|
||||
'net_cookie_manager',
|
||||
'agcookiecompliance',
|
||||
'oxps_usercentrics'
|
||||
];
|
||||
|
||||
foreach ($allowedManagerTypes as $type) {
|
||||
if ($this->isModuleActive($type)) {
|
||||
$this->sCookieManagerType = $type;
|
||||
break;
|
||||
}
|
||||
}
|
||||
/** @var ManagerHandler $oManagerHandler */
|
||||
$oManagerHandler = oxNew(ManagerHandler::class);
|
||||
$this->sCookieManagerType = $oManagerHandler->getCurrManager();
|
||||
}
|
||||
}
|
||||
|
||||
if ($this->sCookieManagerType === false and $this->getModuleConsentmanagerSettingSelectValue()){
|
||||
return "consentmanager";
|
||||
}
|
||||
|
||||
return $this->sCookieManagerType;
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
public function shallUseOwnCookieManager() :bool
|
||||
{
|
||||
return (bool) Registry::getConfig()->getConfigParam('d3_gtm_settings_hasOwnCookieManager');
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -78,29 +69,37 @@ class ViewConfig extends ViewConfig_parent
|
|||
$oConfig = Registry::getConfig();
|
||||
|
||||
// No Cookie Manager in use
|
||||
if (!$oConfig->getConfigParam('d3_gtm_settings_hasOwnCookieManager')) {
|
||||
if (!$this->shallUseOwnCookieManager()) {
|
||||
return true;
|
||||
}
|
||||
|
||||
$this->defineCookieManagerType();
|
||||
|
||||
$sCookieID = $oConfig->getConfigParam('d3_gtm_settings_cookieName');
|
||||
|
||||
// Netensio Cookie Manager
|
||||
if ($this->getCookieManagerType() == "net_cookie_manager") {
|
||||
if ($this->sCookieManagerType === ManagerTypes::NET_COOKIE_MANAGER) {
|
||||
$oSession = Registry::getSession();
|
||||
$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
|
||||
if ($this->getCookieManagerType() == "agcookiecompliance") {
|
||||
if ($this->sCookieManagerType === ManagerTypes::AGCOOKIECOMPLIANCE) {
|
||||
if (method_exists($this, "isCookieCategoryEnabled")) {
|
||||
return $this->isCookieCategoryEnabled($sCookieID);
|
||||
}
|
||||
}
|
||||
|
||||
// UserCentrics
|
||||
if ($this->getCookieManagerType() === "oxps_usercentrics" or $this->getCookieManagerType() === 'consentmanager') {
|
||||
// UserCentrics or consentmanager
|
||||
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.
|
||||
return true;
|
||||
}
|
||||
|
@ -114,21 +113,27 @@ class ViewConfig extends ViewConfig_parent
|
|||
* This is especially important for UserCentrics.
|
||||
* @return string
|
||||
*/
|
||||
public function getGtmScriptAttributes()
|
||||
public function getGtmScriptAttributes() :string
|
||||
{
|
||||
$oConfig = Registry::getConfig();
|
||||
$sCookieId = $oConfig->getConfigParam('d3_gtm_settings_cookieName');
|
||||
|
||||
if ($this->getCookieManagerType() == "oxps_usercentrics") {
|
||||
$sCookieId = $oConfig->getConfigParam('d3_gtm_settings_cookieName');
|
||||
if (false === $this->shallUseOwnCookieManager()){
|
||||
return "";
|
||||
}
|
||||
|
||||
if (
|
||||
$this->sCookieManagerType === ManagerTypes::USERCENTRICS_MODULE
|
||||
or $this->sCookieManagerType === ManagerTypes::USERCENTRICS_MANUALLY
|
||||
)
|
||||
{
|
||||
if ($sCookieId) {
|
||||
return 'type="text/plain" data-usercentrics="' . $sCookieId . '"';
|
||||
return 'data-usercentrics="' . $sCookieId . '" type="text/plain" async=""';
|
||||
}
|
||||
}
|
||||
|
||||
if ($this->getCookieManagerType() == "consentmanager") {
|
||||
$sCookieId = $oConfig->getConfigParam('d3_gtm_settings_cookieName');
|
||||
|
||||
if ($this->sCookieManagerType === ManagerTypes::CONSENTMANAGER)
|
||||
{
|
||||
if ($sCookieId) {
|
||||
return 'async
|
||||
type="text/plain"
|
||||
|
|
|
@ -30,6 +30,10 @@ Sofern nötig, bestätigen Sie bitte, dass Sie `package-name` erlauben, Code aus
|
|||
|
||||
Aktivieren Sie das Modul im Shopadmin unter "Erweiterungen -> Module".
|
||||
|
||||
### Wichtig!
|
||||
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"!
|
||||
|
||||
## Verwendung
|
||||
### Grundfunktionalität
|
||||
Nach erfolgreicher Installation finden Sie in Ihrem Shop-Admin unter "Erweiterungen > Module"
|
||||
|
|
13
metadata.php
13
metadata.php
|
@ -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.5.0',
|
||||
'version' => '2.6.0',
|
||||
'author' => 'Data Development (Inh.: Thomas Dartsch)',
|
||||
'email' => 'support@shopmodule.com',
|
||||
'url' => 'https://www.oxidmodule.com/',
|
||||
|
@ -35,7 +35,8 @@ $aModule = [
|
|||
[
|
||||
'template' => 'layout/base.tpl',
|
||||
'block' => 'head_meta_robots',
|
||||
'file' => '/Application/views/blocks/_gtm_js.tpl'
|
||||
'file' => '/Application/views/blocks/_gtm_js.tpl',
|
||||
'position' => 150
|
||||
],
|
||||
// tag manager nojs
|
||||
[
|
||||
|
@ -64,8 +65,8 @@ $aModule = [
|
|||
// Lists
|
||||
// view_item_list
|
||||
[
|
||||
'template' => 'widget/product/list.tpl',
|
||||
'block' => 'widget_product_list',
|
||||
'template' => 'page/list/list.tpl',
|
||||
'block' => 'page_list_productlist',
|
||||
'file' => '/Application/views/ga4/view_item_list.tpl',
|
||||
'position' => 150
|
||||
],
|
||||
|
@ -122,10 +123,10 @@ $aModule = [
|
|||
],
|
||||
[
|
||||
'group' => 'd3_gtm_settings_cookiemanager',
|
||||
'name' => 'd3_gtm_settings_HAS_CONSENTMANAGER',
|
||||
'name' => 'd3_gtm_settings_HAS_STD_MANAGER',
|
||||
'type' => 'select',
|
||||
'value' => 'none',
|
||||
'constraints' => 'NO|YES',
|
||||
'constraints' => 'NONE|CONSENTMANAGER|USERCENTRICS',
|
||||
],
|
||||
]
|
||||
];
|
Loading…
Reference in New Issue