Google Analytics not tracking e-commerce on crossdomain implementation
Here's our setup:
1) Primary site contains an e-commerce solution that uses GA to track everything and is doing it as required. The tracking code on every page is as follows:
var pageTracker = _gat._getTracker("account id");
pageTracker._setDomainName("primary domain");
pageTracker._setAllowLinker(true);
pageTracker._setAllowHash(false);
pageTracker._trackPa开发者_如何学Gogeview();
The primary site also opens a service from a secondary domain directory A. We use pageTracker._getLinkerUrl() to get all the proper GA information added to the url before opening the utility.
2) The utility running on secondary domain directory A uses GA tracking code as recommended by Google:
var pageTracker = _gat._getTracker("account id");
pageTracker._setDomainName('none');
pageTracker._setAllowLinker(true);
pageTracker._setAllowHash(false);
pageTracker._trackPageview();
The secondary service uses GA Events to record various stuff happening there to the primary sites GA account and it all works quite well.
Now's where things started going wrong:
- We set up a split test at secondary domain directory B.
- We also have a server side code in place that redirects around 50% of users to directory B when they open directory A. The google tracking code at directory B is identical to the one in A. All the GA events thrown from directory B however have a identifying prefix so we can later analyze Split version users behavior.
The result of this was that while GA recorded all events, the e-commerce statistics went haywire as the directory B segment recorded ZERO e-commerce transactions, while the average dropped around 50% and directory A segment continued at regular conversion rate levels.
What we're currently thinking of redoing the split framework to have the primary domains app to know the split test url we're sending the user and not fiddling with server side redirects. We hope that this will fix the issue for now.
But question is - is it possible to somehow get Google Analytics to properly work here to associate with e-commerce data without getting rid of the server side split framework?
As we didn't have a clear cause for the problem, we solved this by doing the split URL preparation in clientside with retrieving the split URL with AJAX from the app managing the test balancing, so that javascript that opens the secondary domain (and runs the GA code) gets the processed final target url and the page won't get redirected. Sofar analytics is showing results from both, primary and split versions and is recording events properly, so it worked.
When testing we discovered that the referring url got lost somewehere along the way (possibly due to our redirection code), but as the e-commerce tracking also failed to track properly when using Google Web Optimizer, then this might be an issue there aswell, when dealing with split tests run over multiple domains.
精彩评论