jQueryMobile loads its first page as every site does. The usual Google Analytics integration works - the request ist tracked. But following pages are loaded asynchronously and user clicks are not tracked.
How to integrate Google Analytics into a jQueryMobile website, so that all page clicks are tracked?
The team announced that the cross-platform jQuery Mobile project under its umbrella is fully deprecated as of October 7, 2021.
Go to google.com/analytics. To create an account, click Get started today. If you already have a Google Analytics account, click Sign in to Analytics. Set up Analytics on your website and/or app.
Jon Gales has written a great article on this.
http://www.jongales.com/blog/2011/01/10/google-analytics-and-jquery-mobile/
Here's the code he recommends using:
$('[data-role=page]').live('pageshow', function (event, ui) {
try {
_gaq.push(['_setAccount', 'YOUR_GA_ID']);
hash = location.hash;
if (hash) {
_gaq.push(['_trackPageview', hash.substr(1)]);
} else {
_gaq.push(['_trackPageview']);
}
} catch(err) {
}
});
Update
Since live
is now deprecated you should use the on
event instead, if you´re using jQuery 1.7+. http://api.jquery.com/on/
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With