我已经试了好几个小时,想在Cordova 5.1应用程序上使用这个插件。
https://github.com/danwilson/google-analytics-plugin
根据简单的说明,我应该能够跟踪我的应用程序中的页面浏览和事件,但是我在我的Google Analytics帐户中看不到任何活动。
像建议的那样,我创建了一个APP帐户。我进入实时检查,但没有成功。这是我的一点代码:
onDeviceReady: function() {
navigator.splashscreen.hide();
if (typeof window.analytics !== 'undefined'){
console.log("We got Analytics");
window.analytics.startTrackerWithId('UA-67560028-3', function(){
console.log("Started OK");
window.analytics.trackView('Home');
});
}
else
{
console.log("Google Analytics plugin could not be loaded.")
}
}
当我构建应用并将其安装在我的设备上时,我可以从Dalvik控制台中看到"Habemus analyticsss"。当我运行"cordova plugin list"时,我可以看到插件已经成功安装:
cordova-plugin-google-analytics 0.8.0 "Google Universal Analytics Plugin"
任何帮助都将不胜感激,非常感谢!顺便说一下,这是我的清单文件:
<?xml version='1.0' encoding='utf-8'?>
<manifest android:hardwareAccelerated="true" android:versionCode="10000" android:versionName="1.0.0" package="com.labrtve.trazosurbanos" xmlns:android="http://schemas.android.com/apk/res/android">
<supports-screens android:anyDensity="true" android:largeScreens="true" android:normalScreens="true" android:resizeable="true" android:smallScreens="true" android:xlargeScreens="true" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
<application android:hardwareAccelerated="true" android:icon="@drawable/icon" android:label="@string/app_name" android:supportsRtl="true">
<activity android:configChanges="orientation|keyboardHidden|keyboard|screenSize|locale" android:label="@string/activity_name" android:launchMode="singleTop" android:name="MainActivity" android:screenOrientation="portrait" android:theme="@android:style/Theme.Black.NoTitleBar" android:windowSoftInputMode="adjustResize">
<intent-filter android:label="@string/launcher_name">
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<meta-data android:name="com.google.android.gms.version" android:value="@integer/google_play_services_version" />
</application>
<uses-sdk android:minSdkVersion="10" android:targetSdkVersion="16" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.VIBRATE" />
</manifest>