简体   繁体   English

PhoneGap应用程序的最佳分析?

[英]Best analytics for a PhoneGap application?

What's the best way to track user actions in a phonegap app? 什么是跟踪手机应用中的用户操作的最佳方式? I'm using PhoneGap Build to build a pure JS/CSS/HTML Sencha Touch application, so I have access to nothing else. 我正在使用PhoneGap Build来构建纯JS / CSS / HTML Sencha Touch应用程序,因此我无需访问任何其他内容。 Google Analytics would only work for connected-activity, and I'm confident that much of my app use happens off the network. Google Analytics仅适用于互联活动,我相信我的大部分应用都是通过网络进行的。

What solutions are out there? 有什么解决方案? I'd be willing to pay for something worth using. 我愿意付出值得使用的东西。

Since the accepted answer is invalid as that plugin doesn't exist anymore, I just wanted to mention the plugins I checked for this purpose. 由于接受的答案无效,因为该插件不再存在,我只是想提一下我为此目的检查的插件。 There are actually 3 (plus a few more in beta): 实际上有3个(加上一些测试版):

  1. https://github.com/phonegap-build/GAPlugin https://github.com/phonegap-build/GAPlugin
  2. https://github.com/danwilson/google-analytics-plugin https://github.com/danwilson/google-analytics-plugin
  3. https://github.com/cmackay/google-analytics-plugin https://github.com/cmackay/google-analytics-plugin

Tough choice... I have been testing them separately and they all seem to do the job, so probably it's just a matter of preference based pretty much on how you like the way they are used. 艰难的选择......我一直在单独测试它们并且它们似乎都在完成这项工作,所以可能只是基于您喜欢它们的使用方式的偏好问题。

None of them mention anything regarding queuing events while the device is offline and dispatching them once the network is available, but GAPlugin has a queue that gets dispatched based on a frequency you can set during initialization, so maybe it can work around the offline problem. 当设备处于脱机状态时,他们都没有提及有关排队事件的任何内容,并且一旦网络可用就调度它们,但是GAPlugin有一个队列可以根据您在初始化期间设置的频率进行调度,因此它可以解决脱机问题。

If anybody knows anything regarding this, comments are very welcome. 如果有人对此有所了解,非常欢迎评论。 I will try to test them on device once I get some time, cause the iOS simulator doesn't seem to allow me to turn off the wifi... 一旦我有时间,我会尝试在设备上测试它们,因为iOS模拟器似乎不允许我关闭wifi ...

You can write your own PhoneGap plug-ins (basically a JavaScript to Native code bridge). 您可以编写自己的PhoneGap插件(基本上是JavaScript到Native代码桥)。 This would give you the freedom to use any of the current native solutions out there which do have offline support (Webtrends, GA, Flurry, ...). 这将使您可以自由使用任何具有离线支持的当前原生解决方案(Webtrends,GA,Flurry,...)。

See : http://wiki.phonegap.com/w/page/36752779/PhoneGap%20Plugins 请参阅: http//wiki.phonegap.com/w/page/36752779/PhoneGap%20Plugins

You would have to create one JavaScript file and one Native file per platform you wanted to support. 您必须为每个要支持的平台创建一个JavaScript文件和一个Native文件。 In your Native code you would do a call to your tracking vendor's SDK. 在您的本机代码中,您将调用跟踪供应商的SDK。

I used the Android example and just put this example together as a sample. 我使用了Android示例,并将此示例放在一起作为示例。 Please be advised this wasn't tested at all or even put into an IDE. 请注意,这根本没有经过测试,甚至没有进入IDE。 I simply edited the provided examples in notepad++ :-) 我只是在记事本++中编辑了提供的示例:-)

//Java // Java的

public class TrackingPlugin extends Plugin {
    public static final String ACTION="pageView";
    @Override
    public PluginResult execute(String action, JSONArray data, String callbackId) {
        Log.d("Tracking", "Plugin Called");
        PluginResult result = null;
        if (ACTION.equals(action)) {
            try {
                String pageTitle= data.getString(0);
                JSONObject res = new JSONObject();

                SOME_TRACKING_API.Track(pageTitle);

                res.put("status","OK");
                result = new PluginResult(Status.OK, res);
            } catch (JSONException jsonEx) {
                Log.d("DirectoryListPlugin", "Got JSON Exception "+ jsonEx.getMessage());
                result = new PluginResult(Status.JSON_EXCEPTION);
            }
        } else {
            result = new PluginResult(Status.INVALID_ACTION);
            Log.d("TrackingPlugin", "Invalid action : "+action+" passed");
        }
    return result;
}

//JavaScript // JavaScript的

/**
 * @return Object literal singleton instance of Track
 */
var Track = function() {
};

/**
  * @param pageTitle The title for a new view
  * @param successCallback The callback which will be called when track call is done
  * @param failureCallback The callback which will be called when track call is done
  */
Track.prototype.pageView = function(pageTitle,successCallback, failureCallback) {
 return PhoneGap.exec(    
      successCallback,    //Success callback from the plugin
      failureCallback,    //Error callback from the plugin
      'TrackingPlugin',   //Tell PhoneGap to run "TrackingPlugin" Plugin
      'pageView',         //Tell plugin, which action we want to perform
      [pageTitle]);       //Passing list of args to the plugin
};

PhoneGap.addConstructor(function() {
    PhoneGap.addPlugin("Track", new Track());
});

Note: This information appears to be out of date for newer versions of PhoneGap. 注意:对于较新版本的PhoneGap,此信息似乎已过期。 Proceed with caution. 谨慎行事。

PhoneGap has released a semi-official Google Analytics plugin for utilizing the official Google Analytics SDKs for iOS and Android; PhoneGap发布了一个半官方的谷歌分析插件,用于iOS和Android的官方谷歌分析SDK; for other platforms, you can rely on JavaScript. 对于其他平台,您可以依赖JavaScript。

Here's the blog post about it. 这是关于它的博客文章。

You can find it in this repository . 您可以在此存储库中找到它。

Here are the folders for: 以下是以下文件夹:

It all gets so tricky when you talk about offline analytics. 当你谈论离线分析时,这一切都变得非常棘手。 Two things pop out at me.. The first being, and I'm not sure if your app is for iOS or Android but Apple has rejected apps because the "app" was nothing more than a wrapper around a mobile website. 有两件事突然出现在我面前......第一个是,我不确定你的应用是用于iOS还是Android,但Apple拒绝了应用,因为“app”只不过是一个移动网站的包装。 That is more related to the fact that those apps didn't utilize any core device functionality (no native code). 这与这些应用程序没有使用任何核心设备功能(没有本机代码)的事实更相关。

Second, I realize you mentioned you wanted to stay away from native code but have a look at the GA Mobile SDK. 其次,我意识到你提到你想远离本机代码但是看看GA Mobile SDK。 You'll see that GA actually has a method of tracking and saving analytics while a device is offline. 您会发现GA实际上有一种在设备离线时跟踪和保存分析的方法。 When the app has network connectivity, the analytics are then sent to the GA server. 当应用程序具有网络连接时,分析将被发送到GA服务器。 This would be a trade off for you, use a little native code but save time because you didn't have to roll your own solution. 这将是一个折衷,使用一些本机代码,但节省时间,因为您不必自己推出解决方案。 Cheers! 干杯!

http://code.google.com/apis/analytics/docs/mobile/overview.html http://code.google.com/apis/analytics/docs/mobile/overview.html

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM