PhoneGap 应用程序的最佳分析?

发布于 2024-12-23 15:50:53 字数 189 浏览 1 评论 0原文

在phonegap应用程序中跟踪用户操作的最佳方法是什么?我正在使用 PhoneGap Build 构建纯 JS/CSS/HTML Sencha Touch 应用程序,因此我无法访问其他任何内容。 Google Analytics 仅适用于连接活动,而且我相信我的应用程序的大部分使用都发生在网络之外。

有哪些解决方案?我愿意为值得使用的东西付费。

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. Google Analytics would only work for connected-activity, and I'm confident that much of my app use happens off the network.

What solutions are out there? I'd be willing to pay for something worth using.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

思慕 2024-12-30 15:50:53

由于接受的答案无效,因为该插件不再存在,我只想提及我为此目的检查的插件。实际上有 3 个(加上测试版中的一些):

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

艰难的选择..我一直在单独测试它们,它们似乎都可以完成工作,所以这可能只是一个基于您喜欢它们的使用方式的偏好问题。

他们都没有提到有关在设备离线时对事件进行排队以及在网络可用时调度它们的任何内容,但 GAPlugin 有一个队列,可以根据您在初始化期间设置的频率进行调度,因此也许它可以解决离线问题。

如果有人对此有任何了解,非常欢迎评论。一旦我有时间,我会尝试在设备上测试它们,因为 iOS 模拟器似乎不允许我关闭 wifi...

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):

  1. https://github.com/phonegap-build/GAPlugin
  2. https://github.com/danwilson/google-analytics-plugin
  3. 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.

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...

各空 2024-12-30 15:50:53

您可以编写自己的 PhoneGap 插件(基本上是 JavaScript 到 Native 代码的桥梁)。这将使您可以自由地使用任何当前具有离线支持的本机解决方案(Webtrends、GA、Flurry 等)。

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

您必须为每个您想要支持的平台创建一个 JavaScript 文件和一个 Native 文件。在您的本机代码中,您将调用跟踪供应商的 SDK。

我使用了Android示例,只是将这个示例放在一起作为示例。请注意,这根本没有经过测试,甚至没有放入 IDE 中。我只是在记事本++中编辑了提供的示例:-)

//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

/**
 * @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());
});

You can write your own PhoneGap plug-ins (basically a JavaScript to Native code bridge). This would give you the freedom to use any of the current native solutions out there which do have offline support (Webtrends, GA, Flurry, ...).

See : 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. In your Native code you would do a call to your tracking vendor's SDK.

I used the Android example and just put this example together as a sample. Please be advised this wasn't tested at all or even put into an IDE. I simply edited the provided examples in notepad++ :-)

//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

/**
 * @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());
});
爱的十字路口 2024-12-30 15:50:53

注意:对于较新版本的 PhoneGap,此信息似乎已过时。请谨慎行事。

PhoneGap 已发布半官方 Google Analytics 插件,用于利用适用于 iOS 和 Android 的官方 Google Analytics SDK;对于其他平台,您可以依赖 JavaScript。

这是有关它的博客文章。

您可以在此 存储库

以下是以下文件夹:

Note: This information appears to be out of date for newer versions of PhoneGap. Proceed with caution.

PhoneGap has released a semi-official Google Analytics plugin for utilizing the official Google Analytics SDKs for iOS and Android; for other platforms, you can rely on JavaScript.

Here's the blog post about it.

You can find it in this repository.

Here are the folders for:

瞳孔里扚悲伤 2024-12-30 15:50:53

当你谈论离线分析时,一切都变得非常棘手。我突然想到两件事……第一件事是,我不确定你的应用程序是适用于 iOS 还是 Android,但苹果已经拒绝了应用程序,因为“应用程序”只不过是移动网站的包装。这更与这些应用程序没有利用任何核心设备功能(没有本机代码)这一事实有关。

其次,我意识到您提到您想远离本机代码,但看看 GA Mobile SDK。您会发现 GA 实际上有一种在设备离线时跟踪和保存分析的方法。当应用程序具有网络连接时,分析结果将发送到 GA 服务器。这对您来说是一种权衡,使用一些本机代码但可以节省时间,因为您不必推出自己的解决方案。干杯!

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

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. 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. You'll see that GA actually has a method of tracking and saving analytics while a device is offline. When the app has network connectivity, the analytics are then sent to the GA server. 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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文