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
var Track = function() { }; Track.prototype.pageView = function(pageTitle,successCallback, failureCallback) { return PhoneGap.exec( successCallback,
source share