2011-02-27 00:25:02 +01:00
|
|
|
<?php
|
|
|
|
|
2012-12-21 11:20:32 +01:00
|
|
|
/**
|
|
|
|
* This module is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation, either version 3 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This module is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* For further informations, see <http://www.gnu.org/licenses/>.
|
|
|
|
*
|
|
|
|
* @link http://www.oxidmodule.com
|
|
|
|
* @link http://www.shopmodule.com
|
2013-02-21 14:49:05 +01:00
|
|
|
* @copyright (C) D3 Data Development (Inh. Thomas Dartsch)
|
2012-12-21 11:20:32 +01:00
|
|
|
*/
|
|
|
|
|
2013-02-21 14:51:41 +01:00
|
|
|
class d3_oxcmp_utils_googleanalytics extends d3_oxcmp_utils_googleanalytics_parent
|
2011-02-27 00:25:02 +01:00
|
|
|
{
|
2011-02-27 21:21:16 +01:00
|
|
|
private $_sModId = 'd3_googleanalytics';
|
2012-12-21 11:17:54 +01:00
|
|
|
|
2012-12-21 11:20:32 +01:00
|
|
|
/**
|
|
|
|
* @return null
|
|
|
|
*/
|
2011-02-27 00:25:02 +01:00
|
|
|
public function render()
|
|
|
|
{
|
|
|
|
$ret = parent::render();
|
|
|
|
|
2012-12-21 11:20:32 +01:00
|
|
|
/** @var $oParentView oxView */
|
|
|
|
$oParentView = $this->getParent();
|
2013-04-24 12:40:35 +02:00
|
|
|
$oParentView->addTplParam('blD3GoogleAnalyticsActive', d3_cfg_mod::get($this->_d3getModId())->isActive());
|
|
|
|
$oParentView->addTplParam('oD3GASettings', d3_cfg_mod::get($this->_d3getModId()));
|
2014-05-02 16:58:43 +02:00
|
|
|
$oParentView->addTplParam('sD3GATTpl', $this->d3getGATTpl());
|
|
|
|
$oParentView->addTplParam('sD3GACreateParameter', $this->d3getCreateParameters());
|
|
|
|
$oParentView->addTplParam('sD3GASendPageViewParameter', $this->d3getSendPageViewParameters());
|
2014-05-02 23:12:23 +02:00
|
|
|
$oParentView->addTplParam('sD3CurrentShopUrl', oxRegistry::getConfig()->getActiveShop()->getFieldData('oxurl'));
|
2011-02-27 00:25:02 +01:00
|
|
|
|
|
|
|
return $ret;
|
|
|
|
}
|
2013-02-21 14:49:05 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @return string
|
|
|
|
*/
|
2013-04-24 12:40:35 +02:00
|
|
|
private function _d3getModId()
|
2013-02-21 14:49:05 +01:00
|
|
|
{
|
|
|
|
return $this->_sModId;
|
|
|
|
}
|
2014-05-02 16:58:43 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @return string
|
|
|
|
*/
|
|
|
|
public function d3getGATTpl()
|
|
|
|
{
|
|
|
|
if (d3_cfg_mod::get($this->_sModId)->getValue('sD3GAType') == 'async') {
|
|
|
|
return 'd3_googleanalytics.tpl';
|
|
|
|
}
|
|
|
|
|
|
|
|
return 'd3ga_universal.tpl';
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @return string
|
|
|
|
*/
|
|
|
|
public function d3getCreateParameters()
|
|
|
|
{
|
|
|
|
$aParameter = array();
|
|
|
|
|
|
|
|
if (d3_cfg_mod::get($this->_sModId)->getValue('sD3GASetDomainName')) {
|
|
|
|
$aParameter[] = "'cookieDomain': '".d3_cfg_mod::get($this->_sModId)->getValue('sD3GASetDomainName')."'";
|
2014-05-02 23:12:23 +02:00
|
|
|
$aParameter[] = "'legacyCookieDomain': '".
|
|
|
|
d3_cfg_mod::get($this->_sModId)->getValue('sD3GASetDomainName')."'";
|
2014-05-02 16:58:43 +02:00
|
|
|
}
|
|
|
|
if (d3_cfg_mod::get($this->_sModId)->getValue('sD3GASetCookiePath')) {
|
|
|
|
$aParameter[] = "'cookiePath': '".d3_cfg_mod::get($this->_sModId)->getValue('sD3GASetCookiePath')."'";
|
|
|
|
}
|
|
|
|
if (d3_cfg_mod::get($this->_sModId)->getValue('blD3GAAllowDomainLinker')) {
|
|
|
|
$aParameter[] = "'allowLinker': true";
|
|
|
|
}
|
2014-05-05 15:50:01 +02:00
|
|
|
if (d3_cfg_mod::get($this->_sModId)->getValue('iD3GASiteSpeedSampleRate')) {
|
|
|
|
$aParameter[] = "'siteSpeedSampleRate': ".d3_cfg_mod::get($this->_sModId)->getValue('iD3GASiteSpeedSampleRate');
|
|
|
|
}
|
2014-05-02 16:58:43 +02:00
|
|
|
|
|
|
|
if (count($aParameter)) {
|
|
|
|
return ", {".implode(',', $aParameter)."}";
|
|
|
|
}
|
|
|
|
|
|
|
|
return '';
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @return string
|
|
|
|
*/
|
|
|
|
public function d3getSendPageViewParameters()
|
2014-05-05 15:50:01 +02:00
|
|
|
{
|
|
|
|
if (d3_cfg_mod::get($this->_sModId)->getValue('sD3GAType') == 'async') {
|
|
|
|
return $this->_d3getAsyncSendpageViewParameters();
|
|
|
|
}
|
|
|
|
|
|
|
|
return $this->_d3getUniversalSendPageViewParameters();
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @return string
|
|
|
|
*/
|
|
|
|
protected function _d3getAsyncSendpageViewParameters()
|
2014-05-02 16:58:43 +02:00
|
|
|
{
|
|
|
|
$aParameter = array();
|
|
|
|
|
2014-05-05 15:50:01 +02:00
|
|
|
/** @var oxUBase $oCurrentView */
|
|
|
|
$oCurrentView = oxRegistry::getConfig()->getActiveView();
|
|
|
|
$oCurrentView->getIsOrderStep();
|
|
|
|
|
|
|
|
if ($oCurrentView->getIsOrderStep()) {
|
|
|
|
$aParameter[] = "'{$oCurrentView->getClassName()}.html'";
|
|
|
|
}
|
|
|
|
|
|
|
|
if (count($aParameter)) {
|
|
|
|
return ", " . implode(',', $aParameter) . "";
|
|
|
|
}
|
|
|
|
|
|
|
|
return '';
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @return string
|
|
|
|
*/
|
|
|
|
protected function _d3getUniversalSendPageViewParameters()
|
|
|
|
{
|
|
|
|
$aParameter = array();
|
|
|
|
|
|
|
|
/** @var oxUBase $oCurrentView */
|
|
|
|
$oCurrentView = oxRegistry::getConfig()->getActiveView();
|
|
|
|
$oCurrentView->getIsOrderStep();
|
|
|
|
|
|
|
|
if ($oCurrentView->getIsOrderStep()) {
|
|
|
|
$aParameter[] = "'page': '{$oCurrentView->getClassName()}.html'";
|
|
|
|
$aParameter[] = "'title': 'Checkout: ".ucfirst($oCurrentView->getClassName())."'";
|
|
|
|
}
|
|
|
|
|
2014-05-02 16:58:43 +02:00
|
|
|
if (d3_cfg_mod::get($this->_sModId)->hasDebugMode()) {
|
|
|
|
$aParameter[] = "
|
|
|
|
'hitCallback': function() {
|
|
|
|
alert('analytics.js done sending data');
|
|
|
|
}
|
|
|
|
";
|
|
|
|
}
|
|
|
|
|
|
|
|
if (count($aParameter)) {
|
2014-05-05 15:50:01 +02:00
|
|
|
return ", {" . implode(',', $aParameter) . "}";
|
2014-05-02 16:58:43 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
return '';
|
|
|
|
}
|
|
|
|
}
|