Answers:
步骤1:
您需要在ordee成功文件上添加转换代码
app/design/frontend/yourpackage/yourtemplate/template/checkout/success.phtml
如果没有文件退出,则:
复制success.phtml
自
app/design/frontend/base/default/template/checkout/
并粘贴
app/design/frontend/yourpackage/yourtemplate/template/checkout/
添加您的 code on new success.phtml
在此文件中,您可以使用以下代码订购ID
$this->getOrderId()
或: 检查此扩展程序 http://www.magentocommerce.com/magento-connect/luka-google-adwords-conversion-tracking.html
您可以将以下代码片段复制并粘贴到您的success.phtml中
/app/design/frontend/yourpackage/yourtemplate/template/checkout/success.phtml
<?php
$orderId = Mage::getSingleton('checkout/session')->getLastOrderId();
$order = Mage::getModel('sales/order')->load($orderId);
$total = (float)number_format($order()->getSubtotal(),2);
?>
<script type="text/javascript">
/* <![CDATA[ */
var google_conversion_id = 'CONVERSION_ID';
var google_conversion_language = "LANG_CODE";
var google_conversion_format = "FORMAT";
var google_conversion_color = "COLOR";
var google_conversion_label = "LABEL";
if (<?php echo $total?>) {
var google_conversion_value = <?php echo $total?>;
}
/* ]]> */
</script>
<script type="text/javascript" src="//www.googleadservices.com/pagead/conversion.js">
</script>
<noscript>
<div style="display:inline;">
<img height="1" width="1" style="border-style:none;" alt=""
src="//www.googleadservices.com/pagead/conversion/CONVERSION_ID/?value=<?php echo $total?>&label=LABEL&guid=ON&script=0"/>
</div>
</noscript>
确保在上面的代码中更改以下变量-:
CONVERSION_ID
(例如999999999
)LANG_CODE
(例如en
)FORMAT
(例如1
)COLOR
(例如#ffffff
)LABEL
(例如-9C8CICMuggQ4O_B1wM
)如果您对上述方法不满意,则可以使用以下模块,该模块易于配置,而不必花时间去处理代码。
http://www.scommerce-mage.co.uk/magento-google-adwords-conversion-tracking.html
希望能帮助到你!
$order
在上面的代码中未定义。解决方法: $orderId = Mage::getSingleton('checkout/session')->getLastOrderId();
$order = Mage::getModel('sales/order')->load($orderId);
$total = (float) number_format($order->getSubtotal(), 2);
这是对我有用的代码
<?php
//Get Order Number & Order Total
$order = Mage::getModel('sales/order')->loadByIncrementId(Mage::getSingleton('checkout/session')->getLastRealOrderId());
$amount = number_format($order->getGrandTotal(),2);
?>
我从此链接中获得了它,也许它也对某人有所帮助。
http://www.jxtgroup.com/how-to-setup-conversion-tracking-in-magento_3912881.html