I have an html5 mobile application where everything exists on one page, and I use history.back / popstate / etc to change the contents of the page (via jQuery Mobile). I use Google Analytics to track various events, and on one page I track if a user exits through a specific button:
$('#my-back-button').bind('tap', function() { _gaq.push(['_trackEvent', 'mycategory', 'myaction']); history.back(); return false; });
In the android 2.2 browser, history.back () is called, but onpopstate does not start and the page does not change. If I put window.onpopstate = function() { alert("!"); }; window.onpopstate = function() { alert("!"); }; Just before history.back (), I do not see a warning.
If I format two lines first (history.back () and then _gaq.push), this seems to work, but I cannot rely on this order in all my code.
No exceptions are thrown. It works great on iOS and desktop Chrome.
Any ideas why history.back () doesn't work after calling Google Analytics?
Durhamg
source share