I want to retrieve the Google Analytics Tracking ID based on the Google Tag Manager ID, via code. Is this possible? Is there some sort of function I can call in javascript, which returns the ID? The Tag Assistant extension for Chrome correctly sees the Analytics UA code, with only the Tag Manager scripts, so it should be doable I guess?
No matter how GA is implemented (via GTM or hardcoded) you can simply get tracking ID via:
ga.getAll()[0].get('trackingId');
If there're more than 1 GA on page you can access them too (just iterate throuh array).