Vina C.
Vina C.

Reputation: 31

How to change analytics tracking ID on Google Developers in the app configuratiion file

I was trying to enable google analytics and get the configuration file for my android app from google developers, but I accidentally chose the wrong trakcing ID for google analytics as we have multiple tracking IDs. I can't find where I can change it neither a place to disable google analytics service. screenshot from Google Developers

It is said that the services will be added to Google Developer Console but I can only find a list of APIs that are enabled.

Could somebody tell me how I may modify the configuration so I can download the correct configuration file for my android app?

Upvotes: 3

Views: 1111

Answers (2)

Sourav Chandra
Sourav Chandra

Reputation: 843

The tracking id exists in the google-services.json but you can always change it according to your needs.

I assume you want to different your production and development builds hit points. Just create two properties in Google Analytics Dashboard and use them like this:

GoogleAnalytics googleAnalytics = GoogleAnalytics.getInstance(application
                                  .getApplicationContext());
googleAnalyticsTracker = googleAnalytics.newTracker(BuildConfig.BUILD_TYPE
                               .equals("release")?"UA-XXXXXXX":"UA-YYYYYYY");

* while initializing your application class

Upvotes: 0

Adrian Toman
Adrian Toman

Reputation: 11486

A Google Analytics tracking ID is only associated with a project in the google-services.json file that you download. Services could have been added to your project, but it may have only been Google Cloud Messaging and Google+ API.

To change the tracking ID used you can either

a) Change the tracking ID in google-services.json. The property containing the tracking ID is clearly named: tracking_id, or

b) go back to the web site to recreate and download a new google-services.json file.

Upvotes: 1

Related Questions