如何使用Jquery mobile进行移动分析 [英] How to do mobile analytics using Jquery mobile
问题描述
我正在寻找一个很好的解决方案来为Jquery mobile进行移动分析。我确实检查过这个问题。
但这些都是针对特定平台/手机制造商的特定解决方案,但jQuery Mobile无论制造商还是操作系统,都可以在所有平台上运行。基本上,我正在寻找一个针对webapps的分析解决方案。
附加信息: -
bango看起来很贵,每月$ 49。 Admob不会工作,因为我们不需要广告,也不需要放置广告。
< script>
var _gaq = _gaq || [];
_gaq.push(['_ setAccount','UA-xxxxxx-xx']);
(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);
})();
$ b $('[data-role = page]')。live('pageshow',function(event,ui){
try {
hash = location.hash;
if(hash& hash.length> 1){
_gaq.push(['_ trackPageview',hash.substr(1)]);
} else {
_gaq.push(['_ trackPageview']);
}
} catch(err){
}
});
< / script>
即使是第一页,'pageshow'事件也会触发,所以不要认为您想包含带有GA设置的_trackPageview。此外,location.hash会以#字符返回url,所以hash.subtr(1)会清除那个会将hash / pushstate访问者规范化的关闭。
更新11 / 30/11:增加了针对ie bug的哈希长度检查(来自:Paulo Manuel Santos)。
I am looking for a good solution to do mobile analytics for Jquery mobile . I did check this question
Flurry Analytics vs Google Analytics on the mobile platform
but these are all solutions for a platform specific/ phone manufacturer specific but jquery mobile works on all platforms irrespective of the manufacturer or operating system. Essentially i am looking for a analytics solution for webapps.
Additional Info:- bango seems expensive at $49/month. Admob wont work since we dont need it for advertising and not for placing ads.
I'm using the following:
<script>
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-xxxxxx-xx']);
(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);
})();
$('[data-role=page]').live('pageshow', function (event, ui) {
try {
hash = location.hash;
if (hash && hash.length > 1) {
_gaq.push(['_trackPageview', hash.substr(1)]);
} else {
_gaq.push(['_trackPageview']);
}
} catch(err) {
}
});
</script>
The 'pageshow' event fires even for the first page, so don't think you want to include the _trackPageview with the GA setup. Also, location.hash will return url with the "#" character so hash.subtr(1) cleans that off which will normalize hash/pushstate visitors.
Update 11/30/11: Added check for hash length for ie bug (from: Paulo Manuel Santos).
这篇关于如何使用Jquery mobile进行移动分析的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!