如何使用 Jquery mobile 进行移动分析 [英] How to do mobile analytics using Jquery mobile

查看:27
本文介绍了如何使用 Jquery mobile 进行移动分析的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I am looking for a good solution to do mobile analytics for Jquery mobile . I did check this question

移动平台上的 Flurry Analytics 对比 Google Analytics

但这些都是针对特定平台/特定于手机制造商的解决方案,但 jquery mobile 适用于所有平台,而不管制造商或操作系统如何.本质上,我正在为 webapps 寻找分析解决方案.

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.

附加信息:-Bango 似乎很贵,每月 49 美元.Admob 不起作用,因为我们不需要它来做广告而不是放置广告.

Additional Info:- bango seems expensive at $49/month. Admob wont work since we dont need it for advertising and not for placing ads.

推荐答案

我正在使用以下内容:

<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' 事件即使在第一页上也会触发,所以不要认为您想在 GA 设置中包含 _trackPageview.此外,location.hash 将返回带有#"字符的 url,因此 hash.subtr(1) 会清除它,这将使 hash/pushstate 访问者正常化.

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.

2011 年 11 月 30 日更新:添加了对 ie 错误的哈希长度检查(来自:Paulo Manuel Santos).

Update 11/30/11: Added check for hash length for ie bug (from: Paulo Manuel Santos).

这篇关于如何使用 Jquery mobile 进行移动分析的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆