1

I am making an app in android and I want to get analytics from the users. I tried to use the Phonegap Plugin, but I didn't have any luck trying to implement it.

I was wondering if it was possible to get Google Analytics by treating the app like a normal webpage and putting some javascript in the head of my page.

1 Answers1

2

I was struggeling with that GAplugin recently. So this is what I did:

1: if you're using phonegap build just place this in your config.xml:

<gap:plugin name="com.adobe.plugins.gaplugin" />

2: on the google analytics page create a new mobile app.

3: place the plugin in your index.html

 <script src="GAPlugin.js"></script>

4: place the following code in your onDeviceReady function.

gaPlugin = window.plugins.gaPlugin;
gaPlugin.init(successHandler, errorHandler, "UA-12345678-1", 10);

5: track a page like this:

gaPlugin.trackPage( nativePluginResultHandler, nativePluginErrorHandler,     "some.url.com");

more information can be found here: https://github.com/phonegap-build/GAPlugin/blob/master/README.md

Pete
  • 519
  • 1
  • 5
  • 10