2010-02-06 271 views
3

我無法讓Google Analytics跟蹤商業交易。以下是我在訂單確認頁面上生成的代碼。Google Analytics(分析)無法跟蹤交易

我不知道如何調試這個,我找不到有關如何從谷歌的js獲取錯誤代碼的信息。如果可以的話,我會在Firebug的控制檯中運行它。在這一點上,我堅持如何繼續。

<script type="text/javascript"> 
    var _gaq = _gaq || []; 
    _gaq.push(['_setAccount', 'UA-########-#']); 
    _gaq.push(['_setDomainName', '.mydomain.com']); 
    _gaq.push(['_trackPageview']); 


    _gaq.push(['_addTrans', 
     '117',   // order ID - required 
     'StoreName.com', // affiliation or store name 
     '35.96',   // total - required 
     '0',   // tax 
     '0',    // shipping 
     '',  // city 
     '',  // state or province 
     ''    // country 
    ]); 
    _gaq.push(['_addItem', 
     '117',   // order ID - required 
     '1',   // SKU/code - required 
     '1 Pack',  // product name 
     'Catagory5',   // catagory 
     '35.96,   // unit price - required 
     '1'    // quantity - required 
    ]); 
    _gaq.push(['_trackTrans']); 

    (function() { 
    var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true; 
    ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js'; 
    (document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(ga); 
    })(); 
</script> 

謝謝你的任何建議。

+1

在單價後發現錯字 – reconbot 2010-02-12 22:03:42

回答

3

結帳this page on Google Code。它提供了你想要做什麼的例子。

+0

我使用的是Google較新的異步方法,但想法相同。我目前正在執行所需的3個步驟,並在該頁面上列出。 – reconbot 2010-02-06 23:50:17

+0

與Google示例相比,您的代碼看起來不錯。您確實關閉了電子商務追蹤? :+)另外,非異步代碼是否適合你? – 2010-02-08 04:21:04

+0

我會換掉它並檢查。 – reconbot 2010-02-09 16:23:11

相關問題