【问题标题】:How to view Gtag recommended parameters in Google Analytics?如何在 Google Analytics 中查看 Gtag 推荐参数?
【发布时间】:2018-12-28 05:35:26
【问题描述】:

我在我的网站中使用 gtag.js 库并在谷歌分析中查看结果。我已经实现了purchase事件如下:

trackPurchase({ checkoutResult, order, items }) {
  const gtagItems = items.map(item => orderItemToGAItem(item));
  this.gtag('event', 'purchase', {
    transaction_id: checkoutResult.transactionId,
    value: checkoutResult.amount,
    currency: checkoutResult.currency,
    shipping: order.shippingCost,
    itmes: gtagItems,
  });
}

当触发事件时,chrome 中的 GA 调试器会在控制台中打印以下内容:

Running command: ga("gtag_UA_********.send", "event", {currencyCode: "HKD", forceSSL: true, &gtm: "2oubc0", hitCallback: [function], eventCategory: "ecommerce", eventAction: "purchase", eventValue: 400})
analytics_debug.js:23 
Sent beacon:
[ ****** ]


analytics_debug.js:23 <unknown>        (&gtm)  2oubc0
analytics_debug.js:23 _j1              (&jid)  
analytics_debug.js:23 _j2              (&gjid) 
analytics_debug.js:23 adSenseId        (&a)    317378694
analytics_debug.js:23 apiVersion       (&v)    1
analytics_debug.js:23 clientId         (&cid)  [ ****** ]
analytics_debug.js:23 currencyCode     (&cu)   HKD
analytics_debug.js:23 ec:action        (&pa)   purchase
analytics_debug.js:23 ec:id            (&ti)   [ ****** ]
analytics_debug.js:23 ec:revenue       (&tr)   400
analytics_debug.js:23 ec:shipping      (&ts)   20
analytics_debug.js:23 encoding         (&de)   UTF-8
analytics_debug.js:23 eventAction      (&ea)   purchase
analytics_debug.js:23 eventCategory    (&ec)   ecommerce
analytics_debug.js:23 eventValue       (&ev)   400
analytics_debug.js:23 hitType          (&t)    event
analytics_debug.js:23 javaEnabled      (&je)   0
analytics_debug.js:23 language         (&ul)   en-us
analytics_debug.js:23 location         (&dl)   [ ****** ]
analytics_debug.js:23 screenColors     (&sd)   24-bit
analytics_debug.js:23 screenResolution (&sr)   2560x1440
analytics_debug.js:23 title            (&dt)   OrderInfo
analytics_debug.js:23 trackingId       (&tid)  [ ****** ]
analytics_debug.js:23 viewportSize     (&vp)   1643x928

我可以在谷歌分析控制台中看到purchase 事件,但是没有label,我找不到shipping、value、currency、transaction_id 和item 中的任何一个。如何按这些值过滤事件或查看它们?

提前致谢。

【问题讨论】:

    标签: google-analytics gtag.js


    【解决方案1】:

    实际上,您不能在事件参数中使用任何字段名称,因为您希望它们正确集成到 Analytics 中。您应该根据本节尊重名称:https://developers.google.com/analytics/devguides/collection/gtagjs/migration#map_analyticsjs_fields_to_gtagjs_parameters

    如果要设置标签,使用的字段名称为event_label,如下:

    this.gtag('event', 'purchase', {
      'event_label': checkoutResult.transactionId
    });
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-04-19
      相关资源
      最近更新 更多