-
-
Save agencethelio/3c3041c9b801e9e5baf218272dba81d6 to your computer and use it in GitHub Desktop.
Traitement du service Report de GoogleAnalytics
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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