【发布时间】:2014-03-29 06:17:45
【问题描述】:
我正在编写这个控制台应用程序来获取一些基本的“Google Analytics API 数据”逻辑。一切工作正常,但我不想添加更多指标来查询谷歌分析 API。我不想添加 ga:newvisitors、ga:reaccuringvisitors 等。我如何在下面的代码中实现呢?
这是一段相关的代码:
var gas = new AnalyticsService(new BaseClientService.Initializer()
{
HttpClientInitializer = credential,
ApplicationName = "TestGoogleAnalytics",
});
var r = gas.Data.Ga.Get("ga:ProfileID", "2010-02-24", "2014-02-24", "ga:visitors");
//Specify some addition query parameters
r.Dimensions = "ga:pagePath";
r.Sort = "-ga:visitors";
r.MaxResults = 10000;
//Execute and fetch the results of our query
Google.Apis.Analytics.v3.Data.GaData d = r.Execute();
foreach (KeyValuePair<string, string> kvp in d.TotalsForAllResults)
{
Console.WriteLine("Total Visitors:" +" " + kvp.Value);
}
Console.WriteLine(d.TotalsForAllResults.Keys + " = " + d.TotalsForAllResults.Values);
Console.ReadLine();
谢谢
【问题讨论】:
标签: c# .net google-analytics google-analytics-api google-api-client