google-analytics-plugin: trackView rejects with throwing an error
I am using this plugin with ionic. (latest version of everything)
I have this code: start tracking -> track view “test”
GoogleAnalytics.startTrackerWithId(config.googleAnalytics).then(
res => {
console.log("startTrackerWithId res", res);
GoogleAnalytics.trackView("test").then(
res => console.log("trackView res", res),
error => console.log("trackView error", error),
);
},
error => console.log("startTrackerWithId error", error)
);
And the console output is:
trackView error Error: send timeout
at http://localhost:8000/plugins/cordova-plugin-google-analytics/browser/UniversalAnalyticsProxy.js:170:13
at t.invokeTask (http://localhost:8000/build/polyfills.js:3:9723)
at Object.onInvokeTask (http://localhost:8000/build/main.js:40846:37)
at t.invokeTask (http://localhost:8000/build/polyfills.js:3:9659)
at e.runTask (http://localhost:8000/build/polyfills.js:3:7083)
at invoke (http://localhost:8000/build/polyfills.js:3:10836)
at e.args.(anonymous function) (http://localhost:8000/build/polyfills.js:2:30123)
Am I doing something wrong?
About this issue
- Original URL
- State: closed
- Created 7 years ago
- Comments: 26 (5 by maintainers)
I ran into the same thing. It’s a documentation problem. There’s no note to tell you that you need to have the GA code in your index.html as well! You would think installation of a plugin would handle everything for you, but it doesn’t. You still need code in your index.html. Copy it from the GA dashboard and paste it in.
@martyzz1 it returns a promise on ionic2: https://ionicframework.com/docs/v2/native/google-analytics/