From 294961da407b468a210b9a7fbd4f33a459370530 Mon Sep 17 00:00:00 2001 From: DanielSeifert Date: Thu, 9 Mar 2017 08:30:51 +0000 Subject: [PATCH] fix remarketing tracking via Analytics --- .../tpl/widget/inc/d3ga_universal_custom.tpl | 14 +++++++------- .../d3_google_remarketing_articlelister.php | 12 ++++++++++++ .../d3_google_trustedstore_articlelister.php | 12 ++++++++++++ .../d3_oxcmp_utils_googleanalytics.php | 16 ++++++++++++---- 4 files changed, 43 insertions(+), 11 deletions(-) diff --git a/changed_full/470-/modules/d3/d3_googleanalytics/views/tpl/widget/inc/d3ga_universal_custom.tpl b/changed_full/470-/modules/d3/d3_googleanalytics/views/tpl/widget/inc/d3ga_universal_custom.tpl index 0c87954..8682155 100644 --- a/changed_full/470-/modules/d3/d3_googleanalytics/views/tpl/widget/inc/d3ga_universal_custom.tpl +++ b/changed_full/470-/modules/d3/d3_googleanalytics/views/tpl/widget/inc/d3ga_universal_custom.tpl @@ -10,19 +10,19 @@ [{assign var="iDimensionCount" value=0}] [{if $oD3GASettings->getValue('blD3GAUseAnalyticsRemarketing')}] - [{* dimension 2 set payment type *}] + [{* dimension 1 set product ids *}] [{assign var="iDimensionCount" value=$iDimensionCount+1}] - [{if $oViewConf->getActiveClassName() == 'thankyou'}] + [{if $sD3GARemarketingProdId2}] ga( 'set', 'dimension[{$iDimensionCount}]', - [{$sD3GARemarketingProdId}] + [{$sD3GARemarketingProdId2}] ); [{/if}] - [{* dimension 2 set payment type *}] + [{* dimension 2 set page type *}] [{assign var="iDimensionCount" value=$iDimensionCount+1}] - [{if $oViewConf->getActiveClassName() == 'thankyou'}] + [{if $sD3GARemarketingPageType}] ga( 'set', 'dimension[{$iDimensionCount}]', @@ -30,9 +30,9 @@ ); [{/if}] - [{* dimension 2 set payment type *}] + [{* dimension 3 set product total price *}] [{assign var="iDimensionCount" value=$iDimensionCount+1}] - [{if $oViewConf->getActiveClassName() == 'thankyou'}] + [{if $sD3GARemarketingPrice}] ga( 'set', 'dimension[{$iDimensionCount}]', diff --git a/copy_this/modules/d3/d3_googleanalytics/models/d3_google_remarketing_articlelister.php b/copy_this/modules/d3/d3_googleanalytics/models/d3_google_remarketing_articlelister.php index 09ad536..74f87f9 100644 --- a/copy_this/modules/d3/d3_googleanalytics/models/d3_google_remarketing_articlelister.php +++ b/copy_this/modules/d3/d3_googleanalytics/models/d3_google_remarketing_articlelister.php @@ -32,6 +32,18 @@ class d3_google_remarketing_articlelister 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 * diff --git a/copy_this/modules/d3/d3_googleanalytics/models/d3_google_trustedstore_articlelister.php b/copy_this/modules/d3/d3_googleanalytics/models/d3_google_trustedstore_articlelister.php index 65b8b62..0097789 100644 --- a/copy_this/modules/d3/d3_googleanalytics/models/d3_google_trustedstore_articlelister.php +++ b/copy_this/modules/d3/d3_googleanalytics/models/d3_google_trustedstore_articlelister.php @@ -30,6 +30,18 @@ class d3_google_trustedstore_articlelister 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 * 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 d8eb93b..4cdac3f 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 @@ -29,6 +29,7 @@ class d3_oxcmp_utils_googleanalytics extends d3_oxcmp_utils_googleanalytics_pare 'manufacturerlist' => 'category', 'vendorlist' => 'category', 'details' => 'product', + 'oxwarticledetails' => 'product', 'basket' => 'cart', 'order' => 'purchase', ); @@ -67,6 +68,7 @@ class d3_oxcmp_utils_googleanalytics extends d3_oxcmp_utils_googleanalytics_pare if ($oSet->getValue('blD3GASetRemarketing') || $oSet->getValue('blD3GAUseAnalyticsRemarketing')) { $aInfos = $this->d3GetGAProdInfos(); $oParentView->addTplParam('sD3GARemarketingProdId', $this->d3GetGAProdIdList($aInfos['aArtIdList'])); + $oParentView->addTplParam('sD3GARemarketingProdId2', $this->d3GetGAProdIdList($aInfos['aArtIdList'], false)); $oParentView->addTplParam( 'sD3GARemarketingPrice', $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)) { stopProfile(__METHOD__); - return call_user_func(array($oArticleLister, $sMethodName), $oCurrentView); + $aRet = call_user_func(array($oArticleLister, $sMethodName), $oCurrentView); + stopProfile(__METHOD__); + return $aRet; } stopProfile(__METHOD__); @@ -401,12 +405,16 @@ class d3_oxcmp_utils_googleanalytics extends d3_oxcmp_utils_googleanalytics_pare * * @return string */ - public function d3GetGAProdIdList($aArticleIds) + public function d3GetGAProdIdList($aArticleIds, $blFormatArray = true) { if (count($aArticleIds)) { - return "['".implode("', '", $aArticleIds)."']"; + return $blFormatArray ? + "['".implode("', '", $aArticleIds)."']" : + "'".implode(", ", $aArticleIds)."'"; } else { - return "''"; + return $blFormatArray ? + "''" : + false; } }