Avoiding race conditions in Google Analytics asynchronous tracking
问题 I am having issues with many of my events (maybe 20%) not getting recorded in Google Analytics. These are all events called with onclick on an image button that posts a form. I believe that the code isn't running fast enough to submit the events to Google before the browser moves on to the next page. What I would like to do is check the state of _gaq's queue and make sure there are no pending events before completing my Javascript. _gaq seems a little cryptic to me, but it does have an