Reputation: 11
I have a ecommerce code where in i am only passing transaction ID and Quantity details. but this is not recorded in GA API..Below is the code.
<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);
})();
Please help me out with this..
Thanks, Ashok Verma
Upvotes: 0
Views: 97
Reputation: 703
You have to call the _addTrans, _addItem and _trackTrans commands for the same tracker object defined via _setAccount ('mainind'):
<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);
})();
Also note that _setAllowHash and _trackPageLoadTime are deprecated and should be removed.
Upvotes: 1