Gtag - 基本的“购买”事件未触发

问题描述

每当我网站上的用户成功进行交易时,我都会设置以下事件:

window.gtag("event","purchase",{
    id: new Date().getTime().toString(),value: 59.97,currency: "USD",});

我直接从 Google 的增强型电子商务文档中挑选了该活动:

https://developers.google.com/analytics/devguides/collection/gtagjs/enhanced-ecommerce#measure_purchases

不知道为什么它没有增加我最近的销售额?

注意:我在我的 GA 管理员中启用了增强型电子商务。

解决方法

您的负载看起来不符合所提供的示例。尝试将 id 更改为 transaction_id :

gtag('event','purchase',{
  "transaction_id": "24.031608523954162","affiliation": "Google online store","value": 23.07,"currency": "USD","tax": 1.24,"shipping": 0,"items": [
    {
      "id": "P12345","name": "Android Warhol T-Shirt","list_name": "Search Results","brand": "Google","category": "Apparel/T-Shirts","variant": "Black","list_position": 1,"quantity": 2,"price": '2.0'
    },{
      "id": "P67890","name": "Flame challenge TShirt","brand": "MyBrand","variant": "Red","list_position": 2,"quantity": 1,"price": '3.0'
    }
  ]
});