mcihak
November 24, 2016, 11:17am
1
Hi all,
I am trying to use GA in my app.
In app inicialization I have this part of code:
GoogleAnalytics.startTrackerWithId(“UA-*****”);
And in every component constructor i have:
this.platform.ready().then(() => {
GoogleAnalytics.trackView(“Title”);
});
After app launch I have console error: main.js:7 EXCEPTION: Uncaught (in promise): Tracker not started
Can you help me with it?
Thanks
Do you have wrapped all your plugins call in platform.ready??
platform.ready().then((readySource) => {
console.log('Platform ready from', readySource);
// Platform now ready, execute any required native code
});
I had that problem too. To solve it you have to handle your google analytics queries in a providers/service.
this.platform.ready().then(() => {
myService.startTracker();
myService.trackView("Title");
}
etc.
I posted my service code, where I also stack the analytics request till the cordova plugin is ready, there (see peterpeterparker)
the exact same code as I posted in the GitHub issue? You have written a service etc.? Maybe could you show some more details of your codes?
mcihak
November 24, 2016, 12:46pm
6
I used the service but some type is red and I don’t know what to do with it :-/
in “trackView()” it is: analytics and than
in “trackEventsNotSent()” it is: Promise and Comparator
in “initGoogleAnalytics()” it is: Promise and catch
you could replace the comparator with following (I edited my solution too):
this.eventsNotSent == null || Object.keys(this.eventsNotSent).length === 0
these are the imports I do (I edited the solution too):
import {Injectable} from '@angular/core';
import {GoogleAnalytics} from 'ionic-native';
import {Observable} from 'rxjs/Observable';
import 'rxjs/add/observable/forkJoin';
mcihak
November 24, 2016, 1:04pm
8
Replaced but others are still red :-/
for window.analytics you could define an empty interface or cast it in < any >
for the Promise and catch honestly I don’t know why it doesn’t work, it’s like a basic class I thought. You don’t have any Promise and catch in your all app?
mcihak
November 24, 2016, 1:38pm
10
Yes I have Promises but with catch I have problems in all app… :-/
strange. maybe remove the catch just for test purpose?
have you seen the last post?
seems it works better with version 1.6.0 of the plugin…if that could help