GA电子商务代码问题

时间:2013-05-07 07:23:08

标签: javascript google-analytics

我有一个电子商务代码,其中我只传递交易ID和数量详细信息。但这并没有记录在GA API中。下面是代码。

<script type="text/javascript" language="javascript">
var _gaq = _gaq || [];
_gaq.push(
['mainind._setAccount', 'UA-12345-1'],
['mainind._setDomainName', '.abcd.com'],
['mainind._setAllowHash', false],
['mainind._trackPageview'],
['mainind._trackPageLoadTime']
);

_gaq.push(['_addTrans',
    '136069322',    
    '',                 
    '',                 
    '',                 
    '',                 
    '',                 
    '',                 
    ''                  
]);
_gaq.push(['_addItem',
    '136069322',                        
    '',                                     
    '',                                     
    '',                                     
    '',                                     
    '4' 
]);

_gaq.push(['_trackTrans']); 

(function() {
var ga = document.createElement('script');
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
ga.setAttribute('async', 'true');
document.documentElement.firstChild.appendChild(ga);
})();

请帮我解决这个问题..

谢谢, Ashok Verma

1 个答案:

答案 0 :(得分:1)

您必须为通过_setAccount('mainind')定义的相同跟踪器对象调用_addTrans,_addItem和_trackTrans命令:

  <script type="text/javascript" language="javascript">
var _gaq = _gaq || [];
_gaq.push(
['mainind._setAccount', 'UA-12345-1'],
['mainind._setDomainName', '.abcd.com'],
['mainind._setAllowHash', false],
['mainind._trackPageview'],
['mainind._trackPageLoadTime']
);

_gaq.push(['mainind._addTrans',
    '136069322',    
    '',                 
    '',                 
    '',                 
    '',                 
    '',                 
    '',                 
    ''                  
]);
_gaq.push(['mainind._addItem',
    '136069322',                        
    '',                                     
    '',                                     
    '',                                     
    '',                                     
    '4' 
]);

_gaq.push(['mainind._trackTrans']); 

(function() {
var ga = document.createElement('script');
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
ga.setAttribute('async', 'true');
document.documentElement.firstChild.appendChild(ga);
})();

另请注意,_setAllowHash_trackPageLoadTime已弃用,应予以删除。