diff --git a/Application/Controller/Admin/GA4AdminUserInterface_main.php b/Application/Controller/Admin/GA4AdminUserInterface_main.php index d8ae94f..b0e6a46 100644 --- a/Application/Controller/Admin/GA4AdminUserInterface_main.php +++ b/Application/Controller/Admin/GA4AdminUserInterface_main.php @@ -5,6 +5,7 @@ declare(strict_types=1); namespace D3\GoogleAnalytics4\Application\Controller\Admin; use D3\GoogleAnalytics4\Application\Model\Constants; +use D3\GoogleAnalytics4\Application\Model\ManagerHandler; use D3\GoogleAnalytics4\Application\Model\ManagerTypes; use OxidEsales\Eshop\Core\Registry; use OxidEsales\Eshop\Core\ViewConfig; @@ -20,6 +21,7 @@ class GA4AdminUserInterface_main extends \OxidEsales\Eshop\Application\Controlle $this->addTplParam('d3ViewObject', $this); $this->addTplParam('d3ViewConfObject', Registry::get(ViewConfig::class)); $this->addTplParam('d3ManagerTypeArray', oxNew(ManagerTypes::class)->getManagerList()); + $this->addTplParam('d3CurrentCMP', oxNew(ManagerHandler::class)->getCurrManager()); return $return; } diff --git a/Application/Model/CMP/Usercentrics.php b/Application/Model/CMP/Usercentrics.php index 2c4cba4..9e13404 100644 --- a/Application/Model/CMP/Usercentrics.php +++ b/Application/Model/CMP/Usercentrics.php @@ -7,8 +7,19 @@ namespace D3\GoogleAnalytics4\Application\Model\CMP; use D3\GoogleAnalytics4\Application\Model\ManagerTypes; +/** + * Used the OXID Module. + * + * Further information's: + * https://docs.oxid-esales.com/modules/usercentrics/de/latest/einfuehrung.html + * + * Usercentrics homepage: + * https://usercentrics.com + */ class Usercentrics extends ConsentManagementPlatformBaseModel { - const sCMPName = ManagerTypes::USERCENTRICS_MANUALLY; - const sAlternatename = ManagerTypes::USERCENTRICS_MODULE; + const sExternalIncludationPublicName = "( Externe Einbindung ) Usercentrics"; + const sExternalIncludationInternalName = "usercentrics"; + const sModuleIncludationPublicName = "( Modul ) Usercentrics"; + const sModuleIncludationInternalName = "oxps_usercentrics"; } \ No newline at end of file diff --git a/Application/Model/ManagerHandler.php b/Application/Model/ManagerHandler.php index c207359..3bb71ca 100644 --- a/Application/Model/ManagerHandler.php +++ b/Application/Model/ManagerHandler.php @@ -22,13 +22,32 @@ class ManagerHandler $aManagerList = $oManagerTypes->getManagerList(); - foreach ($aManagerList as $managerName){ - if ($oViewConfig->isModuleActive($managerName)){ - return $managerName; + if ($this->getModuleSettingExplicitManagerSelectValue()){ + return $this->getExplicitManager(); + } + + foreach ($aManagerList as $shopModuleId => $publicCMPName){ + if ($oViewConfig->isModuleActive($shopModuleId)){ + $this->d3SaveShopConfVar($shopModuleId); + return $shopModuleId; } } - return $this->getExplicitManager(); + return ""; + } + + /** + * @param string $sParam + * @return void + */ + public function d3SaveShopConfVar(string $sParam){ + Registry::getConfig()->saveShopConfVar( + 'select', + Constants::OXID_MODULE_ID."_HAS_STD_MANAGER", + $sParam, + Registry::getConfig()->getShopId(), + Constants::OXID_MODULE_ID + ); } /** @@ -36,7 +55,7 @@ class ManagerHandler */ public function getModuleSettingExplicitManagerSelectValue() :string { - return Registry::get(ViewConfig::class)->d3GetModuleConfigParam('_HAS_STD_MANAGER'); + return Registry::get(ViewConfig::class)->d3GetModuleConfigParam('_HAS_STD_MANAGER')?:""; } /** @@ -48,8 +67,12 @@ class ManagerHandler /** @var ManagerTypes $oManagerTypes */ $oManagerTypes = oxNew(ManagerTypes::class); - return $oManagerTypes->isManagerInList($sPotentialManagerName) + $sCMPName = $oManagerTypes->isManagerInList($sPotentialManagerName) ? $sPotentialManagerName : "NONE"; + + $this->d3SaveShopConfVar($sCMPName); + + return $sCMPName; } } \ No newline at end of file diff --git a/Application/Model/ManagerTypes.php b/Application/Model/ManagerTypes.php index f12af76..5db77ff 100644 --- a/Application/Model/ManagerTypes.php +++ b/Application/Model/ManagerTypes.php @@ -2,41 +2,24 @@ namespace D3\GoogleAnalytics4\Application\Model; +use D3\GoogleAnalytics4\Application\Model\CMP\Usercentrics; + class ManagerTypes { - #ToDo: make own classes for each of the manager - - - const EXTERNAL_SERVICE = "externalService"; - const NET_COOKIE_MANAGER = "net_cookie_manager"; + const EXTERNAL_SERVICE = "eigener Service"; + const NET_COOKIE_MANAGER = "Netensio Cookie Manager"; /** * Further information's: * https://github.com/aggrosoft/oxid-cookie-compliance */ - const AGCOOKIECOMPLIANCE = "agcookiecompliance"; + const AGCOOKIECOMPLIANCE = "Aggrosoft Cookie Compliance"; - /** - * 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"; + const CONSENTMANAGER = "Consentmanager"; - /** - * manually included usercentrics script - */ - const USERCENTRICS_MANUALLY = "USERCENTRICS"; + const COOKIEFIRST = "Cookiefirst"; - const CONSENTMANAGER = "CONSENTMANAGER"; - - const COOKIEFIRST = "COOKIEFIRST"; - - const COOKIEBOT = "COOKIEBOT"; + const COOKIEBOT = "Cookiebot"; /** * @return array @@ -47,9 +30,9 @@ class ManagerTypes "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, + Usercentrics::sModuleIncludationInternalName => Usercentrics::sModuleIncludationPublicName, + Usercentrics::sExternalIncludationInternalName => Usercentrics::sExternalIncludationPublicName, + "cmconsentmanager" => self::CONSENTMANAGER, "cookiefirst" => self::COOKIEFIRST, "cookiebot" => self::COOKIEBOT, ]; @@ -61,6 +44,6 @@ class ManagerTypes */ public function isManagerInList(string $sManager) :bool { - return in_array($sManager, $this->getManagerList(), true); + return in_array($sManager, array_keys($this->getManagerList()), true); } } \ No newline at end of file diff --git a/Application/views/admin/de/d3googleanalytics4_lang.php b/Application/views/admin/de/d3googleanalytics4_lang.php index cb4d428..54c1f32 100644 --- a/Application/views/admin/de/d3googleanalytics4_lang.php +++ b/Application/views/admin/de/d3googleanalytics4_lang.php @@ -15,8 +15,10 @@ $aLang = array( 'D3CLOSE' => 'Schließen', 'D3NONE' => '- keinen -', 'D3CONTAINERID' => 'Container-ID', + 'D3CONTAINERID_HELP' => ' Was ist die Container-ID?', 'D3ACTIVATEMOD' => 'Modul aktivieren', 'D3CNTRLPARAM' => 'Steuerungsparameter', + 'D3CNTRLPARAM_HELP' => ' Was ist der Steuerungsparameter?', 'D3INACTIVATEMOD' => 'Modul ist nicht aktiv! Es werde keine Funktionen ausgespielt!', // Usercentrics Dynamische Optionen 'D3USRCNTRCSDYNOPT' => 'Usercentrics Dynamische Optionen', @@ -57,7 +59,7 @@ $aLang = array( offizieller Partnerschaft mit Google ( Liste der Partner ) und unterliegen strengen Vorschriften, um ein ordnungsgemäßes Senden und Verarbeiten der Zustimmung unterliegenden Daten sicher zu stellen.', - 'D3CMP' => 'Consent Management Platform ( CMP )', + 'D3CMP' => 'Consent Management Platform ( CMP ) wählen', // Usercentrics Config // activate Individual Default Values diff --git a/Application/views/admin/tpl/d3googleanalytics4_main.tpl b/Application/views/admin/tpl/d3googleanalytics4_main.tpl index 6fb3fab..33455a4 100644 --- a/Application/views/admin/tpl/d3googleanalytics4_main.tpl +++ b/Application/views/admin/tpl/d3googleanalytics4_main.tpl @@ -35,9 +35,12 @@ [{oxmultilang ident="D3ACTIVATEMOD"}] [{if false === $d3ViewObject->d3GetModuleConfigParam('_blEnableGa4')}][{oxmultilang ident="D3INACTIVATEMOD"}][{/if}] -
- [{oxmultilang ident="D3CONTAINERID"}] - +
+
+ [{oxmultilang ident="D3CONTAINERID"}] + +
+
[{oxmultilang ident="D3CONTAINERID_HELP"}]
d3GetModuleConfigParam('_blEnableDebug')}]checked[{/if}]> @@ -72,19 +75,24 @@ [{oxmultilang ident="D3CMPUSEQ"}][{oxinputhelp ident="D3CMPUSEQ_HELP"}]
-
- [{oxmultilang ident="D3CNTRLPARAM"}] - +
+ + +
+
+
+ [{oxmultilang ident="D3CNTRLPARAM"}] + +
+
[{oxmultilang ident="D3CNTRLPARAM_HELP"}]
- -
diff --git a/CHANGELOG.md b/CHANGELOG.md index 7c03a3f..5710810 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,8 +5,43 @@ 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). ## [unreleased](https://git.d3data.de/D3Public/GoogleAnalytics4/compare/2.17.2...rel_2.x) - 2024-x + +## [2.18.2](https://git.d3data.de/D3Public/GoogleAnalytics4/compare/2.18.0...2.18.1) - 2024-06-25 +### Fixed +- oe-console apply-configuration triggers on-activate and overwrites existing values + +## [2.18.1](https://git.d3data.de/D3Public/GoogleAnalytics4/compare/2.18.0...2.18.1) - 2024-06-04 +### Fixed +- missing return statement, on null/ none + +## [2.18.0](https://git.d3data.de/D3Public/GoogleAnalytics4/compare/2.17.2...2.18.0) - 2024-06-03 ### Added - trait for generalized method +- new admin UI +- additional check for properly activated module +- admin headitem alternative +- usercentrips step/ option 2 +- group CMP-Functionalities/ properties into own Model +- additional help texts, translations, explanations +- extended docs +- auto safe on first approach ga4 + cmp-mod +- onActivate/ onDeactivate +## Changed +- declare module settings consistency +- configParamGetter +- clear dead code +- template code upgrade +- lang text +- amount of save-buttons +- Usercentrics-Class constants and adjust global-module-code to it +- CMP-output in tpl +- clear code and adjust Naming +## Fixed +- false class-property declaration +- wrong to-save param +## Removed +- deprecated and obsolete module-settings +- false composer xml-excludation ## [2.17.2](https://git.d3data.de/D3Public/GoogleAnalytics4/compare/2.17.1...2.17.2) - 2024-04-11 ### Fixed diff --git a/Docs/README.md b/Docs/README.md index 29b581b..e214985 100644 --- a/Docs/README.md +++ b/Docs/README.md @@ -5,6 +5,13 @@ Die Einbindung dieser Event-Templates erfolgt über TPL-Blöcke unter `source/mo *Hinweis: nicht alle templates sind bereits gefüllt. Wünschen Sie die Implementierung eines unausgefüllten templates? Kommen Sie auf uns zu unter https://www.d3data.de/ +## Container-ID +Diese finden Sie im "Google-Tag-Manager"-Arbeitsbereich in der Navigationsleiste. +Sie beginnt mit GTM, gefolgt von einem Bindestrich und einer Zeichenkette. + +Diese ID wird benötigt, um Google anzuweise, zu welchem "Google Tag Manager"-Arbeitsbereich die +gesammelten Daten im Daten-Stream geleitet werden sollen. + ## Steuerungsparameter Tragen Sie hier im Normalfall die ID des zu prüfenden Cookies ein. In bestimmten Fällen, müssen Sie hier alternative Werte eintragen. Diese Fälle sind bedingt diff --git a/Modules/Core/ViewConfig.php b/Modules/Core/ViewConfig.php index d5f294c..ac7b754 100644 --- a/Modules/Core/ViewConfig.php +++ b/Modules/Core/ViewConfig.php @@ -79,7 +79,7 @@ class ViewConfig extends ViewConfig_parent } // No Cookie Manager in use - if (!$this->shallUseOwnCookieManager()) { + if (false === $this->shallUseOwnCookieManager()) { return true; } @@ -104,8 +104,8 @@ class ViewConfig extends ViewConfig_parent // UserCentrics or consentmanager if ( - $this->sCookieManagerType === ManagerTypes::USERCENTRICS_MODULE - or $this->sCookieManagerType === ManagerTypes::USERCENTRICS_MANUALLY + $this->sCookieManagerType === Usercentrics::sModuleIncludationInternalName + or $this->sCookieManagerType === Usercentrics::sExternalIncludationInternalName or $this->sCookieManagerType === ManagerTypes::CONSENTMANAGER or $this->sCookieManagerType === ManagerTypes::COOKIEFIRST or $this->sCookieManagerType === ManagerTypes::COOKIEBOT @@ -134,8 +134,8 @@ class ViewConfig extends ViewConfig_parent } if ( - $this->sCookieManagerType === ManagerTypes::USERCENTRICS_MODULE - or $this->sCookieManagerType === ManagerTypes::USERCENTRICS_MANUALLY + $this->sCookieManagerType === Usercentrics::sModuleIncludationInternalName + or $this->sCookieManagerType === Usercentrics::sExternalIncludationInternalName ) { return 'data-usercentrics="' . $sControlParameter . '" type="text/plain" async=""'; @@ -173,7 +173,7 @@ class ViewConfig extends ViewConfig_parent public function isGtmConsentModeSetActivated() :bool { - return $this->d3GetModuleConfigParam("_blEnableConsentMode"); + return $this->d3GetModuleConfigParam("_blEnableConsentMode")?: false; } public function getGtmDataLayer() @@ -215,7 +215,7 @@ class ViewConfig extends ViewConfig_parent public function isDebugModeOn() :bool { - return $this->d3GetModuleConfigParam("_blEnableDebug"); + return $this->d3GetModuleConfigParam("_blEnableDebug")?: false; } /** @@ -225,7 +225,7 @@ class ViewConfig extends ViewConfig_parent */ public function getServerSidetaggingJsDomain() :string { - return $this->d3GetModuleConfigParam("_sServersidetagging_js"); + return $this->d3GetModuleConfigParam("_sServersidetagging_js")?: ""; } /** @@ -235,7 +235,7 @@ class ViewConfig extends ViewConfig_parent */ public function getServerSidetaggingNoJsDomain() :string { - return $this->d3GetModuleConfigParam('_sServersidetagging_nojs'); + return $this->d3GetModuleConfigParam('_sServersidetagging_nojs')?: ""; } /** @@ -252,7 +252,10 @@ class ViewConfig extends ViewConfig_parent */ public function d3IsUsercentricsCMPChosen() :bool { - return (bool) ($this->d3GetModuleConfigParam('_HAS_STD_MANAGER') === Usercentrics::sCMPName - or $this->d3GetModuleConfigParam('_HAS_STD_MANAGER') === Usercentrics::sAlternatename); + $sCMPPubName = $this->d3GetModuleConfigParam('_HAS_STD_MANAGER'); + $aPossibleCMP = (oxNew(ManagerTypes::class))->getManagerList(); + + return (bool) ($sCMPPubName === Usercentrics::sExternalIncludationInternalName + or $sCMPPubName === Usercentrics::sModuleIncludationInternalName); } } \ No newline at end of file diff --git a/Setup/Actions.php b/Setup/Actions.php new file mode 100644 index 0000000..8d37da3 --- /dev/null +++ b/Setup/Actions.php @@ -0,0 +1,44 @@ +d3GetModuleConfigParam($sSettingName)) !== trim($sSettingValue)){ + $sSettingValue = trim($this->d3GetModuleConfigParam($sSettingName)); + } + + $oConfig->saveShopConfVar( + $sVarType, + Constants::OXID_MODULE_ID.$sSettingName, + $sSettingValue, + $oConfig->getShopId(), + Constants::OXID_MODULE_ID + ); + } + + /** + * @param string $configParamName + * @return mixed + */ + public function d3GetModuleConfigParam(string $configParamName) + { + return Registry::get(ViewConfig::class)->d3GetModuleConfigParam($configParamName); + } +} \ No newline at end of file diff --git a/Setup/Events.php b/Setup/Events.php new file mode 100644 index 0000000..30ac24e --- /dev/null +++ b/Setup/Events.php @@ -0,0 +1,37 @@ +d3SaveDefaultSettings( + 'str', + '_sServersidetagging_js', + 'https://www.googletagmanager.com/gtm.js' + ); + $oActions->d3SaveDefaultSettings( + 'str', + '_sServersidetagging_nojs', + 'https://www.googletagmanager.com/ns.html' + ); + $oActions->d3SaveDefaultSettings( + 'str', + '_sContainerID', + 'GTM-' + ); + } + + /** + * @return void + */ + public static function onDeactivate(){} +} \ No newline at end of file diff --git a/metadata.php b/metadata.php index a6bef84..9addf64 100755 --- a/metadata.php +++ b/metadata.php @@ -50,7 +50,7 @@ $aModule = [ Die Entwicklung basiert auf einem Fork von Marat Bedoev - Github-Link ", 'thumbnail' => 'thumbnail.png', - 'version' => 'Dev-2.18.0', + 'version' => '2.18.2', 'author' => 'Data Development (Inh.: Thomas Dartsch)', 'email' => 'support@shopmodule.com', 'url' => 'https://www.oxidmodule.com/', @@ -175,5 +175,9 @@ $aModule = [ 'file' => '/Application/views/blocks/remove_from_cart.tpl', 'position' => 150 ] - ] + ], + 'events' => [ + 'onActivate' => '\D3\GoogleAnalytics4\Setup\Events::onActivate', + 'onDeactivate' => '\D3\GoogleAnalytics4\Setup\Events::onDeactivate', + ], ]; \ No newline at end of file