Problem tracker not started

Hi, I have a problem, but I do not know what’s happening.
Error on console:

ERROR: Unhandled Promise rejection: Tracker not started ; Zone: <root> ; Task: setTimeout ; Value: Tracker not started
ERROR: error JSON.stringify()ing argument: TypeError: JSON.stringify cannot serialize cyclic structures.

global packages:

    @ionic/cli-utils : 1.3.0
    Cordova CLI      : 7.0.1 
    Ionic CLI        : 3.3.0

local packages:

    @ionic/app-scripts              : 1.3.7
    @ionic/cli-plugin-cordova       : 1.3.0
    @ionic/cli-plugin-ionic-angular : 1.3.0
    @ionic/cli-plugin-ionic1        : 1.3.0
    Cordova Platforms               : android 6.2.3 ios 4.4.0
    Ionic Framework                 : ionic-angular 3.3.0
    Ionic Framework                 : unknown

System:

    Node       : v8.0.0
    OS         : macOS Sierra
    Xcode      : Xcode 8.3.2 Build version 8E2002 
    ios-deploy : 1.9.1 
    ios-sim    : 5.0.13 

Thanks for listening.

You don’t need that and should uninstall it.

Thank you, but after uninstalling the error, it remains.

Googling for “tracker not started” I would guess it has to do something with a Google Analytics plugin you are using?

Yes, i’m using, this error start when i update the Analytics native for 3.12.1

Well, don’t you think this is somewhat interesting information for debugging the problem?

Please provide a list of installed plugins (ionic cordova plugin list) and packages (content of package.json). And best you also include the code you use for the Analytics plugin.

And which version of the plugin were you using before?

Thank you for helping, i don’t know why, but for fixing the problem i did it:

On app component platform when is ready:

this.ga.startTrackerWithId('xxxxxxxxx')
      .then(() => {
        console.log('Google analytics is ready now');
      })
      .catch(e => console.log('Error starting GoogleAnalytics', e));

I put time on provider

Provider for send the name of page:

this.platform.ready().then(() => {
      if(this.platform.is('cordova')) {
        setTimeout(() => {
          this.ga.trackView(namePage);  
        }, 1000);
      }
    });

Thank you!

setTimeout() is virtually never the right answer. It is likely to result in unpredictable, difficult-to-reproduce race conditions. Please do not emulate the post above marked as the “solution”.

Instead, the call to trackView() should be placed in a then clause off the call to startTrackerWithId(), in order to be assured of proper execution order.

Let me be devil’s advocate here and anticipate the next question:

But what if I want to trackView() in other places, where there is no startTrackerWithId() call or I want to call trackView() multiple times in different places?

Then you move the startTrackerWithId() call into a service and expose the relevant future:

class AnalyticsService {
  ready: Promise<GoogleAnalytics>;

  constructor(plat: Platform, ga: GoogleAnalytics) {
    this.ready = plat.ready()
      .then(() => ga.startTrackerWithId())
      .then(() => ga);
  }
}

class SomewhereElse {
  constructor(gasvc: AnalyticsService) {
    gasvc.ready.then((ga) => {
      ga.trackView();
    });
  }
}
4 Likes

Thank you for your reply, Helped me a lot, I changed the structure to continue that way!

1 Like

This Answer helped me solve a similar issue!

@rapropos you rock dude!!! This community is an awesome place because of Jedis like you!!!
May the force be with you!

1 Like

In one specific case, I got this error when the GA Analytics ID was blank. Interestingly, on iOS only, no amount of error handling prevented this from crashing the app. The fix was to simply make sure we always have a GA Analytics ID value.

e.g.
startTrackerWithId(’’).then(

errors on iOS only with message “tracker not started”