I am attempting to query my Analytics (Universal) to receive a list of metrics sorted by a custom dimension.
In July, the Google Analytics API blog announced:
"Developers can use custom dimensions to send unique IDs into Google Analytics, and then use the core reporting API to retrieve these IDs along with other Google Analytics data.
For example, your content management system can pass a content ID as a custom dimension using the Google Analytics tracking code. Developers can then use the API to get a list of the most popular content by ID and display the list of most popular content on their website."
Despite this, I have been unable to retrieve any results from my Analytics. My send function is below:
ga('send', 'pageview', {
'dimension1':'red'
});
Unfortunately, querying GA using a filter of 'ga:dimension1 == red' does not retrieve 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 have also tried using custom segments to retrieve the data, to no avail:
'segment': 'dynamic::ga:dimension1==red'
The data appears in Custom Reports in GA. How can I access it via the API?