Possible to change trackingId in code? (Xaml/C# App)

May 6, 2014 at 8:37 PM
Edited May 6, 2014 at 8:39 PM
Hi,

First of all, thank you for this awesome SDK! You guys rock and hope you continue this great work.

Currently, the trackingId is set in the analytics.xml file. My question would be, is it possible to update/change the trackingId in code at run time? Our app is for business use, and so our clients need to be able to update the trackingId dynamically to hook up into their own Google Analytics account. We are unable to create a new app for every client.

Thanks!
Andrew
Coordinator
May 6, 2014 at 9:41 PM
Hi Andrew, thank you for the compliments!

You can programmatically inject all of the config settings found in analytics.xml instead of using the XML file. To do this, call:
GoogleAnalytics.EasyTracker.Current.Config = new EasyTrackerConfig(){
    TrackingId = "UA-39959863-1",
    ...plus any other properties you want to set...
};
Just make sure you call this before calling .GetTracker()
Marked as answer by AndrewAu on 5/6/2014 at 3:29 PM
May 6, 2014 at 10:29 PM
Thank you Tim! It works. Wow, I am glad that I posted here.

Keep up the good work.