Anyone have any thoughts on why this is working as an onclick event in Android, but not iOS? I’m using Cordova 1.8.1, jQueryMobile 1.1.1, and jQuery 1.7 if that helps.
In onDeviceReady:
var googleAnalytics = window.plugins.googleAnalyticsPlugin;
googleAnalytics.startTrackerWithAccountID("UA-MyCode");
googleAnalytics.trackPageview('/MobileiOS');
which is working and I see in Analytics.
After <body onload="onLoad()"> I have a button that navigates correctly to a page and also has onclick="googleAnalytics.trackPageview('/TestMobileiOS');"
Nothing in Analytics.
In onLoad:
function onLoad(){
document.addEventListener("deviceready", onDeviceReady, false);
}
It’s a scoping issue I think. Your declaration of the “var googleAnalytics” in the onDeviceReady is limited in scope to that function.
However, later on you try and use it within a different scope. Try using the full window.plugins.googleAnalyticsPlugin.trackPageview…. in your click handler.