0

我能够从谷歌分析 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");

它成功获得记录。谢谢。

4

1 回答 1

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();
于 2012-09-26T08:26:52.270 回答