如何使用Jquery mobile进行移动分析

我正在寻找一个很好的解决方案来为Jquery移动设备做移动分析。 我确实检查了这个问题

Flurry Analytics与移动平台上的Google Analytics相比

但这些都是针对特定平台/手机制造商的解决方案,但jquery移动设备适用于所有平台,无论制造商或操作系统如何。 基本上我正在寻找一个针对webapps的分析解决方案。

附加信息: – bango似乎很贵,每月49美元。 Admob不会工作,因为我们不需要广告而不是广告。

我正在使用以下内容:

 

“pageshow”事件甚至会针对第一页触发,因此不要认为您希望将_trackPageview包含在GA设置中。 此外,location.hash将返回带有“#”字符的url,因此hash.subtr(1)会清除该关闭,这将标准化哈希/ pushstate访问者。

更新11/30/11:添加了对bug的哈希长度检查(来自:Paulo Manuel Santos)。

我为Google Analytics使用以下代码,效果很好:

以下几乎是正常的Google Analytics设置:

 var _gaq = _gaq || []; _gaq.push(['_setAccount', '**-*****-**']); (function() { var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true; ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js'; var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s); })(); 

jQuery Mobile的更新在这里,以便记录每个伪页面:

 $(document).delegate('[data-role=page]', 'pageshow', function (event, ui) { var url = location.href; try { if (location.hash) { url = location.hash; } _gaq.push(['_trackPageview', url]); } catch(error) { // error catch } });