fix remarketing tracking via Analytics

This commit is contained in:
Daniel Seifert 2017-03-09 08:30:51 +00:00
parent 99c0927d5d
commit 294961da40
4 changed files with 43 additions and 11 deletions

View File

@ -10,19 +10,19 @@
[{assign var="iDimensionCount" value=0}] [{assign var="iDimensionCount" value=0}]
[{if $oD3GASettings->getValue('blD3GAUseAnalyticsRemarketing')}] [{if $oD3GASettings->getValue('blD3GAUseAnalyticsRemarketing')}]
[{* dimension 2 set payment type *}] [{* dimension 1 set product ids *}]
[{assign var="iDimensionCount" value=$iDimensionCount+1}] [{assign var="iDimensionCount" value=$iDimensionCount+1}]
[{if $oViewConf->getActiveClassName() == 'thankyou'}] [{if $sD3GARemarketingProdId2}]
ga( ga(
'set', 'set',
'dimension[{$iDimensionCount}]', 'dimension[{$iDimensionCount}]',
[{$sD3GARemarketingProdId}] [{$sD3GARemarketingProdId2}]
); );
[{/if}] [{/if}]
[{* dimension 2 set payment type *}] [{* dimension 2 set page type *}]
[{assign var="iDimensionCount" value=$iDimensionCount+1}] [{assign var="iDimensionCount" value=$iDimensionCount+1}]
[{if $oViewConf->getActiveClassName() == 'thankyou'}] [{if $sD3GARemarketingPageType}]
ga( ga(
'set', 'set',
'dimension[{$iDimensionCount}]', 'dimension[{$iDimensionCount}]',
@ -30,9 +30,9 @@
); );
[{/if}] [{/if}]
[{* dimension 2 set payment type *}] [{* dimension 3 set product total price *}]
[{assign var="iDimensionCount" value=$iDimensionCount+1}] [{assign var="iDimensionCount" value=$iDimensionCount+1}]
[{if $oViewConf->getActiveClassName() == 'thankyou'}] [{if $sD3GARemarketingPrice}]
ga( ga(
'set', 'set',
'dimension[{$iDimensionCount}]', 'dimension[{$iDimensionCount}]',

View File

@ -32,6 +32,18 @@ class d3_google_remarketing_articlelister
return $this->_getProductList($aArticleList); return $this->_getProductList($aArticleList);
} }
/**
* @param oxwArticleDetails $oView
*
* @return array
*/
public function getOxwarticledetailsProdList($oView)
{
$aArticleList = array();
$aArticleList[] = $oView->getProduct();
return $this->_getProductList($aArticleList);
}
/** /**
* @param alist $oView * @param alist $oView
* *

View File

@ -30,6 +30,18 @@ class d3_google_trustedstore_articlelister
return $this->_getProductList($aArticleList); return $this->_getProductList($aArticleList);
} }
/**
* @param oxwArticleDetails $oView
*
* @return array
*/
public function getOxwarticledetailsProdList($oView)
{
$aArticleList = array();
$aArticleList[] = $oView->getProduct();
return $this->_getProductList($aArticleList);
}
/** /**
* @param alist $oView * @param alist $oView
* *

View File

@ -29,6 +29,7 @@ class d3_oxcmp_utils_googleanalytics extends d3_oxcmp_utils_googleanalytics_pare
'manufacturerlist' => 'category', 'manufacturerlist' => 'category',
'vendorlist' => 'category', 'vendorlist' => 'category',
'details' => 'product', 'details' => 'product',
'oxwarticledetails' => 'product',
'basket' => 'cart', 'basket' => 'cart',
'order' => 'purchase', 'order' => 'purchase',
); );
@ -67,6 +68,7 @@ class d3_oxcmp_utils_googleanalytics extends d3_oxcmp_utils_googleanalytics_pare
if ($oSet->getValue('blD3GASetRemarketing') || $oSet->getValue('blD3GAUseAnalyticsRemarketing')) { if ($oSet->getValue('blD3GASetRemarketing') || $oSet->getValue('blD3GAUseAnalyticsRemarketing')) {
$aInfos = $this->d3GetGAProdInfos(); $aInfos = $this->d3GetGAProdInfos();
$oParentView->addTplParam('sD3GARemarketingProdId', $this->d3GetGAProdIdList($aInfos['aArtIdList'])); $oParentView->addTplParam('sD3GARemarketingProdId', $this->d3GetGAProdIdList($aInfos['aArtIdList']));
$oParentView->addTplParam('sD3GARemarketingProdId2', $this->d3GetGAProdIdList($aInfos['aArtIdList'], false));
$oParentView->addTplParam( $oParentView->addTplParam(
'sD3GARemarketingPrice', 'sD3GARemarketingPrice',
$aInfos['dPrice'] > 0 ? number_format($aInfos['dPrice'], 2, '.', ''): '' $aInfos['dPrice'] > 0 ? number_format($aInfos['dPrice'], 2, '.', ''): ''
@ -388,7 +390,9 @@ class d3_oxcmp_utils_googleanalytics extends d3_oxcmp_utils_googleanalytics_pare
if (method_exists($oArticleLister, $sMethodName)) { if (method_exists($oArticleLister, $sMethodName)) {
stopProfile(__METHOD__); stopProfile(__METHOD__);
return call_user_func(array($oArticleLister, $sMethodName), $oCurrentView); $aRet = call_user_func(array($oArticleLister, $sMethodName), $oCurrentView);
stopProfile(__METHOD__);
return $aRet;
} }
stopProfile(__METHOD__); stopProfile(__METHOD__);
@ -401,12 +405,16 @@ class d3_oxcmp_utils_googleanalytics extends d3_oxcmp_utils_googleanalytics_pare
* *
* @return string * @return string
*/ */
public function d3GetGAProdIdList($aArticleIds) public function d3GetGAProdIdList($aArticleIds, $blFormatArray = true)
{ {
if (count($aArticleIds)) { if (count($aArticleIds)) {
return "['".implode("', '", $aArticleIds)."']"; return $blFormatArray ?
"['".implode("', '", $aArticleIds)."']" :
"'".implode(", ", $aArticleIds)."'";
} else { } else {
return "''"; return $blFormatArray ?
"''" :
false;
} }
} }