add current product to tracking code

This commit is contained in:
Daniel Seifert 2014-10-16 15:57:12 +00:00
parent be1f41e2dc
commit 8a732d7eac
6 changed files with 348 additions and 146 deletions

2
.gitattributes vendored
View File

@ -179,6 +179,8 @@ copy_this/modules/d3/d3_googleanalytics/controllers/admin/d3_cfg_googleanalytics
copy_this/modules/d3/d3_googleanalytics/core/smarty/plugins/function.d3getArticleFromOrderArticle.php -text copy_this/modules/d3/d3_googleanalytics/core/smarty/plugins/function.d3getArticleFromOrderArticle.php -text
copy_this/modules/d3/d3_googleanalytics/menu.xml -text copy_this/modules/d3/d3_googleanalytics/menu.xml -text
copy_this/modules/d3/d3_googleanalytics/metadata.php -text copy_this/modules/d3/d3_googleanalytics/metadata.php -text
copy_this/modules/d3/d3_googleanalytics/models/d3_google_remarketing_articlelister.php -text
copy_this/modules/d3/d3_googleanalytics/models/d3_google_trustedstore_articlelister.php -text
copy_this/modules/d3/d3_googleanalytics/modules/components/d3_oxcmp_utils_googleanalytics.php -text copy_this/modules/d3/d3_googleanalytics/modules/components/d3_oxcmp_utils_googleanalytics.php -text
copy_this/modules/d3/d3_googleanalytics/modules/controllers/d3_order_googleanalytics.php -text copy_this/modules/d3/d3_googleanalytics/modules/controllers/d3_order_googleanalytics.php -text
copy_this/modules/d3/d3_googleanalytics/modules/controllers/d3_thankyou_googleanalytics.php -text copy_this/modules/d3/d3_googleanalytics/modules/controllers/d3_thankyou_googleanalytics.php -text

View File

@ -7,7 +7,7 @@
gts.push(["badge_position", "BOTTOM_RIGHT"]); gts.push(["badge_position", "BOTTOM_RIGHT"]);
gts.push(["locale", "[{$sD3CurrentGTSLang}]"]); gts.push(["locale", "[{$sD3CurrentGTSLang}]"]);
[{if $oD3GASettings->getValue('sD3GATSShoppingActive')}] [{if $oD3GASettings->getValue('sD3GATSShoppingActive')}]
[{*gts.push(["google_base_offer_id", ""]);*}] gts.push(["google_base_offer_id", "[{$sD3GATSProdId}]"]);
gts.push(["google_base_subaccount_id", "[{$oD3GASettings->getValue('sD3GATSShoppingAccountId')}]"]); gts.push(["google_base_subaccount_id", "[{$oD3GASettings->getValue('sD3GATSShoppingAccountId')}]"]);
gts.push(["google_base_country", "[{$oD3GASettings->getValue('sD3GATSShoppingCountry')|upper}]"]); gts.push(["google_base_country", "[{$oD3GASettings->getValue('sD3GATSShoppingCountry')|upper}]"]);
gts.push(["google_base_language", "[{$oD3GASettings->getValue('sD3GATSShoppingLanguage')|lower}]"]); gts.push(["google_base_language", "[{$oD3GASettings->getValue('sD3GATSShoppingLanguage')|lower}]"]);

View File

@ -67,6 +67,10 @@ $aModule = array(
'd3_cfg_googleanalyticslog_list' => 'd3_cfg_googleanalyticslog_list' =>
'd3/d3_googleanalytics/controllers/admin/d3_cfg_googleanalyticslog_list.php', 'd3/d3_googleanalytics/controllers/admin/d3_cfg_googleanalyticslog_list.php',
'd3_googleanalytics_update' => 'd3/d3_googleanalytics/setup/d3_googleanalytics_update.php', 'd3_googleanalytics_update' => 'd3/d3_googleanalytics/setup/d3_googleanalytics_update.php',
'd3_google_remarketing_articlelister' =>
'd3/d3_googleanalytics/models/d3_google_remarketing_articlelister.php',
'd3_google_trustedstore_articlelister' =>
'd3/d3_googleanalytics/models/d3_google_trustedstore_articlelister.php',
), ),
'templates' => array( 'templates' => array(
'd3_googleanalytics.tpl' => 'd3/d3_googleanalytics/views/tpl/widget/d3_googleanalytics.tpl', 'd3_googleanalytics.tpl' => 'd3/d3_googleanalytics/views/tpl/widget/d3_googleanalytics.tpl',

View File

@ -0,0 +1,160 @@
<?php
/**
* This Software is the property of Data Development and is protected
* by copyright law - it is NOT Freeware.
*
* Any unauthorized use of this software without a valid license
* is a violation of the license agreement and will be prosecuted by
* civil and criminal law.
*
* http://www.shopmodule.com
*
* @copyright © Data Development, Thomas Dartsch
* @author Data Development - Daniel Seifert <ds@shopmodule.com>
* @link http://www.oxidmodule.com
*/
class d3_google_remarketing_articlelister
{
public $sD3GARemarketingSKUField = 'oxartnum';
public $blD3GARemarketingUseBrutto = true;
/**
* @param details $oView
*
* @return array
*/
public function getDetailsProdList($oView)
{
$aArticleList = array();
$aArticleList[] = $oView->getProduct();
return $this->_getProductList($aArticleList);
}
/**
* @param alist $oView
*
* @return array
*/
public function getAlistProdList($oView)
{
$oArticleList = $oView->getArticleList();
return $this->_getProductList($oArticleList);
}
/**
* @param search $oView
*
* @return array
*/
public function getSearchProdList($oView)
{
$oArticleList = $oView->getArticleList();
return $this->_getProductList($oArticleList);
}
/**
* @param vendorlist $oView
*
* @return array
*/
public function getVendorlistProdList($oView)
{
$oArticleList = $oView->getArticleList();
return $this->_getProductList($oArticleList);
}
/**
* @param manufacturerlist $oView
*
* @return array
*/
public function getManufacturerlistProdList($oView)
{
$oArticleList = $oView->getArticleList();
return $this->_getProductList($oArticleList);
}
/**
* @param basket $oView
*
* @return array
*/
public function getBasketProdList($oView)
{
$aArticleList = $oView->getBasketArticles();
return $this->_getProductList($aArticleList);
}
/**
* @param order $oView
*
* @return array
*/
public function getOrderProdList($oView)
{
$aArticleList = $oView->getBasketArticles();
return $this->_getProductList($aArticleList);
}
/**
* @param compare $oView
*
* @return array
*/
public function getCompareProdList($oView)
{
$aArticleList = $oView->getCompArtList();
return $this->_getProductList($aArticleList);
}
/**
* don't change method name, it was dynamically generated
* @param account_noticelist $oView
*
* @return array
*/
public function getAccount_noticelistProdList($oView)
{
$aArticleList = $oView->getNoticeProductList();
return $this->_getProductList($aArticleList);
}
/**
* don't change method name, it was dynamically generated
* @param account_wishlist $oView
*
* @return array
*/
public function getAccount_wishlistProdList($oView)
{
$aArticleList = $oView->getWishProductList();
return $this->_getProductList($aArticleList);
}
/**
* @param $aArticleList
*
* @return array
*/
protected function _getProductList($aArticleList)
{
$aArticleIds = array();
$dPrice = 0;
/** @var oxarticle $oArticle */
if (isset($aArticleList)) {
foreach ($aArticleList as $oArticle) {
$aArticleIds[] = $oArticle->getFieldData($this->sD3GARemarketingSKUField);
if ($this->blD3GARemarketingUseBrutto) {
$dPrice += $oArticle->getPrice()->getBruttoPrice();
} else {
$dPrice += $oArticle->getPrice()->getNettoPrice();
}
}
}
return array('aArtIdList' => $aArticleIds, 'dPrice' => $dPrice);
}
}

View File

@ -0,0 +1,132 @@
<?php
/**
* This Software is the property of Data Development and is protected
* by copyright law - it is NOT Freeware.
*
* Any unauthorized use of this software without a valid license
* is a violation of the license agreement and will be prosecuted by
* civil and criminal law.
*
* http://www.shopmodule.com
*
* @copyright © Data Development, Thomas Dartsch
* @author Data Development - Daniel Seifert <support@shopmodule.com>
* @link http://www.oxidmodule.com
*/
class d3_google_trustedstore_articlelister
{
private $_sModId = 'd3_googleanalytics';
/**
* @param details $oView
*
* @return array
*/
public function getDetailsProdList($oView)
{
$aArticleList = array();
$aArticleList[] = $oView->getProduct();
return $this->_getProductList($aArticleList);
}
/**
* @param alist $oView
*
* @return array
*/
public function getAlistProdList($oView)
{
$oArticleList = $oView->getArticleList();
return $this->_getProductList($oArticleList);
}
/**
* @param search $oView
*
* @return array
*/
public function getSearchProdList($oView)
{
$oArticleList = $oView->getArticleList();
return $this->_getProductList($oArticleList);
}
/**
* @param vendorlist $oView
*
* @return array
*/
public function getVendorlistProdList($oView)
{
$oArticleList = $oView->getArticleList();
return $this->_getProductList($oArticleList);
}
/**
* @param manufacturerlist $oView
*
* @return array
*/
public function getManufacturerlistProdList($oView)
{
$oArticleList = $oView->getArticleList();
return $this->_getProductList($oArticleList);
}
/**
* @param compare $oView
*
* @return array
*/
public function getCompareProdList($oView)
{
$aArticleList = $oView->getCompArtList();
return $this->_getProductList($aArticleList);
}
/**
* don't change method name, it was dynamically generated
* @param account_noticelist $oView
*
* @return array
*/
public function getAccount_noticelistProdList($oView)
{
$aArticleList = $oView->getNoticeProductList();
return $this->_getProductList($aArticleList);
}
/**
* don't change method name, it was dynamically generated
* @param account_wishlist $oView
*
* @return array
*/
public function getAccount_wishlistProdList($oView)
{
$aArticleList = $oView->getWishProductList();
return $this->_getProductList($aArticleList);
}
/**
* @param $aArticleList
*
* @return array
*/
protected function _getProductList($aArticleList)
{
$aArticleIds = array();
/** @var oxarticle $oArticle */
if (isset($aArticleList)) {
foreach ($aArticleList as $oArticle) {
$aArticleIds[] = $oArticle->getFieldData(
d3_cfg_mod::get($this->_sModId)->getValue('sD3GATSShoppingArtId')
);
}
}
return array('aArtIdList' => $aArticleIds);
}
}

View File

@ -33,9 +33,6 @@ class d3_oxcmp_utils_googleanalytics extends d3_oxcmp_utils_googleanalytics_pare
'order' => 'purchase', 'order' => 'purchase',
); );
public $sD3GARemarketingSKUField = 'oxartnum';
public $blD3GARemarketingUseBrutto = true;
/** /**
* @return null * @return null
*/ */
@ -55,7 +52,12 @@ class d3_oxcmp_utils_googleanalytics extends d3_oxcmp_utils_googleanalytics_pare
$oParentView->addTplParam('sAFEGetMoreUrls', $this->afGetMoreUrls()); $oParentView->addTplParam('sAFEGetMoreUrls', $this->afGetMoreUrls());
$oParentView->addTplParam('sD3GASendPageViewParameter', $this->d3getSendPageViewParameters()); $oParentView->addTplParam('sD3GASendPageViewParameter', $this->d3getSendPageViewParameters());
$oParentView->addTplParam('sD3CurrentShopUrl', $this->d3GetCreateCurrentShopUrl()); $oParentView->addTplParam('sD3CurrentShopUrl', $this->d3GetCreateCurrentShopUrl());
$oParentView->addTplParam('sD3CurrentGTSLang', $this->d3GetGTSLang());
if ($oSet->getValue('sD3GATSActive') && $oSet->getValue('sD3GATSShoppingActive')) {
$aInfos = $this->d3GATSGetProdInfos();
$oParentView->addTplParam('sD3CurrentGTSLang', $this->d3GetGTSLang());
$oParentView->addTplParam('sD3GATSProdId', $this->d3GATSGetProdIdList($aInfos['aArtIdList']));
}
if ($oSet->getValue('blD3GASetRemarketing')) { if ($oSet->getValue('blD3GASetRemarketing')) {
$aInfos = $this->d3GetGAProdInfos(); $aInfos = $this->d3GetGAProdInfos();
@ -299,6 +301,45 @@ class d3_oxcmp_utils_googleanalytics extends d3_oxcmp_utils_googleanalytics_pare
strtoupper($oCountry->getFieldData('OXISOALPHA2')); strtoupper($oCountry->getFieldData('OXISOALPHA2'));
} }
/**
* @return array
*/
public function d3GATSGetProdInfos()
{
startProfile(__METHOD__);
$oCurrentView = oxRegistry::getConfig()->getActiveView();
$aArticleIds = array();
$sMethodName = 'get'.ucfirst($oCurrentView->getClassName())."ProdList";
$oArticleLister = oxNew('d3_google_trustedstore_articlelister');
if (method_exists($oArticleLister, $sMethodName)) {
stopProfile(__METHOD__);
return call_user_func(array($oArticleLister, $sMethodName), $oCurrentView);
}
stopProfile(__METHOD__);
return array('aArtIdList' => $aArticleIds);
}
/**
* @param array $aArticleIds
*
* @return string
*/
public function d3GATSGetProdIdList($aArticleIds)
{
if (count($aArticleIds)) {
return $aArticleIds[array_keys($aArticleIds)[0]];
} else {
return "";
}
}
/** /**
* @return string * @return string
*/ */
@ -311,11 +352,12 @@ class d3_oxcmp_utils_googleanalytics extends d3_oxcmp_utils_googleanalytics_pare
$aArticleIds = array(); $aArticleIds = array();
$dPrice = 0; $dPrice = 0;
$sMethodName = '_d3GetGA'.$oCurrentView->getClassName()."ProdList"; $sMethodName = 'get'.ucfirst($oCurrentView->getClassName())."ProdList";
$oArticleLister = oxNew('d3_google_remarketing_articlelister');
if (method_exists($this, $sMethodName)) { if (method_exists($oArticleLister, $sMethodName)) {
stopProfile(__METHOD__); stopProfile(__METHOD__);
return call_user_func(array($this, $sMethodName), $oCurrentView); return call_user_func(array($oArticleLister, $sMethodName), $oCurrentView);
} }
stopProfile(__METHOD__); stopProfile(__METHOD__);
@ -337,144 +379,6 @@ class d3_oxcmp_utils_googleanalytics extends d3_oxcmp_utils_googleanalytics_pare
} }
} }
/**
* @param details $oView
*
* @return array
*/
protected function _d3GetGAdetailsProdList($oView)
{
$aArticleList = array();
$aArticleList[] = $oView->getProduct();
return $this->_d3GetGAProductList($aArticleList);
}
/**
* @param alist $oView
*
* @return array
*/
protected function _d3GetGAalistProdList($oView)
{
$oArticleList = $oView->getArticleList();
return $this->_d3GetGAProductList($oArticleList);
}
/**
* @param search $oView
*
* @return array
*/
protected function _d3GetGAsearchProdList($oView)
{
$oArticleList = $oView->getArticleList();
return $this->_d3GetGAProductList($oArticleList);
}
/**
* @param vendorlist $oView
*
* @return array
*/
protected function _d3GetGAvendorlistProdList($oView)
{
$oArticleList = $oView->getArticleList();
return $this->_d3GetGAProductList($oArticleList);
}
/**
* @param manufacturerlist $oView
*
* @return array
*/
protected function _d3GetGAmanufacturerlistProdList($oView)
{
$oArticleList = $oView->getArticleList();
return $this->_d3GetGAProductList($oArticleList);
}
/**
* @param basket $oView
*
* @return array
*/
protected function _d3GetGAbasketProdList($oView)
{
$aArticleList = $oView->getBasketArticles();
return $this->_d3GetGAProductList($aArticleList);
}
/**
* @param order $oView
*
* @return array
*/
protected function _d3GetGAorderProdList($oView)
{
$aArticleList = $oView->getBasketArticles();
return $this->_d3GetGAProductList($aArticleList);
}
/**
* @param compare $oView
*
* @return array
*/
protected function _d3GetGAcompareProdList($oView)
{
$aArticleList = $oView->getCompArtList();
return $this->_d3GetGAProductList($aArticleList);
}
/**
* don't change method name, it was dynamically generated
* @param account_noticelist $oView
*
* @return array
*/
protected function _d3GetGAaccount_noticelistProdList($oView)
{
$aArticleList = $oView->getNoticeProductList();
return $this->_d3GetGAProductList($aArticleList);
}
/**
* don't change method name, it was dynamically generated
* @param account_wishlist $oView
*
* @return array
*/
protected function _d3GetGAaccount_wishlistProdList($oView)
{
$aArticleList = $oView->getWishProductList();
return $this->_d3GetGAProductList($aArticleList);
}
/**
* @param $aArticleList
*
* @return array
*/
protected function _d3GetGAProductList($aArticleList)
{
$aArticleIds = array();
$dPrice = 0;
/** @var oxarticle $oArticle */
if (isset($aArticleList)) {
foreach ($aArticleList as $oArticle) {
$aArticleIds[] = $oArticle->getFieldData($this->sD3GARemarketingSKUField);
if ($this->blD3GARemarketingUseBrutto) {
$dPrice += $oArticle->getPrice()->getBruttoPrice();
} else {
$dPrice += $oArticle->getPrice()->getNettoPrice();
}
}
}
return array('aArtIdList' => $aArticleIds, 'dPrice' => $dPrice);
}
/** /**
* @param $aParameter * @param $aParameter
* *