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!

Recommended Answers

All 2 Replies

Update:

I have added this to our Ajax call parameters for older IE browsers that have caching annoyances with Ajax calls:

cache: false

This seems to have closed the gap a little bit, but there is still something wrong as our conversions in GA does not match our actual conversions.

Anybody have any insights?

Just a quick question, does your tracker count "refresh" page as well? Also, does it prevent web crawlers too? I'm not sure that the page your Ajax sent back is a valid web page to be called by a simple request for the page...

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.