Magento 1.9中的Facebook像素跟踪安装

时间:2016-02-16 14:37:12

标签: facebook magento-1.9

我一直在尝试实施新的Facebook跟踪像素来跟踪Magento商店的转化。

我在head标签中有基本像素代码

<!-- Facebook Pixel Code -->
<script>
!function(f,b,e,v,n,t,s){if(f.fbq)return;n=f.fbq=function(){n.callMethod?
n.callMethod.apply(n,arguments):n.queue.push(arguments)};if(!f._fbq)f._fbq=n;
n.push=n;n.loaded=!0;n.version='2.0';n.queue=    [];t=b.createElement(e);t.async=!0;
t.src=v;s=b.getElementsByTagName(e)[0];s.parentNode.insertBefore(t,s)}(window,
document,'script','//connect.facebook.net/en_US/fbevents.js');

fbq('init', 'PIXELID');
fbq('track', "PageView");</script>
<noscript><img height="1" width="1" style="display:none"
src="https://www.facebook.com/tr?id=PIXELID&ev=PageView&noscript=1"
/></noscript>
<!-- End Facebook Pixel Code -->

然后我在主题目录中找到了success.phtml文件,根据我的理解,在阅读我找到的Facebook文档时添加了以下代码;

<?php
//Get Order Number & Order Total
$order = Mage::getModel('sales/order')->loadByIncrementId(Mage::getSingleton('checkout/session')->getLastRealOrderId());
$amount = number_format($order->getGrandTotal(),2);
?>
<script>
// Purchase
// Track purchases or checkout flow completions (ex. landing on "Thank You" or confirmation page)
fbq('track', 'Purchase', {'value': '<?php echo $amount; ?>', 'currency': 'GBP'});
</script>

<noscript>
<img height="1" width="1" alt="" style="display:none" src="https://www.facebook.com/tr?id=PIXELID&amp;ev=Purchase&amp;cd[value]=<?php echo $amount; ?>&amp;cd[currency]=GBP&amp;noscript=1"/>
</noscript>

上述代码在通过Facebook广告点击下订单时根本不发送任何数据。任何人都可以解释我做错了什么吗?

0 个答案:

没有答案