Giter Club home page Giter Club logo

cordova-umeng-analytics's Introduction

cordova-umeng-analytics

Cordova友盟统计插件

功能

目前只有基本的统计分析功能,具体功能参见官方文档。 自动更新功能,请参见友盟更新插件

安装

  1. 运行 cordova plugin add https://github.com/pipitang/cordova-umeng-analytics

  2. cordova各种衍生命令行都应该支持,例如phonegap或者ionic。

使用方法

原则

API

统计分析API

配置API

请务必在cordova ready中调用配置接口

Umeng.Analytics.config({
    appkey: 'your_app_key', 
    channel: 'your_channel'
}, function () {
    alert("友盟API初始化成功");
}, function (reason) {
    alert("友盟API初始化失败");
});

开始记录页面停留

页面统计集成正确,才能够获取正确的页面访问路径、访问深度(PV)的数据。对于Cordova程序来说,这里的页面一般来说是应用程序的某个TOKEN。与一般的页面浏览不同,移动APP需要正确处理被暂停和恢复状态,在Cordova中如何实现,请问度娘或者谷哥。

Umeng.Analytics.startPage('xxxPage', 
function () {
    alert("Success");
}, function (reason) {
    alert("Failed: " + reason);
});

结束记录页面停留

此处传入的参数务必与startPage成对出现,参见

Umeng.Analytics.endPage('xxxPage', function () {
   alert("Success");
}, function (reason) {
   alert("Failed: " + reason);
});

自定义事件 参见

Umeng.Analytics.logEvent({
    eventId: 'pay',
    attributes: {book:'Swfit Fundamentals'},
    num: 110
}, function () {
    alert("Success");
}, function (reason) {
alert("Failed: " + reason);
});

其中,eventId为必传参数,其它参数不传,即为统计该行为发生次数。如果同时传入attributes,则为统计各行为各属性发生的次数。如果eventId, attributes和num同时传入,则为统计"计算事件",请查看官方文档。

打开或关闭调试

Umeng.Analytics.enableDebug(true, function () {
   alert("Success");
}, function (reason) {
   alert("Failed: " + reason);
});

FAQ

Q: Android如何调试?

A: 如果怀疑插件有BUG,请使用tag名称为cordova-umeng-analytics。

Q: Windows 版本?

A: 这个很抱歉,有个哥们买了Lumia之后一直在抱怨应用太少,很不幸,你也有这个需求 :) 欢迎 pull request.

TODO

  1. 动态拉取依赖库
  2. 页面统计自动处理应用暂停和启动

许可证

MIT LICENSE

cordova-umeng-analytics's People

Contributors

aoslee avatar pipitang avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.