簡體   English   中英

Google Analytics(分析)電子商務中的數據丟失

[英]Missing data in Google Analytics Ecommerce

當我將生產數據庫中的交易與Google Analytics(分析)電子商務面板中的交易進行比較時,很明顯我丟失了大量數據。 我在網站上進行購買是為了進行測試,並且在購買成功后出現的“謝謝頁面”中,我在檢查該元素時看到以下Google Analytics(分析)跟蹤代碼:

<script>
(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','//www.google-analytics.com/analytics.js','ga');
ga('create', '[My Google Analytics tracking ID]', 'auto');
ga('require', 'ec');
ga('ec:addProduct', {
'id': '[Product ID]', 'name': '[Product name]', 'category': '[Product category]',
'brand': '[Product brand]', 'variant': '[Product variant]', 'price': '[Product price]', 'quantity': 1 });

// Transaction level information is provided via an actionFieldObject.
ga('ec:setAction', 'purchase', { 'id': '[Transaction ID]', 'affiliation': '[Organization where the transaction took place]', 'revenue': '[Revenue value]' });
ga('send', 'pageview');
</script>

此交易大約在24小時前進行。 當我轉到Google Analytics(分析)電子商務信息中心的“銷售業績”部分時,當我查找具有在上面'id': '[Transaction ID]'發送'id': '[Transaction ID]' ,找不到該交易:

在此處輸入圖片說明

在上面的橢圓中,我提供了[交易ID],但您找不到它。 我在數據庫中發現很多情況,其中有些交易在Google Analytics(分析)電子商務中找不到。

Google Analytics(分析)顯示了一些交易,但不是全部。 我檢查了發送給Google Analytics(分析)的代碼,它是正確的,沒有語法錯誤,一切都很完美。 為什么Google Analytics(分析)電子商務的“銷售業績”部分缺少交易? 謝謝。

更新1:

對於'name': '[Product name]' ,我將[Product name]字符串145 B發送給您。大概有這么長的時間:

¡在T99 mi psumi ss E325上啟用DummyteXtífthe+印刷和排版(Id Ustrylore,Ips um Hasbee,Nthein)Dustr Ss Ttandar! (2018-01-05)

文本包含以下特殊字符:

  1. ¡
  2. 一世
  3. +
  4. ñ
  5. --

長度是問題所在(145 B),還是我在[Product name]發送特殊字符的事實?

問題是我從數據庫中提取了[Product category] ,令我驚訝的是,其中許多值在字符串后都有一個空行。 這導致Google Analytics(分析)代碼如下所示:

<script>
    (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','//www.google-analytics.com/analytics.js','ga');
    ga('create', '[My Google Analytics tracking ID]', 'auto');
    ga('require', 'ec');
    ga('ec:addProduct', {
    'id': '[Product ID]', 'name': '[Product name]', 'category': '[Product category]
    ',
    'brand': '[Product brand]', 'variant': '[Product variant]', 'price': '[Product price]', 'quantity': 1 });

    // Transaction level information is provided via an actionFieldObject.
    ga('ec:setAction', 'purchase', { 'id': '[Transaction ID]', 'affiliation': '[Organization where the transaction took place]', 'revenue': '[Revenue value]' });
    ga('send', 'pageview');
</script>

請注意[Product category]不會出現在一行中。 這就是問題的原因。 當然,這被解釋為JavaScript語法錯誤,並且Google Analytics(分析)從未處理過該條目,這就是不運行Google Analytics(分析)腳本的同義詞。 解決方法是從數據庫中刪除那些不必要的行。 另外,例如,如果您使用的是PHP,則可以使用PHP修剪函數(“從字符串的開頭和結尾開始的帶空格(或其他字符)”): http : //php.net/manual/en/function。 trim.php ),以便您的PHP代碼可以在類別名稱的末尾修復這些多余的行。 但是我認為最好的方法是修復數據庫中的類別名稱,因為否則類似的情況可能會導致您今天或將來編寫的其他API或腳本中出現類似的錯誤。 如果您的代碼不是用PHP編寫的,請在您使用的編程語言中找到與trim函數等效的功能。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM