Prodoct Data Not Showing in Ecommerce

13 views
Skip to first unread message

nbirkes

unread,
Nov 5, 2009, 10:36:04 AM11/5/09
to google-analytics-api - GA Data Export API
OK, I set up my site as an ecommerce site in Analytics and am trying
to get it to track all of the orders placed on my site. I read how to
install the tracking code and understand it for the most part.

The problem is that the thank you page of my shopping cart does not
make available to me the list of items that were on the order. Because
of this I have to get clever about how I submit a transaction.

The only place I can gather the shopping cart detail is the final step
of the checkout right before the customer clicks the button to place
their order. I don't want to track the order every time a customer
views this page so my idea was to try to hook into the onclick event
of the submit button to send the data to GA.

When the user clicks the button to submit their order I use the GA
code to create a new transaction by passing in an object that I
created on page load. Then I loop through an array of items that are
in the shopping cart which I also created on page load and call the
_addItem function for each item. Once it finishes I call the
_trackTrans function and submit the form.

After a full day of gathering data this way I am showing all of the
orders that came through and the amounts on each order but the
individual item data is not show up in my report, it still says "There
is no data for this view".

I know I'm not using the code exactly how Google recommends but it
seems like it should work, and it does to an extent but I would really
love to be able to track this information.

Any help would be very much appreciated!!!

Also, here is the exact code I am using on my site.

<script type="text/javascript">
function TrackOrderAndSubmit()
{
try
{
pageTracker._addTrans(
orderInfo.OrderId, // Order ID
orderInfo.Affiliation, // Affiliation
orderInfo.Total, // Total
orderInfo.Tax, // Tax
orderInfo.Shipping, // Shipping
orderInfo.City, // City
orderInfo.State, // State
orderInfo.Country // Country
);

for (i = 0; i < itemsInCart.length; i++)
{
var itemToTrack = itemsInCart[i];

pageTracker._addItem(
orderInfo.OrderId, // Order ID
itemToTrack.ItemNumber, // SKU
itemToTrack.ItemName, // Product Name
itemToTrack.Category, // Category
itemToTrack.Price, // Price
itemToTrack.Quantity // Quantity
);
}

pageTracker._trackTrans();
}
catch (err) { }

document.ShoppingCart.submit();
}
</script>

nbirkes

unread,
Nov 5, 2009, 10:47:29 AM11/5/09
to google-analytics-api - GA Data Export API
I think the problem is that the _addItem function is running
asynchronously and doesn't have time to do what it needs to do before
the form is submitted.

Is this correct? If so how should I work around this? Is there a
callback I can hook into to submit the form?

nbirkes

unread,
Nov 5, 2009, 1:42:10 PM11/5/09
to google-analytics-api - GA Data Export API
I still haven't solved my problem. Any input is welcome!

Nick

unread,
Nov 5, 2009, 2:28:27 PM11/5/09
to google-analytics-api - GA Data Export API
Probably because this group's purpose is to help around the Google
Analytics Data Export API?

You can get help for implementation questions in our general user
group: http://www.google.com/support/forum/p/Google+Analytics

Yes each item and transaction is sent in a separate request, all are
asynchronous. I think the problem is the transaction is not fully sent
before the page unloads. You should test you can properly send data by
running your function from an event that doesn't change the page url.
If that works, then this article can help you get it working on the
form submit: http://www.gwotricks.com/test/2009/07/tracking-outbound-links-right-way.html

-Nick

nbirkes

unread,
Nov 6, 2009, 10:17:48 AM11/6/09
to google-analytics-api - GA Data Export API
Apologies, Nick! Thanks for your help I will look in that!

On Nov 5, 1:28 pm, Nick wrote:
> Probably because this group's purpose is to help around the Google
> Analytics Data Export API?
>
> You can get help for implementation questions in our general user
> group:http://www.google.com/support/forum/p/Google+Analytics
>
> Yes each item and transaction is sent in a separate request, all are
> asynchronous. I think the problem is the transaction is not fully sent
> before the page unloads. You should test you can properly send data by
> running your function from an event that doesn't change the page url.
> If that works, then this article can help you get it working on the
> form submit:http://www.gwotricks.com/test/2009/07/tracking-outbound-links-right-w...
Reply all
Reply to author
Forward
0 new messages