Page 1 of 1

Signup tracking; product info never shows in Google Analytic

PostPosted: May 20th, 2011, 6:34 am
by sugeneris
In the membership tracking code area, I've included the snippet below. This is lifted directly from the Google Analytics documentation.

Over in Analytics, under the Ecommerce section, the Transactions view seems to be working fine, which as far as I can tell comes from the _addTrans portion of the code. The "quantity" column always shows 0, but we'll come to that in the next bit as that's not an _addTrans value.

The Product Performance area, though, shows absolutely no data. This is the stuff that should be coming from the _addItem chunk. Note that the quantity is hard-coded as "1" and that we already know the %%subscr_id%% variable works from the Transaction info. So, even if not all the information is getting through, at the very least the transactions should be showing a quantify of 1.

Based on that, I have to assume that the entire _addItem block is failing, but I can't see why. Has anyone else gotten this to work, and could you share your code? I'm using s2Member Pro 3.5.8 on WP 3.1.2


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

    _gaq.push(['_addTrans',
       '%%subscr_id%%',           // order ID - required
       'Client Site Name', // affiliation or store name
       '%%initial%%',          // total - required
       '',           // tax
       '',              // shipping
       '',       // city
       '',     // state or province
       ''             // country
    ]);
   // add item might be called for every item in the shopping cart
  _gaq.push(['_addItem',
    '%%subscr_id%%',           // order ID - required
    '%%item_number%%',           // SKU/code - required
    '%%item_name%%',        // product name
    '',   // category or variation
    '%%initial%%',          // unit price - required
    '1'               // quantity - required
  ]);

  _gaq.push(['_trackTrans']); //submits transaction to the Analytics servers


    (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>

Re: Signup tracking; product info never shows in Google Anal

PostPosted: May 23rd, 2011, 6:24 pm
by Jason Caldwell
Investigating now. Thanks for your patience.

Re: Signup tracking; product info never shows in Google Anal

PostPosted: May 23rd, 2011, 6:36 pm
by Jason Caldwell
What is the exact value of this Replacement Code?
%%item_name%%

Does it contain any single-quotes? If so, that could cause it to fail in this context, because the value is wrapped with single-quotes as well. In other words, this would cause it to fail.

Code: Select all
  _gaq.push(['_addItem',
    '%%subscr_id%%',           // order ID - required
    '%%item_number%%',           // SKU/code - required
    'Jason's Item',        // product name ( FAIL )
    '',   // category or variation
    '%%initial%%',          // unit price - required
    '1'               // quantity - required
  ]);

Re: Signup tracking; product info never shows in Google Anal

PostPosted: May 24th, 2011, 12:53 pm
by sugeneris
Oddly, it started working about two days later. Maybe commerce tracking takes a bit longer to get results showing, or something.

The quote bit is a good point, though. Might be a good idea to throw in a quick warning about that.

Re: Signup tracking; product info never shows in Google Anal

PostPosted: May 24th, 2011, 7:30 pm
by Jason Caldwell
Thanks for reporting back on this.
It's much appreciated.

Certainly, I'll see what we can do about that in a future release.