GA 调试显示电子商务交易发送,但数据未显示

GA Debug Shows Ecommerce Transaction Sending, but Data is Not Showing Up

使用提供有限源控制的框架 (Blackbaud Internet Solutions),我正在尝试在我的站点中实施 Google Analytics 电子商务跟踪。

因为我使用的是自定义捐赠表格,[link]BB 文档中的这段代码 (https://www.blackbaud.com/files/support/guides/bbis/tkConfigureE-Commerce.html) 不起作用,Google 中的大多数开发人员指南假设更多BBIS 允许的源代码控制。

这位于“管理”>“站点和设置”>“[站点名称]”>“设置”选项卡下的 "Site tracking" 部分(对于不熟悉 BBIS 的人来说,假设它位于头部)。

<script async src="https://www.googletagmanager.com/gtag/js?id=UA-XXX-XX"></script>
<script>
  window.dataLayer = window.dataLayer || [];
  function gtag(){dataLayer.push(arguments);}
  gtag('js', new Date());

  gtag('config', 'UA-XXX-XX');
  gtag('require', 'ecommerce');
</script>

此代码出现在捐赠确认页面的底部:

<script type="text/javascript">
function returnDonationObject() {
      // First get the donation
      var gift = document.getElementById("givingSummary");
      var tds = gift.getElementsByTagName("td");
      var totalDonation = 0;

      for(var i = 0; i < tds.length; i++) {
        if(tds[i].innerText.indexOf("$") > -1) {
          var transformedNum = parseFloat(tds[i].innerText.slice(1, tds[i].innerText.length));
          totalDonation += transformedNum;
        }
      }
      totalDonation = totalDonation.toFixed(2);

      // Then get the GUID from the url
      var guid = window.location["href"].split("?t=")[1];

      // create and return the object
      var donationObject = {
        "transactionId" : guid,
        "transactionTotal" : totalDonation
      }
      return donationObject;
  }

  var donationObject = returnDonationObject();
  gtag('event', 'purchase', donationObject);
</script>

returnDonationObject returns 预期的 transactionId 和 transactionTotal,并使用 GA 调试扩展,看起来最终的 gtag('event', 'purchase') 函数成功触发:

Running command: ga("gtag_UA_XXX_XX.send", "event", {forceSSL: true, &gtm: "2ou6k2", hitCallback: [function], eventCategory: "ecommerce", eventAction: "purchase"})
Sent beacon:
v=1&_v=j77d&a=220349989&t=event&_s=3&dl=https%3A%2F%2Fsite-name.com%2Ffoundation%2Fdonate%2Fgive-online%3Ft%3Db2d87d89-e000-4457-8e43-xxxxxx&dr=https%3A%2F%2Fpayments.blackbaud.com%2FPages%2FSecurePayment.aspx%3Ft%3Db2d87d89-e000-4457-8e43-xxxxxxx&ul=en-us&de=UTF-8&dt=Foundation%20Donation%20Form&sd=24-bit&sr=1920x1080&vp=1313x937&je=0&ec=ecommerce&ea=purchase&_u=SCEAAUAL~&jid=&gjid=&cid=760857713.1560526567&tid=UA-XXX-XX&_gid=216294229.1562588238&gtm=2ou6k2&pa=purchase&z=1491483290

VM49 analytics_debug.js:16 <unknown>        (&gtm)  2ou6k2
VM49 analytics_debug.js:16 _j1              (&jid)  
VM49 analytics_debug.js:16 _j2              (&gjid) 
VM49 analytics_debug.js:16 adSenseId        (&a)    220349989
VM49 analytics_debug.js:16 apiVersion       (&v)    1
VM49 analytics_debug.js:16 clientId         (&cid)  760857713.1560526567
VM49 analytics_debug.js:16 ec:action        (&pa)   purchase
VM49 analytics_debug.js:16 encoding         (&de)   UTF-8
VM49 analytics_debug.js:16 eventAction      (&ea)   purchase
VM49 analytics_debug.js:16 eventCategory    (&ec)   ecommerce
VM49 analytics_debug.js:16 hitType          (&t)    event
VM49 analytics_debug.js:16 javaEnabled      (&je)   0
VM49 analytics_debug.js:16 language         (&ul)   en-us
VM49 analytics_debug.js:16 location         (&dl)   https://site-name.com/foundation/donate/give-online?t=b2d87d89-e000-4457-8e43-xxxxxxxx
VM49 analytics_debug.js:16 referrer         (&dr)   https://payments.blackbaud.com/Pages/SecurePayment.aspx?t=b2d87d89-e000-4457-8e43-xxxxxxx
VM49 analytics_debug.js:16 screenColors     (&sd)   24-bit
VM49 analytics_debug.js:16 screenResolution (&sr)   1920x1080
VM49 analytics_debug.js:16 title            (&dt)   Foundation Donation Form
VM49 analytics_debug.js:16 trackingId       (&tid)  UA-XXX-XX
VM49 analytics_debug.js:16 viewportSize     (&vp)   1313x937
VM135:29 {transactionId: "b2d87d89-e000-4457-8e43-xxxxxxxxx", transactionTotal: "78.02"}

但是,电子商务数据仍然没有流向 Google 分析(实施此代码后我已经等了超过 48 小时)。任何人都可以确定我做错了什么吗?谢谢

对于以后遇到这个问题的任何人来说,这个问题其实很简单。我只是在 donationObject 中使用 Google Analytics 的旧实现中的键名。将 donationObject 更改为此得到数据流:

var donationObject = {
   "transaction_id" : guid,
   "value" : totalDonation
}