ecommerce.js的实现

当前在我们的订单确认页面上,我们有:

analytics.js:

/* Google Analytics */
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,'script','https://www.google-analytics.com/analytics.js','ga');
ga('create','UA-102324575-1','auto');
ga('require','GTM-WPS5DXR');
ga('send','pageview');
</script>

我想完成此代码,以发送有关Google Analytics(分析)中交易的信息。 所以我添加了这段代码:

ga('require','ecommerce');
ga('ecommerce:addTransaction',{
  'id': 'order_number','affiliation': 'affiliate1','revenue': 'order_amount','shipping': 'shipping_cost','tax': 'tax_amount'                     
});  '','currency': 'EUR'
});

ga('ecommerce:addItem',{
  'id': 'order_id','name': 'product_name','price': 'product_price',< ! -- Unit price -- >
  'quantity': 'product_quantity'         
});

ga('ecommerce:send');

这样对吗?

非常感谢!

lyloney 回答:ecommerce.js的实现

这部分存在不一致之处:

});  '','currency': 'EUR'
});

必须在 ecommerce:addTransaction 块和 ecommerce:addItem 块内指定 currency 参数。请参阅下面的文档中的示例:

https://developers.google.com/analytics/devguides/collection/analyticsjs/ecommerce#multicurrency

本文链接:https://www.f2er.com/3137859.html

大家都在问