I am currently developing GA reporting web app for my company using asp.net Google api V3(Google.Apis.Analytics.v3.dll). I understand there is older version of .net api and some example for it but when there is newer version I might as well use it. This following code snippet is how you send query to retrieve GA data using Google.GData.Analytics.dll. But it's older version.
AnalyticsService _service = new AnalyticsService("GoogleAnalytics");
_service.setUserCredentials("YourUsername", "YourPassword");
DataQuery dataQuery = new DataQuery(Conststr_Url);
dataQuery.Ids = "ga:xxxxxx";
dataQuery.Dimensions = "ga:date";
dataQuery.Metrics = "ga:visits";
dataQuery.GAStartDate = "2012-05-10";
dataQuery.GAEndDate = "2012-05-24";
DataFeed visits = _service.Query(dataQuery);
foreach (DataEntry entry in visits.Entries)
{
Response.Write("Date: " + entry.Title.Text.Replace("ga:date=", "") + " Visits: " + entry.Metrics[0].Value + "<br />");
}
With version3, I managed to do oauth2 authorisation part successfully using Tasks.ASP.NET.SimpleOAuth2 sample application they provide. But when I try to replace the task service with google analytic service, I just don't know where to start. All I know is declaring the analytic service, and from that point I have nothing to go on :) .Can anyone help me with abit of code snippets or direct me to an exmaple site.
Thank you very much in advance.