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.
PS I'm using Google Analytics V2.
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.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.