我正在尝试使用 Google Analytics Data API 来获取按国家/地区过滤的数据。我正在使用http://google-gdata.googlecode.com/svn/trunk/上的 .NET 库,只要我不尝试按国家/地区过滤,它就可以很好地工作。
这工作正常:
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);
但是,如果我在 Query 调用之前添加它:
query.Filters = string.Format("ga:country=={0}", this.Country);
query.Dimensions = "ga:country";
...我得到这个例外:
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"
我尝试手动将 == 转义为 %3D%3D 但这没有帮助。
有任何想法吗?