Plugin working on iOS but not on Android
Hello there,
I have installed this plugin with ionic and ngCordova. Everything all good. Running the app on iOS everything is working fine. But running the exact same code on Android the tracking events are not showing up in Google Analytics.
Does someone have the same issue? Do I have to activate something at Google to use Analytics on an Android device? What am I doing wrong here?
Some code:
app.js
$ionicPlatform.ready(function() {
$cordovaGoogleAnalytics.debugMode();
$cordovaGoogleAnalytics.startTrackerWithId('UA-XXX-X');
});
controller.js
$ionicPlatform.ready(function() {
$cordovaGoogleAnalytics.trackView('Home Screen');
});
This is working with iOS devices but not with Android devices.
Also if I just put the raw analytics code in the index.html file a view is succesfully tracked and shows up on Analytics. But this is not the right way.
Hi there, We are facing this problem as well! Who knows some solution? Thank you!
For both of you please try to use the ver 1.6.0 of GA because ngCordova api haven't been updated with the last api changes done in GA plugin.
Also please don't try to call debugmode() before startTrackerWithId() because startTrackerWithId create the java instance that is use on every other method.
please check https://github.com/driftyco/ng-cordova/issues/1421
I have used 1.6.0 version and tried with 1.7.5, but still not working
Also need to roll down to 1.6.0, remove the tilde to use exact version in config.xml:
<plugin name="cordova-plugin-google-analytics" spec="1.6.0" />
I need just add this string (plugin name="cordova-plugin-google-analytics" spec="1.6.0) to config.xml?
@vgaemagapp With the cordova cli commands for both platform and plugin you can append --save to add them to the config.xml file. Then you dont need to keep plugin and platforms folder in your git-repo. You restore them with cordova prepare. So to change the version of this plugin you just update the version in config.xml, delete platforms and plugins folder and restore to get the right version.
Thanks ! This help!
On Mon, Apr 3, 2017 at 8:07 PM, Gerhard Sletten [email protected] wrote:
@vgaemagapp https://github.com/vgaemagapp With the cordova cli commands for both platform and plugin you can append --save to add them to the config.xml file. Then you dont need to keep plugin and platforms folder in your git-repo. You restore them with cordova prepare. So to change the version of this plugin you just update the version in config.xml, delete platforms and plugins folder and restore to get the right version.
Cordova cli reference https://cordova.apache.org/docs/en/latest/reference/cordova-cli/index.html#cordova-plugin-command
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/danwilson/google-analytics-plugin/issues/388#issuecomment-291207795, or mute the thread https://github.com/notifications/unsubscribe-auth/AZks8y2103g40HLIdXWnBnoMLclg2Z7iks5rsSc0gaJpZM4MuHPs .
It means just that, analytics has not been defined. The reason that your if statements aren't catching it is because typeof undefined returns the string "undefined" not the primitive undefined, so you should do:
.run(function($ionicPlatform, $ionicPopup) { $ionicPlatform.ready(function() { if(typeof analytics !== 'undefined') { analytics.startTrackerWithId("UA-xxxx"); } else { console.log("Google Analytics Unavailable"); } }); });