Google Analytics电子商务跟踪无需税收即可获取价格(magento)

时间:2013-12-06 13:28:42

标签: php magento google-analytics

我正在使用magento。为了使用谷歌分析,我在管理员端启用了帐户ID(UA-XXXXXXXX-1)的GA模块,它运行正常。现在,对于电子商务跟踪,它正在跟踪价格而不含税,例如价格15 +税1 = 16,它只捕获15而不是16.我知道语法

_addItem(transactionId, sku, name, category, price, quantity)
_addTrans(transactionId, affiliation, total, tax, shipping, city, state, country)
_trackTrans()

但是在magento我不知道它是如何在内部工作的。请指导我..

2 个答案:

答案 0 :(得分:1)

看看@

  

/app/code/core/Mage/GoogleAnalytics/Block/Ga.php

$result[] = sprintf("_gaq.push(['_addTrans', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s']);",
    $order->getIncrementId(),
    $this->jsQuoteEscape(Mage::app()->getStore()->getFrontendName()),
    $order->getBaseGrandTotal(),
    $order->getBaseTaxAmount(),
    $order->getBaseShippingAmount(),
    $this->jsQuoteEscape(Mage::helper('core')->escapeHtml($address->getCity())),
    $this->jsQuoteEscape(Mage::helper('core')->escapeHtml($address->getRegion())),
    $this->jsQuoteEscape(Mage::helper('core')->escapeHtml($address->getCountry()))
);
foreach ($order->getAllVisibleItems() as $item) {
    $result[] = sprintf("_gaq.push(['_addItem', '%s', '%s', '%s', '%s', '%s', '%s']);",
        $order->getIncrementId(),
        $this->jsQuoteEscape($item->getSku()), $this->jsQuoteEscape($item->getName()),
        null, // there is no "category" defined for the order item
        $item->getBasePrice(), $item->getQtyOrdered()
    );
}
$result[] = "_gaq.push(['_trackTrans']);";

答案 1 :(得分:0)

您可以使用以下方式在模板中获得产品的全价:

// $item is the current product.
$product = Mage::getModel('catalog/product')->load($item->getProductId());

// Price as number
$priceIncludingTax = $this->helper('tax')->getPrice($product, $product->getFinalPrice());

// Formatted price as currency string
$price = strip_tags($this->helper('checkout')->formatPrice($priceIncludingTax, 2));