get method

Future<GaData> get(
  1. String ids,
  2. String startDate,
  3. String endDate,
  4. String metrics, {
  5. String? dimensions,
  6. String? filters,
  7. bool? includeEmptyRows,
  8. int? maxResults,
  9. String? output,
  10. String? samplingLevel,
  11. String? segment,
  12. String? sort,
  13. int? startIndex,
  14. String? $fields,
})

Returns Analytics data for a view (profile).

Request parameters:

ids - Unique table ID for retrieving Analytics data. Table ID is of the form ga:XXXX, where XXXX is the Analytics view (profile) ID. Value must have pattern ga:\[0-9\]+.

startDate - Start date for fetching Analytics data. Requests can specify a start date formatted as YYYY-MM-DD, or as a relative date (e.g., today, yesterday, or 7daysAgo). The default value is 7daysAgo. Value must have pattern \[0-9\]{4}-\[0-9\]{2}-\[0-9\]{2}|today|yesterday|\[0-9\]+(daysAgo).

endDate - End date for fetching Analytics data. Request can should specify an end date formatted as YYYY-MM-DD, or as a relative date (e.g., today, yesterday, or 7daysAgo). The default value is yesterday. Value must have pattern \[0-9\]{4}-\[0-9\]{2}-\[0-9\]{2}|today|yesterday|\[0-9\]+(daysAgo).

metrics - A comma-separated list of Analytics metrics. E.g., 'ga:sessions,ga:pageviews'. At least one metric must be specified. Value must have pattern ga:.+.

dimensions - A comma-separated list of Analytics dimensions. E.g., 'ga:browser,ga:city'. Value must have pattern (ga:.+)?.

filters - A comma-separated list of dimension or metric filters to be applied to Analytics data. Value must have pattern ga:.+.

includeEmptyRows - The response will include empty rows if this parameter is set to true, the default is true

maxResults - The maximum number of entries to include in this feed.

output - The selected format for the response. Default format is JSON. Possible string values are:

  • "dataTable" : Returns the response in Google Charts Data Table format. This is useful in creating visualization using Google Charts.
  • "json" : Returns the response in standard JSON format.

samplingLevel - The desired sampling level. Possible string values are:

  • "DEFAULT" : Returns response with a sample size that balances speed and accuracy.
  • "FASTER" : Returns a fast response with a smaller sample size.
  • "HIGHER_PRECISION" : Returns a more accurate response using a large sample size, but this may result in the response being slower.

segment - An Analytics segment to be applied to data.

sort - A comma-separated list of dimensions or metrics that determine the sort order for Analytics data. Value must have pattern (-)?ga:.+.

startIndex - An index of the first entity to retrieve. Use this parameter as a pagination mechanism along with the max-results parameter.

$fields - Selector specifying which fields to include in a partial response.

Completes with a GaData.

Completes with a commons.ApiRequestError if the API endpoint returned an error.

If the used http.Client completes with an error when making a REST call, this method will complete with the same error.

Implementation

async.Future<GaData> get(
  core.String ids,
  core.String startDate,
  core.String endDate,
  core.String metrics, {
  core.String? dimensions,
  core.String? filters,
  core.bool? includeEmptyRows,
  core.int? maxResults,
  core.String? output,
  core.String? samplingLevel,
  core.String? segment,
  core.String? sort,
  core.int? startIndex,
  core.String? $fields,
}) async {
  final queryParams_ = <core.String, core.List<core.String>>{
    'ids': [ids],
    'start-date': [startDate],
    'end-date': [endDate],
    'metrics': [metrics],
    if (dimensions != null) 'dimensions': [dimensions],
    if (filters != null) 'filters': [filters],
    if (includeEmptyRows != null)
      'include-empty-rows': ['${includeEmptyRows}'],
    if (maxResults != null) 'max-results': ['${maxResults}'],
    if (output != null) 'output': [output],
    if (samplingLevel != null) 'samplingLevel': [samplingLevel],
    if (segment != null) 'segment': [segment],
    if (sort != null) 'sort': [sort],
    if (startIndex != null) 'start-index': ['${startIndex}'],
    if ($fields != null) 'fields': [$fields],
  };

  const url_ = 'data/ga';

  final response_ = await _requester.request(
    url_,
    'GET',
    queryParams: queryParams_,
  );
  return GaData.fromJson(response_ as core.Map<core.String, core.dynamic>);
}