微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

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

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

Flurry Analytics vs Google Analytics on the mobile platform

但这些都是针对特定平台/手机制造商的解决方案,但jquery移动设备适用于所有平台,无论制造商或操作系统如何.基本上我正在寻找一个针对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);
    })();

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

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

原文地址:https://www.jb51.cc/jquery/178095.html

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐