【发布时间】:2018-12-10 08:13:19
【问题描述】:
举报
我已阅读此主题:Google Analytics API: Why is the API data different than what's being seen on the Analytics Dashboard? 但仍然无法弄清楚为什么我的结果与我的分析仪表板有如此大的差异。
如果我的响应包含 sampleData,我如何签入 .Net?这是我正在使用的代码:
string[] s = new string[]{"https://www.googleapis.com/auth/analytics.readonly"};
var auth = GoogleAnalyticsServiceAccount.AuthenticateServiceAccount("XXXXX", "D:\\Spawtz\\Src\\client_id.json", s);
// Create the DateRange object.
//DateRange lastWeek = new DateRange() { StartDate = "2018-12-02", EndDate = "2018-12-09" };
DateRange lastMonth = new DateRange() { StartDate = "2018-11-09", EndDate = "2018-12-09" };
DateRange lastYear = new DateRange() { StartDate = "2017-12-09", EndDate = "2018-12-09" };
// Create the Metrics object.
Metric pageViews = new Metric { Expression = "ga:pageViews"};
//Create the Dimensions object.
Dimension pagePath = new Dimension { Name = "ga:pagePath" };
// Create the ReportRequest object.
// Create the ReportRequest object.
ReportRequest reportRequest = new ReportRequest
{
ViewId = "XXXXX",
DateRanges = new List<DateRange>() { lastMonth, lastYear},
Dimensions = new List<Dimension>() { pagePath },
Metrics = new List<Metric>() { pageViews },
FiltersExpression = "ga:pagePath==/cricket-player/t20/playerid=2348"
};
List<ReportRequest> requests = new List<ReportRequest>();
requests.Add(reportRequest);
// Create the GetReportsRequest object.
GetReportsRequest getReport = new GetReportsRequest() { ReportRequests = requests };
// Call the batchGet method.
GetReportsResponse response = auth.Reports.BatchGet(getReport).Execute();
我可以在 asp.Net 中设置 SamplingLevel 和 Max-Results 吗?
【问题讨论】:
-
请拍下您在仪表板中看到的数字以及运行代码时看到的结果。
-
您好,感谢您的回复。这是为相同 dateRange 值拍摄的两张图像:ibb.co/QpQCBRwibb.co/JRKf7sZ
-
@DeonLastManStands - 在你的代码中你有
/cricket-player/t20/playerid=2348但在屏幕截图中它有/cricket-player/t20&playerid=2348- 可能是扭曲的东西?
标签: c# google-analytics google-api google-analytics-api google-api-dotnet-client