How to get Google Core Reporting Api ids Parameter Value

Google core reporting api used to get reporting data from Google Analytics. While building query for core api most important parameter is ids or tableId for building core api query.

Get apiQuery = analytics.data().ga()
.get(tableId,                  // Table Id.
"2012-01-01",              // Start date.
"2012-01-15",              // End date.
"ga:visits")               // Metrics.
.setDimensions("ga:source,ga:keyword")
.setSort("-ga:visits,ga:source")
.setFilters("ga:medium==organic")
.setMaxResults(25);

Finding value for ids or tableId parameter is not straight forward, but it can be found very easily using google analytics url. Just browser Google Analytics

For old version of application you can get very easily, use value if id parameter in query string.

https://www.google.com/analytics/reporting/?reset=1&id=XXXXXXXX&pdr=20123402-2014401

For latest version Google Analytics application url is different

https://www.google.com/analytics/web/#report/visitors-overview/a27931615w53449409pXXXXXXXX/

It is the number at the end of the URL starting with “p” letter

google-analytics-ids