Skip to content

Instantly share code, notes, and snippets.

@agencethelio agencethelio/GetReport.cs Secret
Created Nov 9, 2018

Embed
What would you like to do?
Traitement du service Report de GoogleAnalytics
private static Report GetReport(string sViewId, string startDate, string endDate)
{
string[] scopes = new string[] { AnalyticsReportingService.Scope.Analytics };
var credential_google = GoogleCredential.FromJson(_jsonCertificat).CreateScoped(scopes);
AnalyticsReportingService analyticsreporting = new AnalyticsReportingService(new BaseClientService.Initializer()
{
HttpClientInitializer = credential_google,
ApplicationName = _projectId,
});
DateRange dateRange = new DateRange() { StartDate = startDate, EndDate = endDate };
ReportRequest reportRequest = new ReportRequest
{
ViewId = sViewId,
DateRanges = new List<DateRange>() { dateRange },
Dimensions = _dimensions,
Metrics = _metrics
};
List<ReportRequest> requests = new List<ReportRequest>
{
reportRequest
};
// Create the GetReportsRequest object.
GetReportsRequest getReport = new GetReportsRequest() { ReportRequests = requests };
// Call the batchGet method.
GetReportsResponse response = analyticsreporting.Reports.BatchGet(getReport).Execute();
return response.Reports[0];
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.