我能够从谷歌分析API获取数据。如何获得国家明智的页面访问等数据组合。我尝试:
var query1 = asv.Data.Ga.Get("ga:xxxxxxxx", startDate, endDate, "ga:pageviews,ga:country");
query1.Metrics = "ga:country";//Gives error(can not be assigned to -- it is read only.)
query1.Dimensions = "ga:country";
query1.Sort = "ga:country,ga:pageviews";
query1.StartIndex = 1;
var report1 = query1.Fetch();
我想在网格中获取记录和绑定。我的错误在哪里。如果我评论该行
query1.Fetch();
提供错误意味着无法获取记录。
当我使用
var request = asv.Data.Ga.Get("ga:xxxxxxxx", startDate, endDate, "ga:visits,ga:pageviews,ga:bounces");
它成功获得了记录。谢谢。
答案 0 :(得分:0)
我得到了一个解决方案,所以我发布以供将来参考。
var query1 = asv.Data.Ga.Get("ga:63104444", startDate, endDate, "ga:visits");
query1.Dimensions = "ga:country";
query1.Sort = "-ga:visits";
var report1 = query1.Fetch();
List<KeyValuePair<string, object>> CountryWiseVisitList = new List<KeyValuePair<string, object>>();
foreach (IList<string> lstRow in report1.Rows)
{
CountryWiseVisitList.Add(new KeyValuePair<string, object>(lstRow[0].ToString(), lstRow[1].ToString()));
}
gdvCountryWiseVisit.DataSource = CountryWiseVisitList; //Bind on grid
gdvCountryWiseVisit.DataBind();