The problem:
Our "thankyou" page (goal page) is not recording all of our conversions. For instance, our analytics account is showing 19 conversions for yesterday, but we actually had 34 conversions.
The situation and the Code:
Our thankyou page is being called dynamically from the checkout page through a jquery/ajax call when the user clicks "complete order". The script sends the form data via an ajax post. A successful response returns the html for the thankyou page, which contains a summary of the customers order along with the conversion code. The conversion code is run through a jquery function, $.globalEval(), to execute the scripts in the response, like so:
$.ajax({type:'POST', url: '/path/to/php/script',
data:$('#checkout_form').serialize(),
success: function(response) {
var dom = $(response);
dom.filter('script').each(function(){
// execute every javascript snippet (our conversion code)
$.globalEval(this.text || this.textContent || this.innerHTML || '');
});
// load the thankyou html...
}
}).fail(function(jqXHR, textStatus) {
// handle fail...
});
In the ajax response, we have our GA code which is recording a virtual pageview, recording some ecommerce data, and also recording Adwords statistics. Our virtual pageview code included in the response is as follows:
_gaq.push(['_trackPageview', '/thankyou']);
The Confusion:
For whatever reason, our conversion is only recording SOME of the time. It is a bit puzzling, and we have done alot of testing and prodding to no avail. I am trying to avoid separating the thankyou page as a completely different pageload, because we have alot of different ajax style features we plan on implementing, but not if we cannot accurately record pageviews and track goals.
Notes:
We have our main GA tracking code in the header of our checkout page. We are using the newer style, non-blocking, GA tracking code.
The Question(s):
Does anyone have experience in trying to implement something similar to this where you are performing an ajax call to the goal page, and performing a virtual pageview? Why does our conversion record only SOME of the time? Is GA filtering our conversions and if so, why? Is it possible that this problem has nothing to do with ajax, but rather with using virtual pageviews for our sales funnel?
Any help would be much appreciated, and if you need any further information please ask. Thanks!