2
我正在编写此控制台应用程序以获取一些基本的“Google Analytics API数据”逻辑。 Everythings正常工作,但我不想添加更多的指标来查询谷歌分析API。我不想添加ga:newvisitors,ga:reaccuringvisitors等。我如何在下面的代码中实现这一点?从.NET Analytics获取Google AnalyticsAPI的数据,多个指标?
这里有一个相关的部分代码:
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("Antal Besök:" +" " + kvp.Value);
}
Console.WriteLine(d.TotalsForAllResults.Keys + " = " + d.TotalsForAllResults.Values);
Console.ReadLine();
感谢
嗯好吧,我做了类似的事情,但我错误地编写了代码。谢谢我会试试这个=) – koffe14
检查更新我搜索了一些东西,你的指标是错误的。 – DaImTo
哦,我不知道他们删除它,我需要更多的统计数据来绘制图表。 Reacurringvisitors dosn't excist,但我认为ga:percentNewVisits可以使用。然而,当我运行代码时出现这个错误,当我像这样执行“r”时,错误会引发Google.Apis.Analytics.v3.Data.GaData d = r.Execute();错误说 - “参数验证失败的”ids“ – koffe14