diff --git a/copy_this/modules/d3/d3_googleanalytics/controllers/admin/d3_cfg_googleanalytics_adwords.php b/copy_this/modules/d3/d3_googleanalytics/controllers/admin/d3_cfg_googleanalytics_adwords.php index b3dfff0..30c7397 100644 --- a/copy_this/modules/d3/d3_googleanalytics/controllers/admin/d3_cfg_googleanalytics_adwords.php +++ b/copy_this/modules/d3/d3_googleanalytics/controllers/admin/d3_cfg_googleanalytics_adwords.php @@ -32,10 +32,6 @@ class d3_cfg_googleanalytics_adwords extends d3_cfg_mod_main */ public function getGaType() { - if ($this->d3GetSet()->getValue('sD3GAType') == 'async') { - return 'async'; - } - - return 'universal'; + return $this->d3GetSet()->getValue('sD3GAType'); } } diff --git a/copy_this/modules/d3/d3_googleanalytics/controllers/admin/d3_cfg_googleanalytics_campaigns.php b/copy_this/modules/d3/d3_googleanalytics/controllers/admin/d3_cfg_googleanalytics_campaigns.php index 6feef4e..cef8584 100644 --- a/copy_this/modules/d3/d3_googleanalytics/controllers/admin/d3_cfg_googleanalytics_campaigns.php +++ b/copy_this/modules/d3/d3_googleanalytics/controllers/admin/d3_cfg_googleanalytics_campaigns.php @@ -32,10 +32,6 @@ class d3_cfg_googleanalytics_campaigns extends d3_cfg_mod_main */ public function getGaType() { - if ($this->d3GetSet()->getValue('sD3GAType') == 'async') { - return 'async'; - } - - return 'universal'; + return $this->d3GetSet()->getValue('sD3GAType'); } } diff --git a/copy_this/modules/d3/d3_googleanalytics/controllers/admin/d3_cfg_googleanalytics_main.php b/copy_this/modules/d3/d3_googleanalytics/controllers/admin/d3_cfg_googleanalytics_main.php index ef34c9a..ef00096 100644 --- a/copy_this/modules/d3/d3_googleanalytics/controllers/admin/d3_cfg_googleanalytics_main.php +++ b/copy_this/modules/d3/d3_googleanalytics/controllers/admin/d3_cfg_googleanalytics_main.php @@ -32,10 +32,6 @@ class d3_cfg_googleanalytics_main extends d3_cfg_mod_main */ public function getGaType() { - if ($this->d3GetSet()->getValue('sD3GAType') == 'async') { - return 'async'; - } - - return 'universal'; + return $this->d3GetSet()->getValue('sD3GAType'); } } diff --git a/copy_this/modules/d3/d3_googleanalytics/metadata.php b/copy_this/modules/d3/d3_googleanalytics/metadata.php index ee203f2..836db15 100644 --- a/copy_this/modules/d3/d3_googleanalytics/metadata.php +++ b/copy_this/modules/d3/d3_googleanalytics/metadata.php @@ -92,14 +92,13 @@ $aModule = array( 'd3ga_universal_trustedstore.tpl' => 'd3/d3_googleanalytics/views/tpl/widget/inc/d3ga_universal_trustedstore.tpl', - 'd3_cfg_googleanalytics_main.tpl' => - 'd3/d3_googleanalytics/views/admin/tpl/d3_cfg_googleanalytics_main.tpl', - 'd3_cfg_googleanalytics_adwords.tpl' => - 'd3/d3_googleanalytics/views/admin/tpl/d3_cfg_googleanalytics_adwords.tpl', - 'd3_cfg_googleanalytics_campaigns.tpl' => - 'd3/d3_googleanalytics/views/admin/tpl/d3_cfg_googleanalytics_campaigns.tpl', - 'd3_cfg_googleanalytics_trustedstore.tpl' => - 'd3/d3_googleanalytics/views/admin/tpl/d3_cfg_googleanalytics_trustedstore.tpl', + 'd3ga_gtag.tpl' => 'd3/d3_googleanalytics/views/tpl/widget/d3ga_gtag.tpl', + 'd3ga_gtag_ecommerce.tpl' => 'd3/d3_googleanalytics/views/tpl/widget/inc/d3ga_gtag_ecommerce.tpl', + + 'd3_cfg_googleanalytics_main.tpl' => 'd3/d3_googleanalytics/views/admin/tpl/d3_cfg_googleanalytics_main.tpl', + 'd3_cfg_googleanalytics_adwords.tpl' => 'd3/d3_googleanalytics/views/admin/tpl/d3_cfg_googleanalytics_adwords.tpl', + 'd3_cfg_googleanalytics_campaigns.tpl' => 'd3/d3_googleanalytics/views/admin/tpl/d3_cfg_googleanalytics_campaigns.tpl', + 'd3_cfg_googleanalytics_trustedstore.tpl' => 'd3/d3_googleanalytics/views/admin/tpl/d3_cfg_googleanalytics_trustedstore.tpl', ), 'events' => array( 'onActivate' => 'd3install::checkUpdateStart', diff --git a/copy_this/modules/d3/d3_googleanalytics/modules/components/d3_oxcmp_utils_googleanalytics.php b/copy_this/modules/d3/d3_googleanalytics/modules/components/d3_oxcmp_utils_googleanalytics.php index fbee324..8242c9d 100644 --- a/copy_this/modules/d3/d3_googleanalytics/modules/components/d3_oxcmp_utils_googleanalytics.php +++ b/copy_this/modules/d3/d3_googleanalytics/modules/components/d3_oxcmp_utils_googleanalytics.php @@ -1,5 +1,9 @@ _sModId)->getValue('sD3GAType') == 'async') { return 'd3_googleanalytics.tpl'; + } elseif (\D3\ModCfg\Application\Model\Configuration\d3_cfg_mod::get($this->_sModId)->getValue('sD3GAType') == 'universaal') { + return 'd3ga_universal.tpl'; + } elseif (\D3\ModCfg\Application\Model\Configuration\d3_cfg_mod::get($this->_sModId)->getValue('sD3GAType') == 'gtag') { + return 'd3ga_gtag.tpl'; } - - return 'd3ga_universal.tpl'; } /** @@ -226,6 +232,16 @@ class d3_oxcmp_utils_googleanalytics extends d3_oxcmp_utils_googleanalytics_pare { $aParameter = array(); + if (\D3\ModCfg\Application\Model\Configuration\d3_cfg_mod::get($this->_sModId)->getValue('sD3GAType') == 'gtag') { + $aParameter = $this->_d3getCreateAnonymizeIpParameter($aParameter); + + /** @var oxUBase $oCurrentView */ + $oCurrentView = oxRegistry::getConfig()->getActiveView(); + $oCurrentView->getIsOrderStep(); + + $aParameter = $this->_d3getGtagSendPageViewPageParameter($oCurrentView, $aParameter); + } + $aParameter = $this->_d3getCreateDomainNameParameter($aParameter); $aParameter = $this->_d3getCreateCookiePathParameter($aParameter); $aParameter = $this->_d3getCreateDomainLinkerParameter($aParameter); @@ -246,9 +262,11 @@ class d3_oxcmp_utils_googleanalytics extends d3_oxcmp_utils_googleanalytics_pare { if (d3_cfg_mod::get($this->_sModId)->getValue('sD3GAType') == 'async') { return $this->_d3getAsyncSendpageViewParameters(); + } elseif (\D3\ModCfg\Application\Model\Configuration\d3_cfg_mod::get($this->_sModId)->getValue('sD3GAType') == 'universal') { + return $this->_d3getUniversalSendPageViewParameters(); + } elseif (\D3\ModCfg\Application\Model\Configuration\d3_cfg_mod::get($this->_sModId)->getValue('sD3GAType') == 'gtag') { + return $this->_d3getGtagSendPageViewParameters(); } - - return $this->_d3getUniversalSendPageViewParameters(); } /** @@ -292,6 +310,11 @@ class d3_oxcmp_utils_googleanalytics extends d3_oxcmp_utils_googleanalytics_pare return ''; } + protected function _d3getGtagSendPageViewParameters() + { + return ''; + } + /** * @return bool */ @@ -514,6 +537,22 @@ class d3_oxcmp_utils_googleanalytics extends d3_oxcmp_utils_googleanalytics_pare return $aParameter; } + /** + * @param $aParameter + * @return array + * @throws DBALException + * @throws DatabaseConnectionException + * @throws DatabaseErrorException + */ + protected function _d3getCreateAnonymizeIpParameter($aParameter) + { + if (\D3\ModCfg\Application\Model\Configuration\d3_cfg_mod::get($this->_sModId)->getValue('blD3GAAnonymizeIP')) { + $aParameter[] = "'anonymize_ip': true'"; + } + + return $aParameter; + } + /** * @param oxUBase $oCurrentView * @param array $aParameter @@ -540,18 +579,14 @@ class d3_oxcmp_utils_googleanalytics extends d3_oxcmp_utils_googleanalytics_pare * * @return array */ - protected function _d3getUniversalSendPageViewPageParameter($oCurrentView, $aParameter) + protected function _d3getGtagSendPageViewPageParameter($oCurrentView, $aParameter) { if ($oCurrentView->getIsOrderStep() || strtolower($oCurrentView->getClassName()) == 'thankyou') { - $aParameter[] = "'page': '/{$oCurrentView->getClassName()}.html'"; - $aParameter[] = "'title': 'Checkout: " . ucfirst($oCurrentView->getClassName()) . "'"; - - return $aParameter; + $aParameter[] = "'page_path': '/{$oCurrentView->getClassName()}.html'"; + $aParameter[] = "'page_title': 'Checkout: " . ucfirst($oCurrentView->getClassName()) . "'"; } elseif ($this->_d3HasNoPageParameter()) { - $aParameter[] = "'page': '/{$oCurrentView->getClassName()}.html'"; - $aParameter[] = "'title': '" . ucfirst($oCurrentView->getClassName()) . "'"; - - return $aParameter; + $aParameter[] = "'page_path': '/{$oCurrentView->getClassName()}.html'"; + $aParameter[] = "'page_title': '" . ucfirst($oCurrentView->getClassName()) . "'"; } return $aParameter; diff --git a/copy_this/modules/d3/d3_googleanalytics/views/admin/tpl/d3_cfg_googleanalytics_main.tpl b/copy_this/modules/d3/d3_googleanalytics/views/admin/tpl/d3_cfg_googleanalytics_main.tpl index 2995419..9ad28e3 100644 --- a/copy_this/modules/d3/d3_googleanalytics/views/admin/tpl/d3_cfg_googleanalytics_main.tpl +++ b/copy_this/modules/d3/d3_googleanalytics/views/admin/tpl/d3_cfg_googleanalytics_main.tpl @@ -142,7 +142,8 @@