public async Task <List <GoogleSource> > GetSource() { if (!String.IsNullOrEmpty(profileId)) { DataResource.GaResource.GetRequest request = service.Data.Ga.Get(String.Format("ga:{0}", profileId), "30daysAgo", "today", "ga:sessions,ga:users"); request.Dimensions = "ga:medium"; var qq = await request.ExecuteAsync(); List <GoogleSource> visitors = new List <GoogleSource>(); foreach (var item in qq.Rows) { GoogleSource vv = new GoogleSource(); vv.Refferal = item[0]; vv.SessionCount = item[1]; vv.Users = item[2]; visitors.Add(vv); } return(visitors); //return qq.TotalResults.ToString(); } else { return(null); } }
public async Task <List <GoogleVisitorsAndPageView> > GetMonthVisitorsAndPageviews() { if (!String.IsNullOrEmpty(profileId)) { DataResource.GaResource.GetRequest request = service.Data.Ga.Get(String.Format("ga:{0}", profileId), "30daysAgo", "today", "ga:sessions,ga:pageviews,ga:users"); request.Dimensions = "ga:date"; var qq = await request.ExecuteAsync(); List <GoogleVisitorsAndPageView> visitors = new List <GoogleVisitorsAndPageView>(); foreach (var item in qq.Rows) { GoogleVisitorsAndPageView vv = new GoogleVisitorsAndPageView(); string time = item[0].Substring(0, 4) + "/" + item[0].Substring(4, 2) + "/" + item[0].Substring(6, 2); vv.Time = time; vv.Session = item[1]; vv.PageViews = item[2]; vv.Users = item[3]; visitors.Add(vv); } return(visitors); //return qq.TotalResults.ToString(); } else { return(null); } }