2012-09-26 123 views
0

我能夠從谷歌分析獲取數據api.How我得到這樣的國家明智的頁面數據visit.I嘗試的組合:操縱谷歌分析數據

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");

其順利拿到record.Thanks。

回答

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();