I am using phonegap 3.3 to build android app locally and trying to use the GA plugin
I have installed the GAplugin using
phonegap local plugin add https://github.com/phonegap-build/GAPlugin.git
Added this code in my index.
var gaPlugin;
document.addEventListener("deviceready", onDeviceReady, false);
function onDeviceReady() {
alert("calling ga");
gaPlugin = window.plugins.gaPlugin;
alert("calling init")
gaPlugin.init(successHandler, errorHandler, "UA-48220634-1", 1);
gaPlugin.trackPage( nativePluginResultHandler, nativePluginErrorHandler, "index.html");
gaPlugin.trackEvent( nativePluginResultHandler, nativePluginErrorHandler, "Button", "Click", "event only", 1);
gaPlugin.exit(nativePluginResultHandler, nativePluginErrorHandler);
}
function successHandler()
{
alert("init success");
}
function errorHandler()
{
alert("init failed");
}
function nativePluginResultHandler()
{
alert("tracking success");
}
function nativePluginErrorHandler()
{
alert("tracking failed");
}
I get all successful messages but cant see anything in Google Analytics.
I also tried manually including the GAPlugin.js but no change.
I can see GAPlugin in list of plugins
Anujs-MacBook-Pro:my-app edunewz$ phonegap plugin list
[phonegap] com.adobe.plugins.GAPlugin
[phonegap] com.jamiestarke.webviewdebug
[phonegap] org.apache.cordova.camera
[phonegap] org.apache.cordova.file
[phonegap] org.apache.cordova.file-transfer
[phonegap] org.apache.cordova.inappbrowser
Can anybody help me out.
Go into /platforms/android/AndroidManifest.xml and make sure
are present.
Execute:
I also added:
to config.xml.
Make sure you copy + paste GAPlugin.js from /plugins/com.adobe.plugins.GAPlugin/www into your /www folder.
The code posted below comes from: https://github.com/shanabus/phonegapbuildtest/blob/master/Index.html
Most of it is just extra, as he shows working feedback in the actual app.
Make sure you're using Mobile App Analytics, and not web analytics like he is in the above code snippet.
Observe how he is tracking these events (I learned a lot from this): https://github.com/shanabus/phonegapbuildtest/search?q=gaPlugin.trackEvent
Use the plugin's example for how to accomplish VariableButtonClicked, PageButtonClicked, TrackButtonClicked. https://github.com/bobeast/GAPlugin/blob/master/Example/index.html The example code never worked out of the box for me, so just use it as a reference.
Check under https://www.google.com/analytics/web/?hl=en#realtime/ and pray. Sometimes it takes a long time before showing, so give it a day before you start troubleshooting. The rest of analytics data is like 24 hours behind, so select the current day if you want to see data 1-5 hours after.. sometimes longer.
Some people might say these extra steps are overkill, and they would be right.. but I had to do some combination of all of them before it worked for me. Strangely enough I feel like I'm leaving something out. Good luck!
in My Case it was network information plugin missing :