0

配置此事件时遇到真正的麻烦。我使用 Qubit.com 标签管理器,这是我用于“查看产品”事件的代码。

此事件未跟​​踪,我不知道为什么。这是代码 -

function () {
var _this = this;

console.log('1 FB ViewContent Start');

    var product_ids = [];
    if(universal_variable.transaction.line_items){
        for (var i = 0; i < universal_variable.transaction.line_items.length; i++) {
            product_ids.push(universal_variable.transaction.line_items[i].product.sku_code)
        }
    }

    console.log('2 FB ViewContent Product List Compiled');

    fbq('track', 'ViewContent', {
      content_ids: product_ids,
      content_type: 'product',
      value: "" + _this.valueForToken("ORDER_TOTAL"),
  currency: "" + _this.valueForToken("CURRENCY_CODE")
     });

     console.log('3 FB ViewContent Tracked');

}
4

1 回答 1

0

您没有在此代码中调用任何 javascript 事件操作,就像对产品所做的那样。您是在目录页面上还是在重新加载页面(详细页面)后查看单个产品。在这两种情况下,代码都会有所不同。你能在这里粘贴你的完整代码吗?

我正在分享另一种解决此问题的方法。您需要在 head 标签关闭之前放置 javascript 代码。

// For single product on the product's detail page
<script>
var _this = this;

    var product_ids = [];
    if(universal_variable.transaction.line_items){
        for (var i = 0; i < universal_variable.transaction.line_items.length; i++) {
            product_ids.push(universal_variable.transaction.line_items[i].product.sku_code)
        }
    }
//Facebook Pixel Code

 !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','https://connect.facebook.net/en_US/fbevents.js');
// FB init 
fbq('init', 'YOUR_PIXEL_ID');
fbq('track', 'PageView');
//FB event
    fbq('track', 'ViewContent', {
      content_ids: product_ids,
      content_type: 'product',
      value: "" + _this.valueForToken("ORDER_TOTAL"),
      currency: "" + _this.valueForToken("CURRENCY_CODE")
     });
</script>

所有事件参数值都应该在代码中。

于 2017-11-24T08:29:03.397 回答