Google Analytics Data V1alpha API - Class Google::Analytics::Data::V1alpha::AnalyticsData::Client (v0.8.3)

Reference documentation and code samples for the Google Analytics Data V1alpha API class Google::Analytics::Data::V1alpha::AnalyticsData::Client.

Client for the AnalyticsData service.

Google Analytics reporting data service.

Inherits

  • Object

Methods

.configure

def self.configure() { |config| ... } -> Client::Configuration

Configure the AnalyticsData Client class.

See Configuration for a description of the configuration fields.

Yields
  • (config) — Configure the Client client.
Yield Parameter
Example
# Modify the configuration for all AnalyticsData clients
::Google::Analytics::Data::V1alpha::AnalyticsData::Client.configure do |config|
  config.timeout = 10.0
end

#batch_run_pivot_reports

def batch_run_pivot_reports(request, options = nil) -> ::Google::Analytics::Data::V1alpha::BatchRunPivotReportsResponse
def batch_run_pivot_reports(entity: nil, requests: nil) -> ::Google::Analytics::Data::V1alpha::BatchRunPivotReportsResponse

Returns multiple pivot reports in a batch. All reports must be for the same Entity.

Overloads
def batch_run_pivot_reports(request, options = nil) -> ::Google::Analytics::Data::V1alpha::BatchRunPivotReportsResponse
Pass arguments to batch_run_pivot_reports via a request object, either of type BatchRunPivotReportsRequest or an equivalent Hash.
Parameters
  • request (::Google::Analytics::Data::V1alpha::BatchRunPivotReportsRequest, ::Hash) — A request object representing the call parameters. Required. To specify no parameters, or to keep all the default parameter values, pass an empty Hash.
  • options (::Gapic::CallOptions, ::Hash) — Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
def batch_run_pivot_reports(entity: nil, requests: nil) -> ::Google::Analytics::Data::V1alpha::BatchRunPivotReportsResponse
Pass arguments to batch_run_pivot_reports via keyword arguments. Note that at least one keyword argument is required. To specify no parameters, or to keep all the default parameter values, pass an empty Hash as a request object (see above).
Parameters
Yields
  • (response, operation) — Access the result along with the RPC operation
Yield Parameters
Raises
  • (::Google::Cloud::Error) — if the RPC is aborted.

#batch_run_reports

def batch_run_reports(request, options = nil) -> ::Google::Analytics::Data::V1alpha::BatchRunReportsResponse
def batch_run_reports(entity: nil, requests: nil) -> ::Google::Analytics::Data::V1alpha::BatchRunReportsResponse

Returns multiple reports in a batch. All reports must be for the same Entity.

Overloads
def batch_run_reports(request, options = nil) -> ::Google::Analytics::Data::V1alpha::BatchRunReportsResponse
Pass arguments to batch_run_reports via a request object, either of type BatchRunReportsRequest or an equivalent Hash.
Parameters
  • request (::Google::Analytics::Data::V1alpha::BatchRunReportsRequest, ::Hash) — A request object representing the call parameters. Required. To specify no parameters, or to keep all the default parameter values, pass an empty Hash.
  • options (::Gapic::CallOptions, ::Hash) — Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
def batch_run_reports(entity: nil, requests: nil) -> ::Google::Analytics::Data::V1alpha::BatchRunReportsResponse
Pass arguments to batch_run_reports via keyword arguments. Note that at least one keyword argument is required. To specify no parameters, or to keep all the default parameter values, pass an empty Hash as a request object (see above).
Parameters
Yields
  • (response, operation) — Access the result along with the RPC operation
Yield Parameters
Raises
  • (::Google::Cloud::Error) — if the RPC is aborted.

#configure

def configure() { |config| ... } -> Client::Configuration

Configure the AnalyticsData Client instance.

The configuration is set to the derived mode, meaning that values can be changed, but structural changes (adding new fields, etc.) are not allowed. Structural changes should be made on Client.configure.

See Configuration for a description of the configuration fields.

Yields
  • (config) — Configure the Client client.
Yield Parameter

#get_metadata

def get_metadata(request, options = nil) -> ::Google::Analytics::Data::V1alpha::Metadata
def get_metadata(name: nil) -> ::Google::Analytics::Data::V1alpha::Metadata

Returns metadata for dimensions and metrics available in reporting methods. Used to explore the dimensions and metrics. In this method, a Google Analytics GA4 Property Identifier is specified in the request, and the metadata response includes Custom dimensions and metrics as well as Universal metadata.

For example if a custom metric with parameter name levels_unlocked is registered to a property, the Metadata response will contain customEvent:levels_unlocked. Universal metadata are dimensions and metrics applicable to any property such as country and totalUsers.

Overloads
def get_metadata(request, options = nil) -> ::Google::Analytics::Data::V1alpha::Metadata
Pass arguments to get_metadata via a request object, either of type GetMetadataRequest or an equivalent Hash.
Parameters
  • request (::Google::Analytics::Data::V1alpha::GetMetadataRequest, ::Hash) — A request object representing the call parameters. Required. To specify no parameters, or to keep all the default parameter values, pass an empty Hash.
  • options (::Gapic::CallOptions, ::Hash) — Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
def get_metadata(name: nil) -> ::Google::Analytics::Data::V1alpha::Metadata
Pass arguments to get_metadata via keyword arguments. Note that at least one keyword argument is required. To specify no parameters, or to keep all the default parameter values, pass an empty Hash as a request object (see above).
Parameter
  • name (::String) — Required. The resource name of the metadata to retrieve. This name field is specified in the URL path and not URL parameters. Property is a numeric Google Analytics GA4 Property identifier. To learn more, see where to find your Property ID.

    Example: properties/1234/metadata

    Set the Property ID to 0 for dimensions and metrics common to all properties. In this special mode, this method will not return custom dimensions and metrics.

Yields
  • (response, operation) — Access the result along with the RPC operation
Yield Parameters
Raises
  • (::Google::Cloud::Error) — if the RPC is aborted.

#initialize

def initialize() { |config| ... } -> Client

Create a new AnalyticsData client object.

Yields
  • (config) — Configure the AnalyticsData client.
Yield Parameter
Returns
  • (Client) — a new instance of Client
Example
# Create a client using the default configuration
client = ::Google::Analytics::Data::V1alpha::AnalyticsData::Client.new

# Create a client using a custom configuration
client = ::Google::Analytics::Data::V1alpha::AnalyticsData::Client.new do |config|
  config.timeout = 10.0
end

#run_pivot_report

def run_pivot_report(request, options = nil) -> ::Google::Analytics::Data::V1alpha::RunPivotReportResponse
def run_pivot_report(entity: nil, dimensions: nil, metrics: nil, dimension_filter: nil, metric_filter: nil, pivots: nil, date_ranges: nil, currency_code: nil, cohort_spec: nil, keep_empty_rows: nil, return_property_quota: nil) -> ::Google::Analytics::Data::V1alpha::RunPivotReportResponse

Returns a customized pivot report of your Google Analytics event data. Pivot reports are more advanced and expressive formats than regular reports. In a pivot report, dimensions are only visible if they are included in a pivot. Multiple pivots can be specified to further dissect your data.

Overloads
def run_pivot_report(request, options = nil) -> ::Google::Analytics::Data::V1alpha::RunPivotReportResponse
Pass arguments to run_pivot_report via a request object, either of type RunPivotReportRequest or an equivalent Hash.
Parameters
  • request (::Google::Analytics::Data::V1alpha::RunPivotReportRequest, ::Hash) — A request object representing the call parameters. Required. To specify no parameters, or to keep all the default parameter values, pass an empty Hash.
  • options (::Gapic::CallOptions, ::Hash) — Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
def run_pivot_report(entity: nil, dimensions: nil, metrics: nil, dimension_filter: nil, metric_filter: nil, pivots: nil, date_ranges: nil, currency_code: nil, cohort_spec: nil, keep_empty_rows: nil, return_property_quota: nil) -> ::Google::Analytics::Data::V1alpha::RunPivotReportResponse
Pass arguments to run_pivot_report via keyword arguments. Note that at least one keyword argument is required. To specify no parameters, or to keep all the default parameter values, pass an empty Hash as a request object (see above).
Parameters
  • entity (::Google::Analytics::Data::V1alpha::Entity, ::Hash) — A property whose events are tracked. Within a batch request, this entity should either be unspecified or consistent with the batch-level entity.
  • dimensions (::Array<::Google::Analytics::Data::V1alpha::Dimension, ::Hash>) — The dimensions requested. All defined dimensions must be used by one of the following: dimension_expression, dimension_filter, pivots, order_bys.
  • metrics (::Array<::Google::Analytics::Data::V1alpha::Metric, ::Hash>) — The metrics requested, at least one metric needs to be specified. All defined metrics must be used by one of the following: metric_expression, metric_filter, order_bys.
  • dimension_filter (::Google::Analytics::Data::V1alpha::FilterExpression, ::Hash) — The filter clause of dimensions. Dimensions must be requested to be used in this filter. Metrics cannot be used in this filter.
  • metric_filter (::Google::Analytics::Data::V1alpha::FilterExpression, ::Hash) — The filter clause of metrics. Applied at post aggregation phase, similar to SQL having-clause. Metrics must be requested to be used in this filter. Dimensions cannot be used in this filter.
  • pivots (::Array<::Google::Analytics::Data::V1alpha::Pivot, ::Hash>) — Describes the visual format of the report's dimensions in columns or rows. The union of the fieldNames (dimension names) in all pivots must be a subset of dimension names defined in Dimensions. No two pivots can share a dimension. A dimension is only visible if it appears in a pivot.
  • date_ranges (::Array<::Google::Analytics::Data::V1alpha::DateRange, ::Hash>) — The date range to retrieve event data for the report. If multiple date ranges are specified, event data from each date range is used in the report. A special dimension with field name "dateRange" can be included in a Pivot's field names; if included, the report compares between date ranges. In a cohort request, this dateRanges must be unspecified.
  • currency_code (::String) — A currency code in ISO4217 format, such as "AED", "USD", "JPY". If the field is empty, the report uses the entity's default currency.
  • cohort_spec (::Google::Analytics::Data::V1alpha::CohortSpec, ::Hash) — Cohort group associated with this request. If there is a cohort group in the request the 'cohort' dimension must be present.
  • keep_empty_rows (::Boolean) — If false or unspecified, each row with all metrics equal to 0 will not be returned. If true, these rows will be returned if they are not separately removed by a filter.
  • return_property_quota (::Boolean) — Toggles whether to return the current state of this Analytics Property's quota. Quota is returned in PropertyQuota.
Yields
  • (response, operation) — Access the result along with the RPC operation
Yield Parameters
Raises
  • (::Google::Cloud::Error) — if the RPC is aborted.

#run_realtime_report

def run_realtime_report(request, options = nil) -> ::Google::Analytics::Data::V1alpha::RunRealtimeReportResponse
def run_realtime_report(property: nil, dimensions: nil, metrics: nil, limit: nil, dimension_filter: nil, metric_filter: nil, metric_aggregations: nil, order_bys: nil, return_property_quota: nil) -> ::Google::Analytics::Data::V1alpha::RunRealtimeReportResponse

The Google Analytics Realtime API returns a customized report of realtime event data for your property. These reports show events and usage from the last 30 minutes.

Overloads
def run_realtime_report(request, options = nil) -> ::Google::Analytics::Data::V1alpha::RunRealtimeReportResponse
Pass arguments to run_realtime_report via a request object, either of type RunRealtimeReportRequest or an equivalent Hash.
Parameters
  • request (::Google::Analytics::Data::V1alpha::RunRealtimeReportRequest, ::Hash) — A request object representing the call parameters. Required. To specify no parameters, or to keep all the default parameter values, pass an empty Hash.
  • options (::Gapic::CallOptions, ::Hash) — Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
def run_realtime_report(property: nil, dimensions: nil, metrics: nil, limit: nil, dimension_filter: nil, metric_filter: nil, metric_aggregations: nil, order_bys: nil, return_property_quota: nil) -> ::Google::Analytics::Data::V1alpha::RunRealtimeReportResponse
Pass arguments to run_realtime_report via keyword arguments. Note that at least one keyword argument is required. To specify no parameters, or to keep all the default parameter values, pass an empty Hash as a request object (see above).
Parameters
Yields
  • (response, operation) — Access the result along with the RPC operation
Yield Parameters
Raises
  • (::Google::Cloud::Error) — if the RPC is aborted.

#run_report

def run_report(request, options = nil) -> ::Google::Analytics::Data::V1alpha::RunReportResponse
def run_report(entity: nil, dimensions: nil, metrics: nil, date_ranges: nil, offset: nil, limit: nil, metric_aggregations: nil, dimension_filter: nil, metric_filter: nil, order_bys: nil, currency_code: nil, cohort_spec: nil, keep_empty_rows: nil, return_property_quota: nil) -> ::Google::Analytics::Data::V1alpha::RunReportResponse

Returns a customized report of your Google Analytics event data. Reports contain statistics derived from data collected by the Google Analytics tracking code. The data returned from the API is as a table with columns for the requested dimensions and metrics. Metrics are individual measurements of user activity on your property, such as active users or event count. Dimensions break down metrics across some common criteria, such as country or event name.

Overloads
def run_report(request, options = nil) -> ::Google::Analytics::Data::V1alpha::RunReportResponse
Pass arguments to run_report via a request object, either of type RunReportRequest or an equivalent Hash.
Parameters
  • request (::Google::Analytics::Data::V1alpha::RunReportRequest, ::Hash) — A request object representing the call parameters. Required. To specify no parameters, or to keep all the default parameter values, pass an empty Hash.
  • options (::Gapic::CallOptions, ::Hash) — Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
def run_report(entity: nil, dimensions: nil, metrics: nil, date_ranges: nil, offset: nil, limit: nil, metric_aggregations: nil, dimension_filter: nil, metric_filter: nil, order_bys: nil, currency_code: nil, cohort_spec: nil, keep_empty_rows: nil, return_property_quota: nil) -> ::Google::Analytics::Data::V1alpha::RunReportResponse
Pass arguments to run_report via keyword arguments. Note that at least one keyword argument is required. To specify no parameters, or to keep all the default parameter values, pass an empty Hash as a request object (see above).
Parameters
  • entity (::Google::Analytics::Data::V1alpha::Entity, ::Hash) — A property whose events are tracked. Within a batch request, this entity should either be unspecified or consistent with the batch-level entity.
  • dimensions (::Array<::Google::Analytics::Data::V1alpha::Dimension, ::Hash>) — The dimensions requested and displayed.
  • metrics (::Array<::Google::Analytics::Data::V1alpha::Metric, ::Hash>) — The metrics requested and displayed.
  • date_ranges (::Array<::Google::Analytics::Data::V1alpha::DateRange, ::Hash>) — Date ranges of data to read. If multiple date ranges are requested, each response row will contain a zero based date range index. If two date ranges overlap, the event data for the overlapping days is included in the response rows for both date ranges. In a cohort request, this dateRanges must be unspecified.
  • offset (::Integer) — The row count of the start row. The first row is counted as row 0.

    To learn more about this pagination parameter, see Pagination.

  • limit (::Integer) — The number of rows to return. If unspecified, 10 rows are returned. If -1, all rows are returned.

    To learn more about this pagination parameter, see Pagination.

  • metric_aggregations (::Array<::Google::Analytics::Data::V1alpha::MetricAggregation>) — Aggregation of metrics. Aggregated metric values will be shown in rows where the dimension_values are set to "RESERVED_(MetricAggregation)".
  • dimension_filter (::Google::Analytics::Data::V1alpha::FilterExpression, ::Hash) — The filter clause of dimensions. Dimensions must be requested to be used in this filter. Metrics cannot be used in this filter.
  • metric_filter (::Google::Analytics::Data::V1alpha::FilterExpression, ::Hash) — The filter clause of metrics. Applied at post aggregation phase, similar to SQL having-clause. Metrics must be requested to be used in this filter. Dimensions cannot be used in this filter.
  • order_bys (::Array<::Google::Analytics::Data::V1alpha::OrderBy, ::Hash>) — Specifies how rows are ordered in the response.
  • currency_code (::String) — A currency code in ISO4217 format, such as "AED", "USD", "JPY". If the field is empty, the report uses the entity's default currency.
  • cohort_spec (::Google::Analytics::Data::V1alpha::CohortSpec, ::Hash) — Cohort group associated with this request. If there is a cohort group in the request the 'cohort' dimension must be present.
  • keep_empty_rows (::Boolean) — If false or unspecified, each row with all metrics equal to 0 will not be returned. If true, these rows will be returned if they are not separately removed by a filter.
  • return_property_quota (::Boolean) — Toggles whether to return the current state of this Analytics Property's quota. Quota is returned in PropertyQuota.
Yields
  • (response, operation) — Access the result along with the RPC operation
Yield Parameters
Raises
  • (::Google::Cloud::Error) — if the RPC is aborted.