using Google.Analytics; using Google.GData.Analytics; //v2.2.0.0 public class Visitor : IHttpHandler { public void ProcessRequest (HttpContext context) { AccountQuery feedQuery = new AccountQuery(); AnalyticsService service = new AnalyticsService("kiranaAnalytic"); service.setUserCredentials("myemailid@gmail.com", "mypassword"); DataQuery pageViewQuery = new DataQuery("https://www.google.com/analytics/feeds/data");//https://www.google.com/analytics/feeds/data pageViewQuery.Ids = "ga:xxxx"; pageViewQuery.Metrics = "ga:visitors"; pageViewQuery.GAStartDate = "2014-05-01";//DateTime.Now.AddMonths(-1).ToString("yyyy-MM-dd"); pageViewQuery.GAEndDate = DateTime.Now.ToString("yyyy-MM-dd"); DataEntry pvEntry = service.Query(pageViewQuery).Entries[0] as DataEntry; context.Response.ContentType = "text/plain"; context.Response.Write(pvEntry.Metrics[0].Value); } public bool IsReusable { get { return false; } } }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)