0

我将此代码从索引正文移动到我的转换/感谢页面的 html 编辑器中。这个 Criteo Javascript 应该将订单详细信息推送到他们的数据库。出了什么问题?

<!-- Conversionpage htmlblock in js test -->

<body onload="fireConversion()">

<script type="text/javascript" src="//static.criteo.net/js/ld/ld.js" async="true"></script>

<script type="text/javascript">
function fireConversion() {
 var order_info = JSON.parse(ORDER_JSON).order_rows;
 var basketproducts = [];
  for(var i=0;i<order_info.length;i++) {
    basketproducts.push( { id: order_info[i].product_id, price: order_info[i].price, quantity: order_info[i].count});
  }
 var orderid = '[OrderNumber]';
 window.criteo_q = window.criteo_q || [];
 var deviceType = /iPad/.test(navigator.userAgent) ? "t" : /Mobile|iP(hone|od)|Android|BlackBerry|IEMobile|Silk/.test(navigator.userAgent) ? "m" : "d";

 window.criteo_q.push( { event: "setAccount", account: 52999 },  { event: "setSiteType", type: deviceType },  { event: "setEmail", email: "" } , { event: "trackTransaction", id: orderid , item: basketproducts });
</script>
}
4

2 回答 2

0

我想你交换了最后两行。尝试这个:

<!-- Conversionpage htmlblock in js test -->

<body onload="fireConversion()">

<script type="text/javascript" src="//static.criteo.net/js/ld/ld.js" async="true"></script>

<script type="text/javascript">
function fireConversion() {
    var order_info = JSON.parse(ORDER_JSON).order_rows;
    var basketproducts = [];
    for (var i = 0; i < order_info.length; i++) {
        basketproducts.push({ id: order_info[i].product_id, price: order_info[i].price, quantity: order_info[i].count });
    }
    var orderid = '[OrderNumber]';
    window.criteo_q = window.criteo_q || [];
    var deviceType = /iPad/.test(navigator.userAgent) ? 't' : /Mobile|iP(hone|od)|Android|BlackBerry|IEMobile|Silk/.test(
        navigator.userAgent) ? 'm' : 'd';

    window.criteo_q.push({ event: 'setAccount', account: 52999 }, { event: 'setSiteType', type: deviceType },
        { event: 'setEmail', email: '' }, { event: 'trackTransaction', id: orderid, item: basketproducts });
}
</script>
于 2020-06-22T20:43:38.257 回答
0

我同时解决了这个问题。

我将以下代码与转换页面的条件一起放在索引正文中。

变量“orderid”的定义由转换页面正文html编辑器中的小脚本定义。

索引正文 html 中的代码:

<script type="text/javascript" src="//static.criteo.net/js/ld/ld.js" async="true"></script>
<script type="text/javascript">
if (document.body.className == "OrderPage ps-German")
{
  var order_info = JSON.parse(ORDER_JSON).order_rows;
  var basketproducts = [];
  for (var i = 0; i < order_info.length; i++) {
     basketproducts.push({ id: order_info[i].product_id, price: order_info[i].price, quantity: order_info[i].count });
  }
  window.criteo_q = window.criteo_q || [];
  var deviceType = /iPad/.test(navigator.userAgent) ? 't' : /Mobile|iP(hone|od)|Android|BlackBerry|IEMobile|Silk/.test(
    navigator.userAgent) ? 'm' : 'd';
  window.criteo_q.push({ event: 'setAccount', account: 59999 }, { event: 'setSiteType', type: deviceType },
    { event: 'setEmail', email: '' }, { event: 'trackTransaction', id: orderid, item: basketproducts });
}
</script>

转换页面中的代码:

<script>
var orderid = '[OrderNumber]';
</script>
于 2020-06-24T09:31:44.100 回答