I am trying to query my Analytics (Universal) to get a list of metrics sorted by user dimension.
In July, the Google Analytics API Blog announced:
"Developers can use custom parameters to send unique identifiers to Google Analytics, and then use the underlying reporting API to retrieve these identifiers along with other Google Analytics data.
For example, your content management system may pass the content identifier as a custom dimension using the Google Analytics tracking code. Developers can then use the API to list the most popular content by ID and display a list of the most popular content on their website. "
Despite this, I could not get any results from my Google Analytics. My submit function is below:
ga('send', 'pageview', { 'dimension1':'red' });
Unfortunately, a GA query using the filter "ga: dimension1 == red" does not get any results.
gapi.client.analytics.data.ga.get({ 'ids': 'ga:' + "123456", 'start-date': '2013-11-10', 'end-date': '2013-11-20', 'metrics': 'ga:visits', 'filters': 'ga:dimension1==red' }).execute(function(r){console.log(r);});
I also tried using custom segments to retrieve data, but it didn't help:
'segment': 'dynamic::ga:dimension1==red'
Data is displayed in custom reports in GA. How can I access it through the API?