I have a search form throughout my website which submits to a results page (via POST)
In order to track what people are searching for, I've added a line of event tracking code like so to the submit()
event:
$("#search").submit(function(){
var query = $('#search input[type="text"]').val().toLowerCase();
_gaq.push(['_trackEvent', 'search', 'submit', query]);
});
At first, I tried used preventDefault and then called form submit() after the analytics call but this was slow, I presume because it was waiting to hear back from that request.
The above seems to be working but is there a chance that some requests won't be recorded because the form will submit (off to my results page) before the that push request is done?