diff --git a/copy_this/modules/d3/d3_googleanalytics/models/d3_google_articlelister.php b/copy_this/modules/d3/d3_googleanalytics/models/d3_google_articlelister.php index e1a3312..c8e6733 100644 --- a/copy_this/modules/d3/d3_googleanalytics/models/d3_google_articlelister.php +++ b/copy_this/modules/d3/d3_googleanalytics/models/d3_google_articlelister.php @@ -1,5 +1,7 @@ getProduct(); - return $this->_getProductList($aArticleList); + $oArticle = $oView->getProduct(); + $oArticleList = oxNew(ArticleList::class); + $oArticleList->offsetSet($oArticle->getId(), $oArticle); + + return $oArticleList; } /** @@ -70,11 +73,17 @@ class d3_google_articlelister * * @return array */ + /** + * @param ArticleDetails $oView + * @return ArticleList + */ public function getOxwarticledetailsProdList($oView) { - $aArticleList = array(); - $aArticleList[] = $oView->getProduct(); - return $this->_getProductList($aArticleList); + $oArticle = $oView->getProduct(); + $oArticleList = oxNew(ArticleList::class); + $oArticleList->offsetSet($oArticle->getId(), $oArticle); + + return $oArticleList; } /** 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 9a676b6..391fe1c 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 @@ -131,6 +131,7 @@ class d3_oxcmp_utils_googleanalytics extends d3_oxcmp_utils_googleanalytics_pare $oParentView->addTplParam('blIsImpressionViewList', true); $oParentView->addTplParam('aD3GAProdInfos', $this->d3GAGetProdInfos()); $oParentView->addTplParam('sImpressionListType', $this->d3GAGetImpressionListType()); + $oParentView->addTplParam('sImpressionViewType', $this->d3GAGetImpressionViewType()); } } @@ -139,12 +140,23 @@ class d3_oxcmp_utils_googleanalytics extends d3_oxcmp_utils_googleanalytics_pare public function isImpressionViewList() { // ToDo: has to be completed - $impressionViews = ['search', 'start', 'alist', 'vendorlist', 'manufacturerlist']; + $impressionViews = ['search', 'start', 'alist', 'vendorlist', 'manufacturerlist', 'details', 'oxwarticledetails']; $oCurrentView = Registry::getConfig()->getActiveView(); return in_array($oCurrentView->getClassKey(), $impressionViews); } + public function d3GAGetImpressionViewType() + { + switch (Registry::getConfig()->getActiveView()->getClassKey()) { + case 'details': + case 'oxwarticledetails': + return 'view_item'; + default: + return 'view_item_list'; + } + } + public function d3GAGetImpressionListType() { $oCurrentView = Registry::getConfig()->getActiveView(); diff --git a/copy_this/modules/d3/d3_googleanalytics/views/tpl/widget/inc/d3ga_gtag_ecommerce.tpl b/copy_this/modules/d3/d3_googleanalytics/views/tpl/widget/inc/d3ga_gtag_ecommerce.tpl index 7f0cb5c..3c01e69 100644 --- a/copy_this/modules/d3/d3_googleanalytics/views/tpl/widget/inc/d3ga_gtag_ecommerce.tpl +++ b/copy_this/modules/d3/d3_googleanalytics/views/tpl/widget/inc/d3ga_gtag_ecommerce.tpl @@ -35,7 +35,7 @@ gtag('event', 'purchase', { [{if $blIsImpressionViewList}] [{* https://developers.google.com/analytics/devguides/collection/gtagjs/enhanced-ecommerce *}] - gtag('event', 'view_item_list', { + gtag('event', '[{$sImpressionViewType}]', { "items": [ [{foreach from=$aD3GAProdInfos name="itemlist" item="item"}] [{assign var="oPrice" value=$item->getPrice()}] @@ -50,30 +50,13 @@ gtag('event', 'purchase', { "variant": "", "list_position": [{$smarty.foreach.itemlist.iteration}], "quantity": 1, - "price": [{$oPrice->getPrice()}] + "price": '[{$oPrice->getPrice()}]' }, [{/foreach}] ] }); [{/if}] -[{* https://developers.google.com/analytics/devguides/collection/gtagjs/enhanced-ecommerce *}] -gtag('event', 'view_item', { - "items": [ - { - "id": "P12345", - "name": "Android Warhol T-Shirt", - "list_name": "Search Results", - "brand": "Google", - "category": "Apparel/T-Shirts", - "variant": "Black", - "list_position": 1, - "quantity": 2, - "price": '2.0' - } - ] -}); - [{* https://developers.google.com/analytics/devguides/collection/gtagjs/enhanced-ecommerce *}] gtag('event', 'add_to_cart', { "items": [