2

I can't find how to do this. There's this documentation: https://developers.google.com/analytics/devguides/collection/android/v2/advanced - it shows this method:

gaInstance.getTracker(trackingId)

Where trackingId is the api key, but I think this can be used only after the tracker is already configured right? It's not to set the api key.

I need this, because my app has to track to different accounts, depending of a certain server configuration. The server will send me the api key where to track to.

Thanks in advance.

P.S. I'm using Google Analytics V2.

User
  • 31,811
  • 40
  • 131
  • 232
  • This would also be useful for people that use package name rewriting. EasyTracker can't find its resources if you rewrite the package name via "aapt --rename-manifest-package new.package.name" – Dirk Jäckel Mar 08 '13 at 14:56

1 Answers1

0

I did this:

GoogleAnalytics gaInstance = GoogleAnalytics.getInstance(context);
Tracker gaTracker = gaInstance.getTracker(apiKeyGA);
gaInstance.setDefaultTracker(gaTracker);

Seems to work. I have to confirm although.

I put it somewhere after initialization, after my webservice returns. I save it in prefs to access quicker the next time.

Edit: Doesn't work. It keeps tracking with the string I put in XML, and when I remove the element, it doesn't track anymore. But I let it here for now, maybe it leads to a correct answer.

User
  • 31,811
  • 40
  • 131
  • 232