implement ecommerce feature
This commit is contained in:
parent
85eb11aaff
commit
7627f18f87
@ -17,7 +17,9 @@
|
||||
* @copyright (C) D3 Data Development (Inh. Thomas Dartsch)
|
||||
*/
|
||||
|
||||
class d3_oxcmp_utils_googleAnalytics_parent extends oxcmp_utils {}
|
||||
class d3_oxcmp_utils_googleanalytics_parent extends oxcmp_utils {}
|
||||
|
||||
class d3_oxcmp_basket_googleanalytics_parent extends oxcmp_basket {}
|
||||
|
||||
/** */
|
||||
class d3_oxorder_googleanalytics_parent extends oxOrder {}
|
||||
|
@ -48,6 +48,7 @@ $aModule = array(
|
||||
'url' => 'http://www.oxidmodule.com/',
|
||||
'extend' => array(
|
||||
'oxcmp_utils' => 'd3/d3_googleanalytics/modules/components/d3_oxcmp_utils_googleanalytics',
|
||||
'oxcmp_basket' => 'd3/d3_googleanalytics/modules/components/d3_oxcmp_basket_googleanalytics',
|
||||
'oxbasket' => 'd3/d3_googleanalytics/modules/models/d3_oxbasket_googleanalytics',
|
||||
'oxbasketitem' => 'd3/d3_googleanalytics/modules/models/d3_oxbasketitem_googleanalytics',
|
||||
'oxorder' => 'd3/d3_googleanalytics/modules/models/d3_oxorder_googleanalytics',
|
||||
@ -78,6 +79,7 @@ $aModule = array(
|
||||
|
||||
'd3ga_gtag.tpl' => 'd3/d3_googleanalytics/views/tpl/widget/d3ga_gtag.tpl',
|
||||
'd3ga_gtag_ecommerce.tpl' => 'd3/d3_googleanalytics/views/tpl/widget/inc/d3ga_gtag_ecommerce.tpl',
|
||||
'd3ga_gtag_ecommerceproduct.tpl' => 'd3/d3_googleanalytics/views/tpl/widget/inc/d3ga_gtag_ecommerceproduct.tpl',
|
||||
'd3ga_gtag_adwords.tpl' => 'd3/d3_googleanalytics/views/tpl/widget/inc/d3ga_gtag_adwords.tpl',
|
||||
'd3ga_gtag_custom.tpl' => 'd3/d3_googleanalytics/views/tpl/widget/inc/d3ga_gtag_custom.tpl',
|
||||
|
||||
|
@ -30,7 +30,7 @@ class d3_google_articlelister
|
||||
/**
|
||||
* @param start $oView
|
||||
*
|
||||
* @return array
|
||||
* @return ArticleList
|
||||
*/
|
||||
public function getStartProdList($oView)
|
||||
{
|
||||
@ -52,7 +52,7 @@ class d3_google_articlelister
|
||||
}
|
||||
}
|
||||
|
||||
return $this->_getProductList($oArticleList);
|
||||
return $oArticleList;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -129,12 +129,19 @@ class d3_google_articlelister
|
||||
/**
|
||||
* @param basket $oView
|
||||
*
|
||||
* @return array
|
||||
* @return ArticleList
|
||||
*/
|
||||
public function getBasketProdList($oView)
|
||||
{
|
||||
$aArticleList = $oView->getBasketArticles();
|
||||
return $this->_getProductList($aArticleList);
|
||||
$oArticleList = oxNew(ArticleList::class);
|
||||
|
||||
/** @var \OxidEsales\Eshop\Application\Model\Article $oArticle */
|
||||
foreach ($aArticleList as $oArticle) {
|
||||
$oArticleList->offsetSet($oArticle->getId(), $oArticle);
|
||||
}
|
||||
|
||||
return $oArticleList;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -0,0 +1,38 @@
|
||||
<?php
|
||||
|
||||
use OxidEsales\Eshop\Core\Registry;
|
||||
|
||||
/**
|
||||
* 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 (C) D3 Data Development (Inh. Thomas Dartsch)
|
||||
* @author D3 Data Development - Daniel Seifert <support@shopmodule.com>
|
||||
* @link http://www.oxidmodule.com
|
||||
*/
|
||||
|
||||
class d3_oxcmp_basket_googleanalytics extends d3_oxcmp_basket_googleanalytics_parent
|
||||
{
|
||||
public function toBasket($sProductId = null, $dAmount = null, $aSel = null, $aPersParam = null, $blOverride = false)
|
||||
{
|
||||
$sProductId = $sProductId ? $sProductId : \OxidEsales\Eshop\Core\Registry::getConfig()->getRequestParameter('aid');
|
||||
$dAmount = isset($dAmount) ? $dAmount : \OxidEsales\Eshop\Core\Registry::getConfig()->getRequestParameter('am');
|
||||
|
||||
$oGAAction = oxNew(stdClass::class);
|
||||
$oGAAction->action = __FUNCTION__;
|
||||
$oGAAction->product = $sProductId;
|
||||
$oGAAction->amount = $dAmount;
|
||||
|
||||
Registry::getSession()->setVariable('d3GABasketAction', $oGAAction);
|
||||
|
||||
$sRedirectUrl = parent::toBasket($sProductId, $dAmount, $aSel, $aPersParam, $blOverride);
|
||||
|
||||
return $sRedirectUrl;
|
||||
}
|
||||
|
||||
// changeBasket for removing
|
||||
}
|
@ -5,7 +5,12 @@ use D3\ModCfg\Application\Model\Exception\d3_cfg_mod_exception;
|
||||
use D3\ModCfg\Application\Model\Exception\d3ShopCompatibilityAdapterException;
|
||||
use Doctrine\DBAL\DBALException;
|
||||
use OxidEsales\Eshop\Application\Controller\FrontendController;
|
||||
use OxidEsales\Eshop\Application\Model\Article as Article;
|
||||
use OxidEsales\Eshop\Application\Model\ArticleList;
|
||||
use OxidEsales\Eshop\Application\Model\DeliverySet;
|
||||
use OxidEsales\Eshop\Application\Model\Payment as Payment;
|
||||
use OxidEsales\Eshop\Application\Model\Voucher;
|
||||
use OxidEsales\Eshop\Application\Model\VoucherList;
|
||||
use OxidEsales\Eshop\Core\Exception\DatabaseConnectionException;
|
||||
use OxidEsales\Eshop\Core\Exception\DatabaseErrorException;
|
||||
use OxidEsales\Eshop\Core\Exception\StandardException;
|
||||
@ -71,10 +76,12 @@ class d3_oxcmp_utils_googleanalytics extends d3_oxcmp_utils_googleanalytics_pare
|
||||
$oParentView->addTplParam('oD3GAActCurrency', Registry::getConfig()->getActShopCurrencyObject());
|
||||
$oParentView->addTplParam('sD3GAPageLocation', $oParentView->getBaseLink());
|
||||
$oParentView->addTplParam('sD3GAPagePath', str_replace(Registry::getConfig()->getShopUrl(), '', $oParentView->getBaseLink()));
|
||||
$oParentView->addTplParam('oShop', Registry::getConfig()->getActiveShop());
|
||||
// prevent overwriting with empty title from later loaded widgets
|
||||
if ($oParentView->getTitle() && false == $oParentView->getViewDataElement('sD3GAPageTitle')) {
|
||||
$oParentView->addTplParam('sD3GAPageTitle', $oParentView->getTitle());
|
||||
if (false == $oParentView->getViewDataElement('sD3GAPageTitle')) {
|
||||
$oParentView->addTplParam('sD3GAPageTitle', $oParentView->getTitle() ? $oParentView->getTitle() : ucfirst($oParentView->getClassKey()));
|
||||
}
|
||||
|
||||
if (Registry::getSession()->getUser() && ($sUserId = Registry::getSession()->getUser()->getId())) {
|
||||
$oParentView->addTplParam('sD3GAUserId', md5($sUserId));
|
||||
}
|
||||
@ -82,8 +89,6 @@ class d3_oxcmp_utils_googleanalytics extends d3_oxcmp_utils_googleanalytics_pare
|
||||
|
||||
$oParentView->addTplParam('sAFEGetMoreUrls', $this->afGetMoreUrls());
|
||||
$oParentView->addTplParam('sD3GASendPageViewParameter', $this->d3getSendPageViewParameters());
|
||||
$oParentView->addTplParam('sD3CurrentShopUrl', $this->d3GetCreateCurrentShopUrl());
|
||||
$oParentView->addTplParam('blD3GAIsMobile', $this->d3isMobile());
|
||||
$oParentView->addTplParam('iD3GASendNoBounceEventTime', $this->d3GetSendNoBounceEventTime());
|
||||
|
||||
if ($oSet->getValue('sD3GATSActive')) {
|
||||
@ -126,15 +131,73 @@ class d3_oxcmp_utils_googleanalytics extends d3_oxcmp_utils_googleanalytics_pare
|
||||
|
||||
if ($oSet->getValue('blD3GASendECommerce')) {
|
||||
$oParentView->addTplParam('blIsImpressionViewList', false);
|
||||
$oParentView->addTplParam('blIsCheckoutViewList', false);
|
||||
$oParentView->addTplParam('blIsPurchasedList', false);
|
||||
$oParentView->addTplParam('blIsBasketAction', false);
|
||||
|
||||
if ($this->isImpressionViewList()) {
|
||||
$oParentView->addTplParam('blIsImpressionViewList', true);
|
||||
$oParentView->addTplParam('aD3GAProdInfos', $this->d3GAGetProdInfos());
|
||||
$oParentView->addTplParam('sImpressionListType', $this->d3GAGetImpressionListType());
|
||||
$oParentView->addTplParam('sImpressionViewType', $this->d3GAGetImpressionViewType());
|
||||
} elseif ($this->isCheckoutViewList()) {
|
||||
$oParentView->addTplParam('blIsCheckoutViewList', true);
|
||||
/** @var \OxidEsales\Eshop\Application\Model\Basket $basket */
|
||||
$basket = Registry::getSession()->getBasket();
|
||||
$oParentView->addTplParam('oBasket', $basket);
|
||||
|
||||
$voucherList = oxNew(VoucherList::class);
|
||||
foreach ($basket->getVouchers() as $voucher) {
|
||||
$oVoucher = oxNew(Voucher::class);
|
||||
$oVoucher->load($voucher->sVoucherId);
|
||||
$voucherList->offsetSet($oVoucher->getId(), $oVoucher);
|
||||
}
|
||||
$oParentView->addTplParam('oVoucherList', $voucherList);
|
||||
$oParentView->addTplParam('iCheckoutStep', $this->d3GAGetCheckoutStep());
|
||||
$oParentView->addTplParam('sImpressionViewType', $this->d3GAGetImpressionViewType());
|
||||
|
||||
$oShipping = oxNew(DeliverySet::class);
|
||||
if ($basket->getShippingId()) $oShipping->load($basket->getShippingId());
|
||||
$oPayment = oxNew( Payment::class);
|
||||
if ($basket->getPaymentId()) $oPayment->load($basket->getPaymentId());
|
||||
$oParentView->addTplParam('checkoutOptionValue', $oShipping->getFieldData('oxtitle').' + '.$oPayment->getFieldData('oxdesc'));
|
||||
} elseif ($this->isPurchasedList()) {
|
||||
$oParentView->addTplParam('blIsPurchasedList', true);
|
||||
/** @var \OxidEsales\Eshop\Application\Model\Basket $basket */
|
||||
$basket = $oParentView->getBasket();
|
||||
$order = oxNew(\OxidEsales\Eshop\Application\Model\Order::class);
|
||||
$order->load($basket->getOrderId());
|
||||
$oParentView->addTplParam('oOrder', $order);
|
||||
|
||||
$voucherList = oxNew(VoucherList::class);
|
||||
foreach ($basket->getVouchers() as $voucher) {
|
||||
$oVoucher = oxNew(Voucher::class);
|
||||
$oVoucher->load($voucher->sVoucherId);
|
||||
$voucherList->offsetSet($oVoucher->getId(), $oVoucher);
|
||||
}
|
||||
$oParentView->addTplParam('oVoucherList', $voucherList);
|
||||
$oParentView->addTplParam('iCheckoutStep', 5);
|
||||
$oParentView->addTplParam('dVat', array_sum($order->getProductVats(false)));
|
||||
|
||||
$oShipping = oxNew(DeliverySet::class);
|
||||
if ($basket->getShippingId()) $oShipping->load($basket->getShippingId());
|
||||
$oPayment = oxNew( Payment::class);
|
||||
if ($basket->getPaymentId()) $oPayment->load($basket->getPaymentId());
|
||||
$oParentView->addTplParam('checkoutOptionValue', $oShipping->getFieldData('oxtitle').' + '.$oPayment->getFieldData('oxdesc'));
|
||||
}
|
||||
|
||||
if (($basketAction = Registry::getSession()->getVariable('d3GABasketAction'))) {
|
||||
$oParentView->addTplParam('blIsBasketAction', true);
|
||||
$oParentView->addTplParam('sBasketActionType', $this->d3GAGetBasketActionType());
|
||||
$oArticleList = oxNew(ArticleList::class);
|
||||
$oArticle = oxNew( Article::class);
|
||||
$oArticle->load($basketAction->product);
|
||||
$oArticleList->offsetSet($oArticle->getId(), $oArticle);
|
||||
$oParentView->addTplParam('aD3GABasketProdInfos', $oArticleList);
|
||||
$oParentView->addTplParam('dAmount', $basketAction->amount);
|
||||
Registry::getSession()->deleteVariable('d3GABasketAction');
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public function isImpressionViewList()
|
||||
@ -143,20 +206,70 @@ class d3_oxcmp_utils_googleanalytics extends d3_oxcmp_utils_googleanalytics_pare
|
||||
$impressionViews = ['search', 'start', 'alist', 'vendorlist', 'manufacturerlist', 'details', 'oxwarticledetails'];
|
||||
$oCurrentView = Registry::getConfig()->getActiveView();
|
||||
|
||||
return in_array($oCurrentView->getClassKey(), $impressionViews);
|
||||
return in_array(strtolower($oCurrentView->getClassKey()), $impressionViews);
|
||||
}
|
||||
|
||||
public function isCheckoutViewList()
|
||||
{
|
||||
// ToDo: has to be completed
|
||||
$impressionViews = ['basket', 'user', 'payment', 'order'];
|
||||
$oCurrentView = Registry::getConfig()->getActiveView();
|
||||
|
||||
return in_array(strtolower($oCurrentView->getClassKey()), $impressionViews);
|
||||
}
|
||||
|
||||
public function isPurchasedList()
|
||||
{
|
||||
$impressionViews = ['thankyou'];
|
||||
$oCurrentView = Registry::getConfig()->getActiveView();
|
||||
|
||||
return in_array(strtolower($oCurrentView->getClassKey()), $impressionViews);
|
||||
}
|
||||
|
||||
public function d3GAGetImpressionViewType()
|
||||
{
|
||||
switch (Registry::getConfig()->getActiveView()->getClassKey()) {
|
||||
switch (strtolower(Registry::getConfig()->getActiveView()->getClassKey())) {
|
||||
case 'details':
|
||||
case 'oxwarticledetails':
|
||||
return 'view_item';
|
||||
case 'basket':
|
||||
return 'begin_checkout';
|
||||
case 'user':
|
||||
case 'payment':
|
||||
case 'order':
|
||||
return 'checkout_progress';
|
||||
default:
|
||||
return 'view_item_list';
|
||||
}
|
||||
}
|
||||
|
||||
public function d3GAGetCheckoutStep()
|
||||
{
|
||||
switch (strtolower(Registry::getConfig()->getActiveView()->getClassKey())) {
|
||||
case 'basket':
|
||||
return 1;
|
||||
case 'user':
|
||||
return 2;
|
||||
case 'payment':
|
||||
return 3;
|
||||
case 'order':
|
||||
return 4;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
public function d3GAGetBasketActionType()
|
||||
{
|
||||
$basketAction = Registry::getSession()->getVariable('d3GABasketAction');
|
||||
switch ($basketAction->action) {
|
||||
case 'toBasket':
|
||||
return 'add_to_cart';
|
||||
case 'oxwarticledetails':
|
||||
return 'remove_from_cart';
|
||||
}
|
||||
}
|
||||
|
||||
public function d3GAGetImpressionListType()
|
||||
{
|
||||
$oCurrentView = Registry::getConfig()->getActiveView();
|
||||
@ -183,26 +296,6 @@ class d3_oxcmp_utils_googleanalytics extends d3_oxcmp_utils_googleanalytics_pare
|
||||
return $this->_sModId;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function d3GetCreateCurrentShopUrl()
|
||||
{
|
||||
if (d3_cfg_mod::get($this->_sModId)->getValue('blD3GAAllowDomainLinker')) {
|
||||
return 'auto';
|
||||
}
|
||||
|
||||
return $this->d3GetCurrentShopUrl();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function d3GetCurrentShopUrl()
|
||||
{
|
||||
return oxRegistry::getConfig()->getActiveShop()->getFieldData('oxurl');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
@ -446,7 +539,7 @@ class d3_oxcmp_utils_googleanalytics extends d3_oxcmp_utils_googleanalytics_pare
|
||||
|
||||
$oCurrentView = Registry::getConfig()->getActiveView();
|
||||
|
||||
$aArticleIds = array();
|
||||
$oArticleList = oxNew(ArticleList::class);
|
||||
|
||||
$sMethodName = 'get'.ucfirst($oCurrentView->getClassKey())."ProdList";
|
||||
$oArticleLister = oxNew('d3_google_articlelister');
|
||||
@ -458,7 +551,7 @@ class d3_oxcmp_utils_googleanalytics extends d3_oxcmp_utils_googleanalytics_pare
|
||||
|
||||
stopProfile(__METHOD__);
|
||||
|
||||
return array('aArtIdList' => $aArticleIds);
|
||||
return $oArticleList;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -680,23 +773,11 @@ class d3_oxcmp_utils_googleanalytics extends d3_oxcmp_utils_googleanalytics_pare
|
||||
return $aParameter;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
public function d3isMobile()
|
||||
{
|
||||
if (class_exists('oeThemeSwitcherThemeManager')) {
|
||||
/** @var oeThemeSwitcherThemeManager $oThemeManager */
|
||||
$oThemeManager = oxNew('oeThemeSwitcherThemeManager');
|
||||
|
||||
return $oThemeManager->isMobileThemeRequested();
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
* @throws DBALException
|
||||
* @throws DatabaseConnectionException
|
||||
* @throws DatabaseErrorException
|
||||
*/
|
||||
public function d3GetSendNoBounceEventTime()
|
||||
{
|
||||
|
@ -1,3 +0,0 @@
|
||||
#d3GAOptOut {
|
||||
font-size : 14px;
|
||||
}
|
@ -6,8 +6,5 @@
|
||||
[{block name="BaseAnalytics"}]
|
||||
[{include file="d3ga_gtag.tpl"}]
|
||||
[{oxstyle include=$oViewConf->getModuleUrl('d3_googleanalytics', 'out/src/d3_googleanalytics.css')}]
|
||||
[{if $blD3GAIsMobile}]
|
||||
[{oxstyle include=$oViewConf->getModuleUrl('d3_googleanalytics', 'out/src/d3_googleanalytics_mobile.css')}]
|
||||
[{/if}]
|
||||
[{/block}]
|
||||
[{/if}]
|
@ -1,38 +1,3 @@
|
||||
[{* https://developers.google.com/analytics/devguides/collection/gtagjs/ecommerce *}]
|
||||
[{* https://developers.google.com/analytics/devguides/collection/gtagjs/enhanced-ecommerce *}]
|
||||
gtag('event', 'purchase', {
|
||||
"transaction_id": "24.031608523954162",
|
||||
"affiliation": "Google online store",
|
||||
"value": 23.07,
|
||||
"currency": "USD",
|
||||
"tax": 1.24,
|
||||
"shipping": 0,
|
||||
"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'
|
||||
},
|
||||
{
|
||||
"id": "P67890",
|
||||
"name": "Flame challenge TShirt",
|
||||
"list_name": "Search Results",
|
||||
"brand": "MyBrand",
|
||||
"category": "Apparel/T-Shirts",
|
||||
"variant": "Red",
|
||||
"list_position": 2,
|
||||
"quantity": 1,
|
||||
"price": '3.0'
|
||||
}
|
||||
]
|
||||
});
|
||||
|
||||
[{if $blIsImpressionViewList}]
|
||||
[{* https://developers.google.com/analytics/devguides/collection/gtagjs/enhanced-ecommerce *}]
|
||||
gtag('event', '[{$sImpressionViewType}]', {
|
||||
@ -41,146 +6,75 @@ gtag('event', 'purchase', {
|
||||
[{assign var="oPrice" value=$item->getPrice()}]
|
||||
[{assign var="oManufacturer" value=$item->getManufacturer()}]
|
||||
[{assign var="oCategory" value=$item->getCategory()}]
|
||||
{
|
||||
"id": "[{$item->getFieldData('oxartnum')}]",
|
||||
"name": "[{$item->getFieldData('oxtitle')}]",
|
||||
"list_name": "[{$sImpressionListType}]",
|
||||
"brand": "[{if $oManufacturer}][{$oManufacturer->getTitle()}][{/if}]",
|
||||
"category": "[{if $oCategory}][{$oCategory->getTitle()}][{/if}]",
|
||||
"variant": "",
|
||||
"list_position": [{$smarty.foreach.itemlist.iteration}],
|
||||
"quantity": 1,
|
||||
"price": '[{$oPrice->getPrice()}]'
|
||||
},
|
||||
[{include file="d3ga_gtag_ecommerceproduct.tpl" item=$item iteration=$smarty.foreach.itemlist.iteration listname=$sImpressionListType}]
|
||||
[{/foreach}]
|
||||
]
|
||||
});
|
||||
[{elseif $blIsCheckoutViewList}]
|
||||
[{* https://developers.google.com/analytics/devguides/collection/gtagjs/enhanced-ecommerce *}]
|
||||
gtag('event', '[{$sImpressionViewType}]', {
|
||||
"items": [
|
||||
[{foreach from=$oBasket->getContents() name="itemlist" item="basketContent"}]
|
||||
[{assign var="item" value=$basketContent->getArticle()}]
|
||||
[{assign var="oPrice" value=$item->getPrice()}]
|
||||
[{assign var="oManufacturer" value=$item->getManufacturer()}]
|
||||
[{assign var="oCategory" value=$item->getCategory()}]
|
||||
[{include file="d3ga_gtag_ecommerceproduct.tpl" item=$item iteration=$smarty.foreach.itemlist.iteration listname=$sImpressionListType quantity=$basketContent->getAmount()}]
|
||||
[{/foreach}]
|
||||
]
|
||||
[{if $oVoucherList && $oVoucherList->count()}]
|
||||
, "coupon": "
|
||||
[{foreach from=$oVoucherList item="oVoucher"}]
|
||||
[{assign var="voucherSerie" value=$oVoucher->getSerie()}]
|
||||
[{$voucherSerie->getFieldData('oxserienr')}],
|
||||
[{/foreach}]
|
||||
"
|
||||
[{/if}]
|
||||
});
|
||||
[{elseif $blIsPurchasedList}]
|
||||
[{* https://developers.google.com/analytics/devguides/collection/gtagjs/enhanced-ecommerce *}]
|
||||
[{assign var="oCurrency" value=$oOrder->getOrderCurrency()}]
|
||||
gtag('event', 'purchase', {
|
||||
"transaction_id": "[{$oOrder->getFieldData('oxordernr')}]",
|
||||
"affiliation": "[{$oShop->getFieldData('oxname')|escape:"quotes"}]",
|
||||
"value": [{$oOrder->getFieldData('oxtotalnetsum')}],
|
||||
"currency": "[{$oCurrency->name}]",
|
||||
"tax": [{$dVat}],
|
||||
"shipping": [{$oOrder->getFieldData('oxdelcost')}],
|
||||
"items": [
|
||||
[{foreach from=$oOrder->getOrderArticles() name="itemlist" item="oOrderArticle"}]
|
||||
[{assign var="oArticle" value=$oOrderArticle->getArticle()}]
|
||||
[{include file="d3ga_gtag_ecommerceproduct.tpl" item=$oArticle iteration=$smarty.foreach.itemlist.iteration listname="Purchase List" quantity=$oOrderArticle->getFieldData('oxamount')}]
|
||||
[{/foreach}]
|
||||
]
|
||||
[{if $oVoucherList && $oVoucherList->count()}]
|
||||
, "coupon": "
|
||||
[{foreach from=$oVoucherList item="oVoucher"}]
|
||||
[{assign var="voucherSerie" value=$oVoucher->getSerie()}]
|
||||
[{$voucherSerie->getFieldData('oxserienr')}],
|
||||
[{/foreach}]
|
||||
"
|
||||
[{/if}]
|
||||
});
|
||||
[{/if}]
|
||||
|
||||
[{if $blIsBasketAction}]
|
||||
[{* https://developers.google.com/analytics/devguides/collection/gtagjs/enhanced-ecommerce *}]
|
||||
[{* add_to_cart + remove_from_cart *}]
|
||||
gtag('event', '[{$sBasketActionType}]', {
|
||||
"items": [
|
||||
[{foreach from=$aD3GABasketProdInfos name="itemlist" item="item"}]
|
||||
[{include file="d3ga_gtag_ecommerceproduct.tpl" item=$item iteration=$smarty.foreach.itemlist.iteration listname=$sImpressionListType quantity=$dAmount}]
|
||||
[{/foreach}]
|
||||
]
|
||||
});
|
||||
[{/if}]
|
||||
|
||||
[{* https://developers.google.com/analytics/devguides/collection/gtagjs/enhanced-ecommerce *}]
|
||||
gtag('event', 'add_to_cart', {
|
||||
"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', 'remove_from_cart', {
|
||||
"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', 'begin_checkout', {
|
||||
"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'
|
||||
}
|
||||
],
|
||||
"coupon": ""
|
||||
});
|
||||
|
||||
[{* https://developers.google.com/analytics/devguides/collection/gtagjs/enhanced-ecommerce *}]
|
||||
gtag('event', 'checkout_progress', {
|
||||
"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'
|
||||
}
|
||||
],
|
||||
"coupon": "SUMMER_DISCOUNT"
|
||||
});
|
||||
|
||||
[{* https://developers.google.com/analytics/devguides/collection/gtagjs/enhanced-ecommerce *}]
|
||||
gtag('event', 'set_checkout_option', {
|
||||
"checkout_step": 1,
|
||||
"checkout_option": "shipping method",
|
||||
"value": "USPS"
|
||||
});
|
||||
|
||||
|
||||
[{* ============================================================ *}]
|
||||
|
||||
|
||||
[{if $oD3GASettings->getValue('blD3GASendECommerce') && $oViewConf->getActiveClassName() == 'thankyou'}][{strip}]
|
||||
[{block name="UniversalEcommerceOrder"}]
|
||||
[{assign var="order" value=$oView->getOrder()}]
|
||||
|
||||
[{assign var="currate" value=$order->oxorder__oxcurrate->value}]
|
||||
[{if $oD3GASettings->getValue('blD3GAUseNetto')}]
|
||||
[{math equation="s / r" s=$order->getOrderNetSum() r=$currate format="%.2f" assign="sTotal"}] [{* // total - required - has to be gross sum *}]
|
||||
[{else}]
|
||||
[{math equation="s / r" s=$order->getTotalOrderSum() r=$currate format="%.2f" assign="sTotal"}] [{* // total - required *}]
|
||||
[{/if}]
|
||||
[{math equation="s - r" s=$order->getTotalOrderSum() r=$order->getOrderNetSum() format="%.2f" assign="sTax"}]
|
||||
[{math equation="s / r" s=$order->oxorder__oxdelcost->value r=$currate format="%.2f" assign="sShipping"}]
|
||||
|
||||
gtag('event', 'purchase', {
|
||||
"transaction_id": "[{$order->oxorder__oxordernr->value}]",
|
||||
"affiliation": "[{$oxcmp_shop->oxshops__oxname->value|escape:"quotes"}]",
|
||||
"value": [{$sTotal}],
|
||||
"currency": "[{$order->getFieldData('oxcurrency')}]",
|
||||
"tax": [{$sTax}],
|
||||
"shipping": [{$sShipping}],
|
||||
"items": [
|
||||
|
||||
[{foreach from=$order->getOrderArticles() item=oOrderArticle name="artList"}]
|
||||
[{block name="UniversalEcommerceOrderArticle"}]
|
||||
[{if $oD3GASettings->getValue('blD3GAUseNetto')}]
|
||||
[{assign var="oPrice" value=$oOrderArticle->getPrice()}]
|
||||
[{math equation="s / r" s=$oPrice->getNettoPrice() r=$currate format="%.2f" assign="sPrice"}]
|
||||
[{else}]
|
||||
[{assign var="sPrice" value=$oOrderArticle->oxorderarticles__oxprice->value}]
|
||||
[{/if}]
|
||||
{
|
||||
"id": "[{$order->oxorder__oxordernr->value}]",
|
||||
"name": "[{$oOrderArticle->oxorderarticles__oxtitle->value|escape:"quotes"}]",
|
||||
"list_name": "Search Results",
|
||||
"brand": "Google",
|
||||
"category": "[{$oOrderArticle->oxorderarticles__d3_galocator->value|escape:"quotes"}]",
|
||||
"variant": "[{$oOrderArticle->oxorderarticles__oxselvariant->value}]",
|
||||
"list_position": [{$smarty.foreach.artList.index}],
|
||||
"quantity": [{$oOrderArticle->oxorderarticles__oxamount->value}],
|
||||
"price": '[{$sPrice}]'
|
||||
},
|
||||
[{/block}]
|
||||
[{/foreach}]
|
||||
});
|
||||
[{/block}]
|
||||
[{/strip}][{/if}]
|
||||
[{if $blIsCheckoutViewList || $blIsPurchasedList}]
|
||||
[{* https://developers.google.com/analytics/devguides/collection/gtagjs/enhanced-ecommerce *}]
|
||||
gtag('event', 'set_checkout_option', {
|
||||
"checkout_step": [{$iCheckoutStep}],
|
||||
"checkout_option": "Shipping + Payment",
|
||||
"value": "[{$checkoutOptionValue}]"
|
||||
});
|
||||
[{/if}]
|
@ -0,0 +1,15 @@
|
||||
[{if !$quantity}][{assign var="quantity" value=1}][{/if}]
|
||||
[{assign var="oPrice" value=$item->getPrice()}]
|
||||
[{assign var="oManufacturer" value=$item->getManufacturer()}]
|
||||
[{assign var="oCategory" value=$item->getCategory()}]
|
||||
{
|
||||
"id": "[{$item->getFieldData('oxartnum')}]",
|
||||
"name": "[{$item->getFieldData('oxtitle')}]",
|
||||
"list_name": "[{$listname}]",
|
||||
"brand": "[{if $oManufacturer}][{$oManufacturer->getTitle()}][{/if}]",
|
||||
"category": "[{if $oCategory}][{$oCategory->getTitle()}][{/if}]",
|
||||
"variant": "[{$item->getFieldData('oxvarselect')}]",
|
||||
"list_position": [{$iteration}],
|
||||
"quantity": [{$quantity}],
|
||||
"price": '[{$oPrice->getPrice()}]'
|
||||
},
|
Loading…
Reference in New Issue
Block a user