views:

401

answers:

1

I'm trying to use the Google Analytics Data API to get data filtered by country. I am using the .NET library at http://google-gdata.googlecode.com/svn/trunk/ which works beautifully as long as I don't try to filter by country.

This works fine:

const string dataFeedUrl = "https://www.google.com/analytics/feeds/data"; 

var query = new DataQuery(dataFeedUrl);
query.Ids = this.ProfileID;
query.GAStartDate = this.FromDate;
query.GAEndDate = this.ToDate;
query.Metrics = "ga:newVisits,ga:visitors";

DataFeed dataFeed = this.AnalyticsService.Query(query);

But if I add this before the Query call:

query.Filters = string.Format("ga:country=={0}", this.Country);
query.Dimensions = "ga:country";

... I get this exception:

System.Exception {Google.GData.Client.GDataRequestException}
"Execution of request failed: https://www.google.com/analytics/feeds/data?dimensions=ga:country&end-date=2009-06-17&filters=ga:country==Denmark&ids=ga:xxx&metrics=ga:newVisits,ga:visitors&start-date=2009-05-18"

I've tried manually escaping == to %3D%3D but that didn't help.

Any ideas?

A: 

I finally found the ResponseString and saw this message:

"Illegal combination of dimensions and metrics"

Apparently, I have been trying to get data that is not available. This does make sense when looking at the Query Validation Chart in the documentation.

larssg