If you have your cart built up in javascript then just follow Google’s documentation. If you submit your Google Wallet cart server-side using the java SDK and want to track the sale using Google Analytics’ ecommerce feature, then this blog is for you…
Before you start, make sure you have enabled the ecommerce feature in Google Analytics.
In your Java code, you need to set the analyticsData (String) in the cart:
merchantflowSupport.setAnalyticsData(analyticsData);
To get that analyticsData string, I pass it to my server with a query param using a bit of javascript:
$("#google-purchase-link").click(function(e){
_gaq.push(function() {
var pageTracker = _gaq._getAsyncTracker();
setUrchinInputCode(pageTracker);
console.log(getUrchinFieldValue());
window.location = "/purchase/google?analyticsData=" + getUrchinFieldValue();
});
e.preventDefault();
});
I use the async version of Google Analytics, jQuery, and Jersey so I’ve skipped that stuff because that’s not important and you probably do it differently. If you use the old ga.js and GWT, then this blog post may help you better.
If you get stuck, I use this solution for OddPrints.com which is open-source so that should fill any gaps.