Google Analytics: Page views tracked but not ecommerce transactions
Asked Answered
A

1

6

I'm trying to figure out why the Ecommerce tracking in Google Analytics doesn't seem to work. I can see the page views correctly tracked but no transactions.

Snippet from the confirmation page:

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

    _gaq.push(['b._setAccount', 'UA-YYYYYYYY-1']);
    _gaq.push(['b._setDomainName', 'none']);
    _gaq.push(['b._addTrans',
                  '44bbd391-ff38-4f8d-ad68-aec490666151',
                  'Name',
                  '1.00',
                  '',
                  '',
                  '',
                  '',
                  ''
              ]);
    _gaq.push(['b._addItem',
                  '44bbd391-ff38-4f8d-ad68-aec490666151',
                  '15',
                  'test',
                  '',
                  '1.00',
                  '1'
              ]);
    _gaq.push(['b._trackTrans']);

    _gaq.push(['b._trackPageview']);
    (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';
        var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
    })();
</script>

...
</head>

I'm monitoring the traffic on the page with Firebug confirming that all pixel requests were made and came back OK.

I read about having to wait a few hours, up to one day, before you can see results in GA, but I can see the page views after only waiting a few minutes.

However, the transactions tracked using the same tracker object ("b") are not to be found anywhere(could the Ecommerce reports be refreshing slower than the page views?)

Allogamy answered 9/3, 2011 at 15:58 Comment(2)
How long have you been waiting? Though, anecdotally, I've actually found the eCommerce data to be extraordinarily fast to process.Ladonna
It's been a few hours and still nothing. I don't think it's the wait time because, as I said, page views tracked at the same time are appearing just fine. I'm investigating further and keep this place updated, hopefully some will find it useful.Allogamy
A
7

And I finally found the issue. The answer is inconspicuously present on the GA docs page:

_trackTrans()

Sends both the transaction and item data to the Google Analytics server. This method should be called after _trackPageview(), and used in conjunction with the _addItem() and addTrans() methods.

It's rather easy to overlook but it has such a fundamental effect: transactions won't be tracked.

So yes, always call _trackTrans after _trackPageview!

Allogamy answered 9/3, 2011 at 21:35 Comment(6)
Whoa, that's so bizarre. +1. Any idea why?Ladonna
No idea. In my mind there was (and still is) no dependency between the two types of tracking. You can do one, the other, or both. That's why it never crossed my mind that the calling order would be such an issue. I'm curious, however if it's a bug or a feature...Allogamy
So weird that it uses the word should instead of must.Ladonna
This is very strange behaviour from GA. I have came across this question in a GAIQ practice test and I would have assumed that it would have been the other way around. +1 for coming back with the answer and a link to the documentation.Malorie
@Allogamy So why was this an issue for you? Judging by your code in OP, your already calling _trackPageview before _trackTrans.Manisa
No, look again: _gaq.push(['b._trackPageview']); is after _gaq.push(['b._trackTrans']); I am talking about the ones towards the end of the code snippet; the ones towards the start are called for a different GA account.Allogamy

© 2022 - 2024 — McMap. All rights reserved.