added: support for multi domain use in universal tracking code (Alexander Fehler), some cleanups

This commit is contained in:
Daniel Seifert 2014-06-05 09:21:20 +00:00
parent 5dc2667124
commit 2eaa642027
10 changed files with 246 additions and 74 deletions

1
.gitattributes vendored
View File

@ -7,7 +7,6 @@ Sources/UGA_Custom_Dimensions.jpg -text
Sources/UGA_Einstellungen.jpg -text
Sources/UGA_Trichtereinrichtung.jpg -text
Sources/UGA_Trichtereinrichtung_1.jpg -text
Sources/changelog.txt -text
Sources/doku/01_asyncTracking-Dateien/cleardot.gif -text
Sources/doku/01_asyncTracking-Dateien/code_logo.gif -text
Sources/doku/01_asyncTracking-Dateien/codesite.css -text

View File

@ -1,7 +0,0 @@
3.0.0.3
- Update der precheck.php
-- 2012-12-19 -- SK --
- anpassen der Verzeichnisse + Dateien an PE/CE 4.7.x bzw. EE 5.0.x
- "alten" Trunk auslagern unter branches/trunk_bis_4.6.x
- "alte" Versionen unter Tags verschieben in neuse Verzeichnis unter tags/versionen_bis_4.6.x

View File

@ -19,6 +19,11 @@
ga('create', '[{$oD3GASettings->getValue('sD3GAId')}]', '[{$sD3CurrentShopUrl}]' [{$sD3GACreateParameter}]);
[{if $oD3GASettings->getValue('blD3GAAllowDomainLinker')}]
ga('require', 'linker');
ga('linker:autoLink', [[{$sAFEGetMoreUrls}]]);
[{/if}]
[{if $oD3GASettings->getValue('blD3GAAnonymizeIP')}]
ga('set', 'anonymizeIp', true);
[{/if}]

View File

@ -39,7 +39,7 @@ $aModule = array(
'en' => 'Provides a quick and easy integration with your Google Analytics account to your shop.',
),
'thumbnail' => 'picture.png',
'version' => '3.1.0.0',
'version' => '3.1.0.1',
'author' => 'D³ Data Development (Inh. Thomas Dartsch)',
'email' => 'support@shopmodule.com',
'url' => 'http://www.oxidmodule.com/',

View File

@ -45,26 +45,28 @@ class d3_oxcmp_utils_googleanalytics extends d3_oxcmp_utils_googleanalytics_pare
$oSet = d3_cfg_mod::get($this->_d3getModId());
/** @var $oParentView oxView */
$oParentView = $this->getParent();
$oParentView->addTplParam('blD3GoogleAnalyticsActive', $oSet->isActive());
$oParentView->addTplParam('oD3GASettings', $oSet);
$oParentView->addTplParam('sD3GATTpl', $this->d3getGATTpl());
$oParentView->addTplParam('sD3GACreateParameter', $this->d3getCreateParameters());
$oParentView->addTplParam('sD3GASendPageViewParameter', $this->d3getSendPageViewParameters());
$oParentView->addTplParam('sD3CurrentShopUrl', oxRegistry::getConfig()->getActiveShop()->getFieldData('oxurl'));
if ($oSet->isActive()) {
/** @var $oParentView oxView */
$oParentView = $this->getParent();
$oParentView->addTplParam('blD3GoogleAnalyticsActive', $oSet->isActive());
$oParentView->addTplParam('oD3GASettings', $oSet);
$oParentView->addTplParam('sD3GATTpl', $this->d3getGATTpl());
$oParentView->addTplParam('sD3GACreateParameter', $this->d3getCreateParameters());
$oParentView->addTplParam('sAFEGetMoreUrls', $this->afGetMoreUrls());
$oParentView->addTplParam('sD3GASendPageViewParameter', $this->d3getSendPageViewParameters());
$oParentView->addTplParam('sD3CurrentShopUrl', $this->d3GetCreateCurrentShopUrl());
if ($oSet->getValue('blD3GASetRemarketing')) {
$aInfos = $this->d3GetGAProdInfos();
$oParentView->addTplParam('sD3GARemarketingProdId', $this->d3GetGAProdIdList($aInfos['aArtIdList']));
$oParentView->addTplParam(
'sD3GARemarketingPrice',
$aInfos['dPrice'] > 0 ? number_format($aInfos['dPrice'], 2, '.', ''): ''
);
$oParentView->addTplParam('sD3GARemarketingPageType', $this->d3GetGAPageType());
if ($oSet->getValue('blD3GASetRemarketing')) {
$aInfos = $this->d3GetGAProdInfos();
$oParentView->addTplParam('sD3GARemarketingProdId', $this->d3GetGAProdIdList($aInfos['aArtIdList']));
$oParentView->addTplParam(
'sD3GARemarketingPrice',
$aInfos['dPrice'] > 0 ? number_format($aInfos['dPrice'], 2, '.', ''): ''
);
$oParentView->addTplParam('sD3GARemarketingPageType', $this->d3GetGAPageType());
}
}
return $ret;
}
@ -88,6 +90,59 @@ class d3_oxcmp_utils_googleanalytics extends d3_oxcmp_utils_googleanalytics_pare
return 'd3ga_universal.tpl';
}
/**
* @return string
*/
public function d3GetCreateCurrentShopUrl()
{
if (d3_cfg_mod::get($this->_sModId)->getValue('blD3GAAllowDomainLinker')) {
return 'auto';
}
return oxRegistry::getConfig()->getActiveShop()->getFieldData('oxurl');
}
/**
* @return string
*/
public function afGetMoreUrls()
{
if (false == d3_cfg_mod::get($this->_sModId)->getValue('blD3GAAllowDomainLinker')) {
return '';
}
$sSeparator = ',';
return implode($sSeparator, $this->_d3GetNonBaseLanguageUrls());
}
/**
* @return array
*/
protected function _d3GetNonBaseLanguageUrls()
{
$myConfig = oxRegistry::getConfig();
$aLanguageUrls = $myConfig->getConfigParam('aLanguageURLs');
$aUrls = array();
/** @var oxUBase $oActView */
$oActView = $myConfig->getTopActiveView();
if ($myConfig->getConfigParam('bl_perfLoadLanguages')) {
$aLanguages = oxRegistry::getLang()->getLanguageArray(null, true, true);
reset($aLanguages);
while ((list($sKey, $oVal) = each($aLanguages))) {
$aLanguages[$sKey]->link = $oActView->getLink($oVal->id);
$sUrl = str_replace('http://', '', $aLanguageUrls[$oVal->id]);
if ($aLanguageUrls[$oVal->id] != $aLanguageUrls[oxRegistry::getLang()->getBaseLanguage()]) {
$aUrls[] = "'".$sUrl."'";
}
}
}
return $aUrls;
}
/**
* @return string
*/
@ -95,24 +150,11 @@ class d3_oxcmp_utils_googleanalytics extends d3_oxcmp_utils_googleanalytics_pare
{
$aParameter = array();
if (d3_cfg_mod::get($this->_sModId)->getValue('sD3GASetDomainName')) {
$aParameter[] = "'cookieDomain': '".d3_cfg_mod::get($this->_sModId)->getValue('sD3GASetDomainName')."'";
$aParameter[] = "'legacyCookieDomain': '".
d3_cfg_mod::get($this->_sModId)->getValue('sD3GASetDomainName')."'";
}
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";
}
if (d3_cfg_mod::get($this->_sModId)->getValue('iD3GASiteSpeedSampleRate')) {
$aParameter[] = "'siteSpeedSampleRate': ".
d3_cfg_mod::get($this->_sModId)->getValue('iD3GASiteSpeedSampleRate');
}
if (d3_cfg_mod::get($this->_sModId)->getValue('iD3GASampleRate')) {
$aParameter[] = "'sampleRate': ".d3_cfg_mod::get($this->_sModId)->getValue('iD3GASampleRate');
}
$aParameter = $this->_d3getCreateDomainNameParameter($aParameter);
$aParameter = $this->_d3getCreateCookiePathParameter($aParameter);
$aParameter = $this->_d3getCreateDomainLinkerParameter($aParameter);
$aParameter = $this->_d3getCreateSpeedSamplerateParameter($aParameter);
$aParameter = $this->_d3getCreateSamplerateParameter($aParameter);
if (count($aParameter)) {
return ", {".implode(',', $aParameter)."}";
@ -144,12 +186,7 @@ class d3_oxcmp_utils_googleanalytics extends d3_oxcmp_utils_googleanalytics_pare
$oCurrentView = oxRegistry::getConfig()->getActiveView();
$oCurrentView->getIsOrderStep();
if ($oCurrentView->getIsOrderStep() ||
strtolower($oCurrentView->getClassName()) == 'thankyou' ||
$this->_d3HasNoPageParameter()
) {
$aParameter[] = "'/{$oCurrentView->getClassName()}.html'";
}
$aParameter = $this->_d3getAsynchSendpageViewClassParameter($oCurrentView, $aParameter);
if (count($aParameter)) {
return ", " . implode(',', $aParameter) . "";
@ -169,21 +206,8 @@ class d3_oxcmp_utils_googleanalytics extends d3_oxcmp_utils_googleanalytics_pare
$oCurrentView = oxRegistry::getConfig()->getActiveView();
$oCurrentView->getIsOrderStep();
if ($oCurrentView->getIsOrderStep() || strtolower($oCurrentView->getClassName()) == 'thankyou') {
$aParameter[] = "'page': '/{$oCurrentView->getClassName()}.html'";
$aParameter[] = "'title': 'Checkout: ".ucfirst($oCurrentView->getClassName())."'";
} elseif ($this->_d3HasNoPageParameter()) {
$aParameter[] = "'page': '/{$oCurrentView->getClassName()}.html'";
$aParameter[] = "'title': '".ucfirst($oCurrentView->getClassName())."'";
}
if (d3_cfg_mod::get($this->_sModId)->hasDebugMode()) {
$aParameter[] = "
'hitCallback': function() {
alert('analytics.js done sending data');
}
";
}
$aParameter = $this->_d3getUniversalSendPageViewPageParameter($oCurrentView, $aParameter);
$aParameter = $this->_d3getUniversalSendPageViewDebugParameter($aParameter);
if (count($aParameter)) {
return ", {" . implode(',', $aParameter) . "}";
@ -348,6 +372,7 @@ class d3_oxcmp_utils_googleanalytics extends d3_oxcmp_utils_googleanalytics_pare
}
/**
* don't change method name, it was dynamically generated
* @param account_noticelist $oView
*
* @return array
@ -359,6 +384,7 @@ class d3_oxcmp_utils_googleanalytics extends d3_oxcmp_utils_googleanalytics_pare
}
/**
* don't change method name, it was dynamically generated
* @param account_wishlist $oView
*
* @return array
@ -393,4 +419,150 @@ class d3_oxcmp_utils_googleanalytics extends d3_oxcmp_utils_googleanalytics_pare
return array('aArtIdList' => $aArticleIds, 'dPrice' => $dPrice);
}
/**
* @param $aParameter
*
* @return array
*/
protected function _d3getCreateDomainNameParameter($aParameter)
{
if (d3_cfg_mod::get($this->_sModId)->getValue('sD3GASetDomainName')) {
$aParameter[] = "'cookieDomain': '" . d3_cfg_mod::get($this->_sModId)->getValue('sD3GASetDomainName') . "'";
$aParameter[] = "'legacyCookieDomain': '" .
d3_cfg_mod::get($this->_sModId)->getValue('sD3GASetDomainName') . "'";
return $aParameter;
}
return $aParameter;
}
/**
* @param $aParameter
*
* @return array
*/
protected function _d3getCreateCookiePathParameter($aParameter)
{
if (d3_cfg_mod::get($this->_sModId)->getValue('sD3GASetCookiePath')) {
$aParameter[] = "'cookiePath': '" . d3_cfg_mod::get($this->_sModId)->getValue('sD3GASetCookiePath') . "'";
return $aParameter;
}
return $aParameter;
}
/**
* @param $aParameter
*
* @return array
*/
protected function _d3getCreateDomainLinkerParameter($aParameter)
{
if (d3_cfg_mod::get($this->_sModId)->getValue('blD3GAAllowDomainLinker')) {
$aParameter[] = "'allowLinker': true";
return $aParameter;
}
return $aParameter;
}
/**
* @param $aParameter
*
* @return array
*/
protected function _d3getCreateSpeedSamplerateParameter($aParameter)
{
if (d3_cfg_mod::get($this->_sModId)->getValue('iD3GASiteSpeedSampleRate')) {
$aParameter[] = "'siteSpeedSampleRate': " .
d3_cfg_mod::get($this->_sModId)->getValue('iD3GASiteSpeedSampleRate');
return $aParameter;
}
return $aParameter;
}
/**
* @param $aParameter
*
* @return array
*/
protected function _d3getCreateSamplerateParameter($aParameter)
{
if (d3_cfg_mod::get($this->_sModId)->getValue('iD3GASampleRate')) {
$aParameter[] = "'sampleRate': " . d3_cfg_mod::get($this->_sModId)->getValue('iD3GASampleRate');
return $aParameter;
}
return $aParameter;
}
/**
* @param oxUBase $oCurrentView
* @param array $aParameter
*
* @return array
*/
protected function _d3getAsynchSendpageViewClassParameter($oCurrentView, $aParameter)
{
if ($oCurrentView->getIsOrderStep() ||
strtolower($oCurrentView->getClassName()) == 'thankyou' ||
$this->_d3HasNoPageParameter()
) {
$aParameter[] = "'/{$oCurrentView->getClassName()}.html'";
return $aParameter;
}
return $aParameter;
}
/**
* @param oxUBase $oCurrentView
* @param array $aParameter
*
* @return array
*/
protected function _d3getUniversalSendPageViewPageParameter($oCurrentView, $aParameter)
{
if ($oCurrentView->getIsOrderStep() || strtolower($oCurrentView->getClassName()) == 'thankyou') {
$aParameter[] = "'page': '/{$oCurrentView->getClassName()}.html'";
$aParameter[] = "'title': 'Checkout: " . ucfirst($oCurrentView->getClassName()) . "'";
return $aParameter;
} elseif ($this->_d3HasNoPageParameter()) {
$aParameter[] = "'page': '/{$oCurrentView->getClassName()}.html'";
$aParameter[] = "'title': '" . ucfirst($oCurrentView->getClassName()) . "'";
return $aParameter;
}
return $aParameter;
}
/**
* @param $aParameter
*
* @return array
*/
protected function _d3getUniversalSendPageViewDebugParameter($aParameter)
{
if (d3_cfg_mod::get($this->_sModId)->hasDebugMode()) {
$aParameter[] = "
'hitCallback': function() {
alert('analytics.js done sending data');
}
";
return $aParameter;
}
return $aParameter;
}
}

View File

@ -21,18 +21,18 @@ class d3_googleanalytics_update extends d3install_updatebase
public $sModName = 'Google Analytics Schnittstelle';
public $sModVersion = '3.1.0.0';
public $sModVersion = '3.1.0.1';
public $sModRevision = '133';
public $sModRevision = '139';
// heredoc syntax using for class members is available from PHP 5.3 up
public $sBaseConf =
"8ZEb1MwM201blJ3TDltMzJCdVcydUZMa3BNbFZhenJYSlZMbXRnUm82clRwcUVpTkdIS2orbmVOR0N1S
DEwb1Iwcmh1QTNXc002U2V1L25oL1krQkIyNVZaV2ZYMWtSaWxWZWhIdG9xdjVnM21CNmpMekx5NEpPa
0FBU090Y29KSU5kVjNUTC9laTNpQnhPWHJpMlZyOGc1aE1BTUthcWk2N3krYStHenRMQ0RiWG1BU1MyY
zk4bmd3em1VemJFUUZEUHRCbkZ1TTFTbWp4cUxWVlRkb1loQ0MxZGZyTW00ejV1Sy9Qa0dJTXAySGU5T
E9YMEhCblpabm02elJWYXhtSkd0TDdaQ21FSmVpbFp1aU5QYUZtM2VONVVoWUc4b0MzcGRFbWtQczN3c
Hc9";
"JycSFpDSXZYWEpRK1B2dERSbVg5VDVraUJ1VXBIOGpiY0NrY3M4Yzlrc1Q2Z2pPTms4SFRZODhGQTRwN
05QWktLUUozaXhSVVM2eU9VdWdMdklpL2hrV29YMS9lY1BMOUVsYjBiMmJOKzFQSjgzRGlqOGlwMUVVN
UxJY0plT3lBNkptc0VwcXNZT3YzY2hUTTB2QlF6RUIrbTJtVXRmNkppcTJreUJVd0xaUGI1RytmN1VkM
zBaTjNxQkZ5dTg0c05qRUcreDV0WFo0WFZrWjlZd1ltMVpJOTQybDYvQkNDWmVPQzRSdHkrOXpwMld6a
VVFTTBLWjRLTG1uT3k3ZUxXVUYwZlVCR2lQT0ZBWFRVZkd6UmtrOUN0bnFRczdzMnRudHAvMGttaGlhd
EE9";
public $sRequirements = '';

View File

@ -6,7 +6,7 @@ class requConfig
public $sModId = 'd3_googleanalytics';
public $sModVersion = '3.1.0.0';
public $sModVersion = '3.1.0.1';
/********************** check configuration section ************************/

View File

@ -1,3 +1,6 @@
=> 3.1.0.1
- Universal-Trackingcode für Multi-Domain-Nutzung angepasst
=> 3.1.0.0
- Universal-Analytics Tracking-Code implementiert
- zusätzliche Steuerungsparameter eingefügt