Best analytics for PhoneGap app?

What is the best way to track user activity in phonegap app? I use PhoneGap Build to create a clean Sencha Touch JS / CSS / HTML application, so I don't have access to anything else. Google Analytics will only work on connected activity, and I’m sure that most of my use of applications is disconnected from the network.

What solutions exist? I am willing to pay for what is worth using.

+6
source share
4 answers

Since the accepted answer is invalid, as this plugin no longer exists, I just wanted to mention the plugins that I checked for this purpose. There are actually 3 (plus some more beta):

Hard choices ... I tested them separately, and they all seem to do the job, so it's probably just a matter of preference based on a lot of how you like how they are used.

None of them mention anything in the queue when the device is offline and sends them as soon as the network is available, but GAPlugin has a queue that is sent based on the frequency that you can set during initialization, so maybe It can work around an autonomous problem.

If anyone knows about this, comments are very welcome. I will try to test them on the device as soon as I get some time, because the iOS simulator does not seem to allow Wi-Fi to be disabled ...

+1
source

You can write your own PhoneGap plugins (mostly JavaScript for the Native code bridge). This would give you the freedom to use any current native solutions that have autonomous support (Webtrends, GA, Flurry, ...).

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

You will need to create one JavaScript file and one Native file per platform that you would like to support. In your own code, you must call your tracking provider SDK.

I used the Android example and simply combined this example as a sample. Please keep in mind that this has not been tested at all or even placed in the IDE. I just edited the above 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()); }); 
+1
source

Note. This information is outdated for later versions of PhoneGap. Use caution.

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

Here is a blog post about it.

You can find it in this repository .

Here are the folders for:

+1
source

It gets so complicated when you talk about offline analytics. Two things pop up at me. First, and I'm not sure if your application is for iOS or Android, but Apple rejected the application because the “application” was just a wrapper around the mobile site. This is more due to the fact that these applications did not use any functionality of the main device (there is no native code).

Secondly, I understand that you mentioned that you want to stay away from your own code, but look at the GA Mobile SDK. You will see that GA has a method for tracking and saving analytics when the device is offline. When the application has a network connection, analytics is then sent to the GA server. This will be a compromise for you, use a small native code, but save time because you do not need to download your solution. Hurrah!

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

-1
source

Source: https://habr.com/ru/post/904712/


All Articles