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?)

CyberDude
  • 8,541
  • 5
  • 29
  • 47
  • How long have you been waiting? Though, anecdotally, I've actually found the eCommerce data to be extraordinarily fast to process. – Yahel Mar 09 '11 at 17:44
  • 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. – CyberDude Mar 09 '11 at 19:27

1 Answers1

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!

CyberDude
  • 8,541
  • 5
  • 29
  • 47
  • Whoa, that's so bizarre. +1. Any idea why? – Yahel Mar 10 '11 at 00:56
  • 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... – CyberDude Mar 10 '11 at 08:13
  • So weird that it uses the word should instead of must. – Yahel Mar 10 '11 at 13:10
  • 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. – crmpicco Nov 17 '12 at 21:13
  • @CyberDude So why was this an issue for you? Judging by your code in OP, your already calling `_trackPageview` before `_trackTrans`. – Noz Feb 17 '15 at 16:34
  • 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. – CyberDude Feb 17 '15 at 16:46