Class v1beta.BetaAnalyticsDataClient (3.2.1)

Google Analytics reporting data service. v1beta

Package

@google-analytics/data

Constructors

(constructor)(opts, gaxInstance)

constructor(opts?: ClientOptions, gaxInstance?: typeof gax | typeof gax.fallback);

Construct an instance of BetaAnalyticsDataClient.

Parameters
NameDescription
opts ClientOptions
gaxInstance typeof gax | typeof gax.fallback

: loaded instance of google-gax. Useful if you need to avoid loading the default gRPC version and want to use the fallback HTTP implementation. Load only fallback version and pass it to the constructor: ``` const gax = require('google-gax/build/src/fallback'); // avoids loading google-gax with gRPC const client = new BetaAnalyticsDataClient({fallback: 'rest'}, gax); ```

Properties

apiEndpoint

static get apiEndpoint(): string;

The DNS address for this API service - same as servicePath(), exists for compatibility reasons.

auth

auth: gax.GoogleAuth;

betaAnalyticsDataStub

betaAnalyticsDataStub?: Promise<{
        [name: string]: Function;
    }>;

descriptors

descriptors: Descriptors;

innerApiCalls

innerApiCalls: {
        [name: string]: Function;
    };

pathTemplates

pathTemplates: {
        [name: string]: gax.PathTemplate;
    };

port

static get port(): number;

The port for this API service.

scopes

static get scopes(): string[];

The scopes needed to make gRPC calls for every method defined in this service.

servicePath

static get servicePath(): string;

The DNS address for this API service.

warn

warn: (code: string, message: string, warnType?: string) => void;

Methods

batchRunPivotReports(request, options)

batchRunPivotReports(request?: protos.google.analytics.data.v1beta.IBatchRunPivotReportsRequest, options?: CallOptions): Promise<[
        protos.google.analytics.data.v1beta.IBatchRunPivotReportsResponse,
        (protos.google.analytics.data.v1beta.IBatchRunPivotReportsRequest | undefined),
        {} | undefined
    ]>;

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

Parameters
NameDescription
request protos.google.analytics.data.v1beta.IBatchRunPivotReportsRequest

The request object that will be sent.

options CallOptions

Call options. See CallOptions for more details.

Returns
TypeDescription
Promise<[ protos.google.analytics.data.v1beta.IBatchRunPivotReportsResponse, (protos.google.analytics.data.v1beta.IBatchRunPivotReportsRequest | undefined), {} | undefined ]>

{Promise} - The promise which resolves to an array. The first element of the array is an object representing . Please see the [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) for more details and examples.

Example

  /**
   * This snippet has been automatically generated and should be regarded as a code template only.
   * It will require modifications to work.
   * It may require correct/in-range values for request initialization.
   * TODO(developer): Uncomment these variables before running the sample.
   */
  /**
   *  A Google Analytics GA4 property identifier whose events are tracked.
   *  Specified in the URL path and not the body. To learn more, see where to
   *  find your Property
   *  ID (https://developers.google.com/analytics/devguides/reporting/data/v1/property-id).
   *  This property must be specified for the batch. The property within
   *  RunPivotReportRequest may either be unspecified or consistent with this
   *  property.
   *  Example: properties/1234
   */
  // const property = 'abc123'
  /**
   *  Individual requests. Each request has a separate pivot report response.
   *  Each batch request is allowed up to 5 requests.
   */
  // const requests = 1234

  // Imports the Data library
  const {BetaAnalyticsDataClient} = require('@google-analytics/data').v1beta;

  // Instantiates a client
  const dataClient = new BetaAnalyticsDataClient();

  async function callBatchRunPivotReports() {
    // Construct request
    const request = {
    };

    // Run request
    const response = await dataClient.batchRunPivotReports(request);
    console.log(response);
  }

  callBatchRunPivotReports();

batchRunPivotReports(request, options, callback)

batchRunPivotReports(request: protos.google.analytics.data.v1beta.IBatchRunPivotReportsRequest, options: CallOptions, callback: Callback<protos.google.analytics.data.v1beta.IBatchRunPivotReportsResponse, protos.google.analytics.data.v1beta.IBatchRunPivotReportsRequest | null | undefined, {} | null | undefined>): void;
Parameters
NameDescription
request protos.google.analytics.data.v1beta.IBatchRunPivotReportsRequest
options CallOptions
callback Callback<protos.google.analytics.data.v1beta.IBatchRunPivotReportsResponse, protos.google.analytics.data.v1beta.IBatchRunPivotReportsRequest | null | undefined, {} | null | undefined>
Returns
TypeDescription
void

batchRunPivotReports(request, callback)

batchRunPivotReports(request: protos.google.analytics.data.v1beta.IBatchRunPivotReportsRequest, callback: Callback<protos.google.analytics.data.v1beta.IBatchRunPivotReportsResponse, protos.google.analytics.data.v1beta.IBatchRunPivotReportsRequest | null | undefined, {} | null | undefined>): void;
Parameters
NameDescription
request protos.google.analytics.data.v1beta.IBatchRunPivotReportsRequest
callback Callback<protos.google.analytics.data.v1beta.IBatchRunPivotReportsResponse, protos.google.analytics.data.v1beta.IBatchRunPivotReportsRequest | null | undefined, {} | null | undefined>
Returns
TypeDescription
void

batchRunReports(request, options)

batchRunReports(request?: protos.google.analytics.data.v1beta.IBatchRunReportsRequest, options?: CallOptions): Promise<[
        protos.google.analytics.data.v1beta.IBatchRunReportsResponse,
        protos.google.analytics.data.v1beta.IBatchRunReportsRequest | undefined,
        {} | undefined
    ]>;

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

Parameters
NameDescription
request protos.google.analytics.data.v1beta.IBatchRunReportsRequest

The request object that will be sent.

options CallOptions

Call options. See CallOptions for more details.

Returns
TypeDescription
Promise<[ protos.google.analytics.data.v1beta.IBatchRunReportsResponse, protos.google.analytics.data.v1beta.IBatchRunReportsRequest | undefined, {} | undefined ]>

{Promise} - The promise which resolves to an array. The first element of the array is an object representing . Please see the [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) for more details and examples.

Example

  /**
   * This snippet has been automatically generated and should be regarded as a code template only.
   * It will require modifications to work.
   * It may require correct/in-range values for request initialization.
   * TODO(developer): Uncomment these variables before running the sample.
   */
  /**
   *  A Google Analytics GA4 property identifier whose events are tracked.
   *  Specified in the URL path and not the body. To learn more, see where to
   *  find your Property
   *  ID (https://developers.google.com/analytics/devguides/reporting/data/v1/property-id).
   *  This property must be specified for the batch. The property within
   *  RunReportRequest may either be unspecified or consistent with this
   *  property.
   *  Example: properties/1234
   */
  // const property = 'abc123'
  /**
   *  Individual requests. Each request has a separate report response. Each
   *  batch request is allowed up to 5 requests.
   */
  // const requests = 1234

  // Imports the Data library
  const {BetaAnalyticsDataClient} = require('@google-analytics/data').v1beta;

  // Instantiates a client
  const dataClient = new BetaAnalyticsDataClient();

  async function callBatchRunReports() {
    // Construct request
    const request = {
    };

    // Run request
    const response = await dataClient.batchRunReports(request);
    console.log(response);
  }

  callBatchRunReports();

batchRunReports(request, options, callback)

batchRunReports(request: protos.google.analytics.data.v1beta.IBatchRunReportsRequest, options: CallOptions, callback: Callback<protos.google.analytics.data.v1beta.IBatchRunReportsResponse, protos.google.analytics.data.v1beta.IBatchRunReportsRequest | null | undefined, {} | null | undefined>): void;
Parameters
NameDescription
request protos.google.analytics.data.v1beta.IBatchRunReportsRequest
options CallOptions
callback Callback<protos.google.analytics.data.v1beta.IBatchRunReportsResponse, protos.google.analytics.data.v1beta.IBatchRunReportsRequest | null | undefined, {} | null | undefined>
Returns
TypeDescription
void

batchRunReports(request, callback)

batchRunReports(request: protos.google.analytics.data.v1beta.IBatchRunReportsRequest, callback: Callback<protos.google.analytics.data.v1beta.IBatchRunReportsResponse, protos.google.analytics.data.v1beta.IBatchRunReportsRequest | null | undefined, {} | null | undefined>): void;
Parameters
NameDescription
request protos.google.analytics.data.v1beta.IBatchRunReportsRequest
callback Callback<protos.google.analytics.data.v1beta.IBatchRunReportsResponse, protos.google.analytics.data.v1beta.IBatchRunReportsRequest | null | undefined, {} | null | undefined>
Returns
TypeDescription
void

checkCompatibility(request, options)

checkCompatibility(request?: protos.google.analytics.data.v1beta.ICheckCompatibilityRequest, options?: CallOptions): Promise<[
        protos.google.analytics.data.v1beta.ICheckCompatibilityResponse,
        (protos.google.analytics.data.v1beta.ICheckCompatibilityRequest | undefined),
        {} | undefined
    ]>;

This compatibility method lists dimensions and metrics that can be added to a report request and maintain compatibility. This method fails if the request's dimensions and metrics are incompatible.

In Google Analytics, reports fail if they request incompatible dimensions and/or metrics; in that case, you will need to remove dimensions and/or metrics from the incompatible report until the report is compatible.

The Realtime and Core reports have different compatibility rules. This method checks compatibility for Core reports.

Parameters
NameDescription
request protos.google.analytics.data.v1beta.ICheckCompatibilityRequest

The request object that will be sent.

options CallOptions

Call options. See CallOptions for more details.

Returns
TypeDescription
Promise<[ protos.google.analytics.data.v1beta.ICheckCompatibilityResponse, (protos.google.analytics.data.v1beta.ICheckCompatibilityRequest | undefined), {} | undefined ]>

{Promise} - The promise which resolves to an array. The first element of the array is an object representing . Please see the [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) for more details and examples.

Example

  /**
   * This snippet has been automatically generated and should be regarded as a code template only.
   * It will require modifications to work.
   * It may require correct/in-range values for request initialization.
   * TODO(developer): Uncomment these variables before running the sample.
   */
  /**
   *  A Google Analytics GA4 property identifier whose events are tracked. To
   *  learn more, see where to find your Property
   *  ID (https://developers.google.com/analytics/devguides/reporting/data/v1/property-id).
   *  `property` should be the same value as in your `runReport` request.
   *  Example: properties/1234
   *  Set the Property ID to 0 for compatibility checking on dimensions and
   *  metrics common to all properties. In this special mode, this method will
   *  not return custom dimensions and metrics.
   */
  // const property = 'abc123'
  /**
   *  The dimensions in this report. `dimensions` should be the same value as in
   *  your `runReport` request.
   */
  // const dimensions = 1234
  /**
   *  The metrics in this report. `metrics` should be the same value as in your
   *  `runReport` request.
   */
  // const metrics = 1234
  /**
   *  The filter clause of dimensions. `dimensionFilter` should be the same value
   *  as in your `runReport` request.
   */
  // const dimensionFilter = {}
  /**
   *  The filter clause of metrics. `metricFilter` should be the same value as in
   *  your `runReport` request
   */
  // const metricFilter = {}
  /**
   *  Filters the dimensions and metrics in the response to just this
   *  compatibility. Commonly used as `”compatibilityFilter”: “COMPATIBLE”`
   *  to only return compatible dimensions & metrics.
   */
  // const compatibilityFilter = {}

  // Imports the Data library
  const {BetaAnalyticsDataClient} = require('@google-analytics/data').v1beta;

  // Instantiates a client
  const dataClient = new BetaAnalyticsDataClient();

  async function callCheckCompatibility() {
    // Construct request
    const request = {
    };

    // Run request
    const response = await dataClient.checkCompatibility(request);
    console.log(response);
  }

  callCheckCompatibility();

checkCompatibility(request, options, callback)

checkCompatibility(request: protos.google.analytics.data.v1beta.ICheckCompatibilityRequest, options: CallOptions, callback: Callback<protos.google.analytics.data.v1beta.ICheckCompatibilityResponse, protos.google.analytics.data.v1beta.ICheckCompatibilityRequest | null | undefined, {} | null | undefined>): void;
Parameters
NameDescription
request protos.google.analytics.data.v1beta.ICheckCompatibilityRequest
options CallOptions
callback Callback<protos.google.analytics.data.v1beta.ICheckCompatibilityResponse, protos.google.analytics.data.v1beta.ICheckCompatibilityRequest | null | undefined, {} | null | undefined>
Returns
TypeDescription
void

checkCompatibility(request, callback)

checkCompatibility(request: protos.google.analytics.data.v1beta.ICheckCompatibilityRequest, callback: Callback<protos.google.analytics.data.v1beta.ICheckCompatibilityResponse, protos.google.analytics.data.v1beta.ICheckCompatibilityRequest | null | undefined, {} | null | undefined>): void;
Parameters
NameDescription
request protos.google.analytics.data.v1beta.ICheckCompatibilityRequest
callback Callback<protos.google.analytics.data.v1beta.ICheckCompatibilityResponse, protos.google.analytics.data.v1beta.ICheckCompatibilityRequest | null | undefined, {} | null | undefined>
Returns
TypeDescription
void

close()

close(): Promise<void>;

Terminate the gRPC channel and close the client.

The client will no longer be usable and all future behavior is undefined.

Returns
TypeDescription
Promise<void>

{Promise} A promise that resolves when the client is closed.

getMetadata(request, options)

getMetadata(request?: protos.google.analytics.data.v1beta.IGetMetadataRequest, options?: CallOptions): Promise<[
        protos.google.analytics.data.v1beta.IMetadata,
        protos.google.analytics.data.v1beta.IGetMetadataRequest | undefined,
        {} | undefined
    ]>;

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.

Parameters
NameDescription
request protos.google.analytics.data.v1beta.IGetMetadataRequest

The request object that will be sent.

options CallOptions

Call options. See CallOptions for more details.

Returns
TypeDescription
Promise<[ protos.google.analytics.data.v1beta.IMetadata, protos.google.analytics.data.v1beta.IGetMetadataRequest | undefined, {} | undefined ]>

{Promise} - The promise which resolves to an array. The first element of the array is an object representing . Please see the [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) for more details and examples.

Example

  /**
   * This snippet has been automatically generated and should be regarded as a code template only.
   * It will require modifications to work.
   * It may require correct/in-range values for request initialization.
   * TODO(developer): Uncomment these variables before running the sample.
   */
  /**
   *  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 (https://developers.google.com/analytics/devguides/reporting/data/v1/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.
   */
  // const name = 'abc123'

  // Imports the Data library
  const {BetaAnalyticsDataClient} = require('@google-analytics/data').v1beta;

  // Instantiates a client
  const dataClient = new BetaAnalyticsDataClient();

  async function callGetMetadata() {
    // Construct request
    const request = {
      name,
    };

    // Run request
    const response = await dataClient.getMetadata(request);
    console.log(response);
  }

  callGetMetadata();

getMetadata(request, options, callback)

getMetadata(request: protos.google.analytics.data.v1beta.IGetMetadataRequest, options: CallOptions, callback: Callback<protos.google.analytics.data.v1beta.IMetadata, protos.google.analytics.data.v1beta.IGetMetadataRequest | null | undefined, {} | null | undefined>): void;
Parameters
NameDescription
request protos.google.analytics.data.v1beta.IGetMetadataRequest
options CallOptions
callback Callback<protos.google.analytics.data.v1beta.IMetadata, protos.google.analytics.data.v1beta.IGetMetadataRequest | null | undefined, {} | null | undefined>
Returns
TypeDescription
void

getMetadata(request, callback)

getMetadata(request: protos.google.analytics.data.v1beta.IGetMetadataRequest, callback: Callback<protos.google.analytics.data.v1beta.IMetadata, protos.google.analytics.data.v1beta.IGetMetadataRequest | null | undefined, {} | null | undefined>): void;
Parameters
NameDescription
request protos.google.analytics.data.v1beta.IGetMetadataRequest
callback Callback<protos.google.analytics.data.v1beta.IMetadata, protos.google.analytics.data.v1beta.IGetMetadataRequest | null | undefined, {} | null | undefined>
Returns
TypeDescription
void

getProjectId()

getProjectId(): Promise<string>;
Returns
TypeDescription
Promise<string>

getProjectId(callback)

getProjectId(callback: Callback<string, undefined, undefined>): void;
Parameter
NameDescription
callback Callback<string, undefined, undefined>
Returns
TypeDescription
void

initialize()

initialize(): Promise<{
        [name: string]: Function;
    }>;

Initialize the client. Performs asynchronous operations (such as authentication) and prepares the client. This function will be called automatically when any class method is called for the first time, but if you need to initialize it before calling an actual method, feel free to call initialize() directly.

You can await on this method if you want to make sure the client is initialized.

Returns
TypeDescription
Promise<{ [name: string]: Function; }>

{Promise} A promise that resolves to an authenticated service stub.

matchPropertyFromMetadataName(metadataName)

matchPropertyFromMetadataName(metadataName: string): string | number;

Parse the property from Metadata resource.

Parameter
NameDescription
metadataName string

A fully-qualified path representing Metadata resource.

Returns
TypeDescription
string | number

{string} A string representing the property.

metadataPath(property)

metadataPath(property: string): string;

Return a fully-qualified metadata resource name string.

Parameter
NameDescription
property string
Returns
TypeDescription
string

{string} Resource name string.

runPivotReport(request, options)

runPivotReport(request?: protos.google.analytics.data.v1beta.IRunPivotReportRequest, options?: CallOptions): Promise<[
        protos.google.analytics.data.v1beta.IRunPivotReportResponse,
        protos.google.analytics.data.v1beta.IRunPivotReportRequest | undefined,
        {} | undefined
    ]>;

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.

Parameters
NameDescription
request protos.google.analytics.data.v1beta.IRunPivotReportRequest

The request object that will be sent.

options CallOptions

Call options. See CallOptions for more details.

Returns
TypeDescription
Promise<[ protos.google.analytics.data.v1beta.IRunPivotReportResponse, protos.google.analytics.data.v1beta.IRunPivotReportRequest | undefined, {} | undefined ]>

{Promise} - The promise which resolves to an array. The first element of the array is an object representing . Please see the [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) for more details and examples.

Example

  /**
   * This snippet has been automatically generated and should be regarded as a code template only.
   * It will require modifications to work.
   * It may require correct/in-range values for request initialization.
   * TODO(developer): Uncomment these variables before running the sample.
   */
  /**
   *  A Google Analytics GA4 property identifier whose events are tracked.
   *  Specified in the URL path and not the body. To learn more, see where to
   *  find your Property
   *  ID (https://developers.google.com/analytics/devguides/reporting/data/v1/property-id).
   *  Within a batch request, this property should either be unspecified or
   *  consistent with the batch-level property.
   *  Example: properties/1234
   */
  // const property = 'abc123'
  /**
   *  The dimensions requested. All defined dimensions must be used by one of the
   *  following: dimension_expression, dimension_filter, pivots, order_bys.
   */
  // const dimensions = 1234
  /**
   *  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.
   */
  // const metrics = 1234
  /**
   *  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.
   */
  // const dateRanges = 1234
  /**
   *  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.
   */
  // const pivots = 1234
  /**
   *  The filter clause of dimensions. Dimensions must be requested to be used in
   *  this filter. Metrics cannot be used in this filter.
   */
  // const dimensionFilter = {}
  /**
   *  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.
   */
  // const metricFilter = {}
  /**
   *  A currency code in ISO4217 format, such as "AED", "USD", "JPY".
   *  If the field is empty, the report uses the property's default currency.
   */
  // const currencyCode = 'abc123'
  /**
   *  Cohort group associated with this request. If there is a cohort group
   *  in the request the 'cohort' dimension must be present.
   */
  // const cohortSpec = {}
  /**
   *  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.
   */
  // const keepEmptyRows = true
  /**
   *  Toggles whether to return the current state of this Analytics Property's
   *  quota. Quota is returned in PropertyQuota (#PropertyQuota).
   */
  // const returnPropertyQuota = true

  // Imports the Data library
  const {BetaAnalyticsDataClient} = require('@google-analytics/data').v1beta;

  // Instantiates a client
  const dataClient = new BetaAnalyticsDataClient();

  async function callRunPivotReport() {
    // Construct request
    const request = {
    };

    // Run request
    const response = await dataClient.runPivotReport(request);
    console.log(response);
  }

  callRunPivotReport();

runPivotReport(request, options, callback)

runPivotReport(request: protos.google.analytics.data.v1beta.IRunPivotReportRequest, options: CallOptions, callback: Callback<protos.google.analytics.data.v1beta.IRunPivotReportResponse, protos.google.analytics.data.v1beta.IRunPivotReportRequest | null | undefined, {} | null | undefined>): void;
Parameters
NameDescription
request protos.google.analytics.data.v1beta.IRunPivotReportRequest
options CallOptions
callback Callback<protos.google.analytics.data.v1beta.IRunPivotReportResponse, protos.google.analytics.data.v1beta.IRunPivotReportRequest | null | undefined, {} | null | undefined>
Returns
TypeDescription
void

runPivotReport(request, callback)

runPivotReport(request: protos.google.analytics.data.v1beta.IRunPivotReportRequest, callback: Callback<protos.google.analytics.data.v1beta.IRunPivotReportResponse, protos.google.analytics.data.v1beta.IRunPivotReportRequest | null | undefined, {} | null | undefined>): void;
Parameters
NameDescription
request protos.google.analytics.data.v1beta.IRunPivotReportRequest
callback Callback<protos.google.analytics.data.v1beta.IRunPivotReportResponse, protos.google.analytics.data.v1beta.IRunPivotReportRequest | null | undefined, {} | null | undefined>
Returns
TypeDescription
void

runRealtimeReport(request, options)

runRealtimeReport(request?: protos.google.analytics.data.v1beta.IRunRealtimeReportRequest, options?: CallOptions): Promise<[
        protos.google.analytics.data.v1beta.IRunRealtimeReportResponse,
        protos.google.analytics.data.v1beta.IRunRealtimeReportRequest | undefined,
        {} | undefined
    ]>;

Returns a customized report of realtime event data for your property. Events appear in realtime reports seconds after they have been sent to the Google Analytics. Realtime reports show events and usage data for the periods of time ranging from the present moment to 30 minutes ago (up to 60 minutes for Google Analytics 360 properties).

For a guide to constructing realtime requests & understanding responses, see [Creating a Realtime Report](https://developers.google.com/analytics/devguides/reporting/data/v1/realtime-basics).

Parameters
NameDescription
request protos.google.analytics.data.v1beta.IRunRealtimeReportRequest

The request object that will be sent.

options CallOptions

Call options. See CallOptions for more details.

Returns
TypeDescription
Promise<[ protos.google.analytics.data.v1beta.IRunRealtimeReportResponse, protos.google.analytics.data.v1beta.IRunRealtimeReportRequest | undefined, {} | undefined ]>

{Promise} - The promise which resolves to an array. The first element of the array is an object representing . Please see the [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) for more details and examples.

Example

  /**
   * This snippet has been automatically generated and should be regarded as a code template only.
   * It will require modifications to work.
   * It may require correct/in-range values for request initialization.
   * TODO(developer): Uncomment these variables before running the sample.
   */
  /**
   *  A Google Analytics GA4 property identifier whose events are tracked.
   *  Specified in the URL path and not the body. To learn more, see where to
   *  find your Property
   *  ID (https://developers.google.com/analytics/devguides/reporting/data/v1/property-id).
   *  Example: properties/1234
   */
  // const property = 'abc123'
  /**
   *  The dimensions requested and displayed.
   */
  // const dimensions = 1234
  /**
   *  The metrics requested and displayed.
   */
  // const metrics = 1234
  /**
   *  The filter clause of dimensions. Metrics cannot be used in this filter.
   */
  // const dimensionFilter = {}
  /**
   *  The filter clause of metrics. Applied at post aggregation phase, similar to
   *  SQL having-clause. Dimensions cannot be used in this filter.
   */
  // const metricFilter = {}
  /**
   *  The number of rows to return. If unspecified, 10,000 rows are returned. The
   *  API returns a maximum of 100,000 rows per request, no matter how many you
   *  ask for. `limit` must be positive.
   *  The API can also return fewer rows than the requested `limit`, if there
   *  aren't as many dimension values as the `limit`. For instance, there are
   *  fewer than 300 possible values for the dimension `country`, so when
   *  reporting on only `country`, you can't get more than 300 rows, even if you
   *  set `limit` to a higher value.
   */
  // const limit = 1234
  /**
   *  Aggregation of metrics. Aggregated metric values will be shown in rows
   *  where the dimension_values are set to "RESERVED_(MetricAggregation)".
   */
  // const metricAggregations = 1234
  /**
   *  Specifies how rows are ordered in the response.
   */
  // const orderBys = 1234
  /**
   *  Toggles whether to return the current state of this Analytics Property's
   *  Realtime quota. Quota is returned in PropertyQuota (#PropertyQuota).
   */
  // const returnPropertyQuota = true
  /**
   *  The minute ranges of event data to read. If unspecified, one minute range
   *  for the last 30 minutes will be used. If multiple minute ranges are
   *  requested, each response row will contain a zero based minute range index.
   *  If two minute ranges overlap, the event data for the overlapping minutes is
   *  included in the response rows for both minute ranges.
   */
  // const minuteRanges = 1234

  // Imports the Data library
  const {BetaAnalyticsDataClient} = require('@google-analytics/data').v1beta;

  // Instantiates a client
  const dataClient = new BetaAnalyticsDataClient();

  async function callRunRealtimeReport() {
    // Construct request
    const request = {
    };

    // Run request
    const response = await dataClient.runRealtimeReport(request);
    console.log(response);
  }

  callRunRealtimeReport();

runRealtimeReport(request, options, callback)

runRealtimeReport(request: protos.google.analytics.data.v1beta.IRunRealtimeReportRequest, options: CallOptions, callback: Callback<protos.google.analytics.data.v1beta.IRunRealtimeReportResponse, protos.google.analytics.data.v1beta.IRunRealtimeReportRequest | null | undefined, {} | null | undefined>): void;
Parameters
NameDescription
request protos.google.analytics.data.v1beta.IRunRealtimeReportRequest
options CallOptions
callback Callback<protos.google.analytics.data.v1beta.IRunRealtimeReportResponse, protos.google.analytics.data.v1beta.IRunRealtimeReportRequest | null | undefined, {} | null | undefined>
Returns
TypeDescription
void

runRealtimeReport(request, callback)

runRealtimeReport(request: protos.google.analytics.data.v1beta.IRunRealtimeReportRequest, callback: Callback<protos.google.analytics.data.v1beta.IRunRealtimeReportResponse, protos.google.analytics.data.v1beta.IRunRealtimeReportRequest | null | undefined, {} | null | undefined>): void;
Parameters
NameDescription
request protos.google.analytics.data.v1beta.IRunRealtimeReportRequest
callback Callback<protos.google.analytics.data.v1beta.IRunRealtimeReportResponse, protos.google.analytics.data.v1beta.IRunRealtimeReportRequest | null | undefined, {} | null | undefined>
Returns
TypeDescription
void

runReport(request, options)

runReport(request?: protos.google.analytics.data.v1beta.IRunReportRequest, options?: CallOptions): Promise<[
        protos.google.analytics.data.v1beta.IRunReportResponse,
        protos.google.analytics.data.v1beta.IRunReportRequest | undefined,
        {} | undefined
    ]>;

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.

For a guide to constructing requests & understanding responses, see [Creating a Report](https://developers.google.com/analytics/devguides/reporting/data/v1/basics).

Parameters
NameDescription
request protos.google.analytics.data.v1beta.IRunReportRequest

The request object that will be sent.

options CallOptions

Call options. See CallOptions for more details.

Returns
TypeDescription
Promise<[ protos.google.analytics.data.v1beta.IRunReportResponse, protos.google.analytics.data.v1beta.IRunReportRequest | undefined, {} | undefined ]>

{Promise} - The promise which resolves to an array. The first element of the array is an object representing . Please see the [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) for more details and examples.

Example

  /**
   * This snippet has been automatically generated and should be regarded as a code template only.
   * It will require modifications to work.
   * It may require correct/in-range values for request initialization.
   * TODO(developer): Uncomment these variables before running the sample.
   */
  /**
   *  A Google Analytics GA4 property identifier whose events are tracked.
   *  Specified in the URL path and not the body. To learn more, see where to
   *  find your Property
   *  ID (https://developers.google.com/analytics/devguides/reporting/data/v1/property-id).
   *  Within a batch request, this property should either be unspecified or
   *  consistent with the batch-level property.
   *  Example: properties/1234
   */
  // const property = 'abc123'
  /**
   *  The dimensions requested and displayed.
   */
  // const dimensions = 1234
  /**
   *  The metrics requested and displayed.
   */
  // const metrics = 1234
  /**
   *  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.
   */
  // const dateRanges = 1234
  /**
   *  Dimension filters allow you to ask for only specific dimension values in
   *  the report. To learn more, see Fundamentals of Dimension
   *  Filters (https://developers.google.com/analytics/devguides/reporting/data/v1/basics#dimension_filters)
   *  for examples. Metrics cannot be used in this filter.
   */
  // const dimensionFilter = {}
  /**
   *  The filter clause of metrics. Applied after aggregating the report's rows,
   *  similar to SQL having-clause. Dimensions cannot be used in this filter.
   */
  // const metricFilter = {}
  /**
   *  The row count of the start row. The first row is counted as row 0.
   *  When paging, the first request does not specify offset; or equivalently,
   *  sets offset to 0; the first request returns the first `limit` of rows. The
   *  second request sets offset to the `limit` of the first request; the second
   *  request returns the second `limit` of rows.
   *  To learn more about this pagination parameter, see
   *  Pagination (https://developers.google.com/analytics/devguides/reporting/data/v1/basics#pagination).
   */
  // const offset = 1234
  /**
   *  The number of rows to return. If unspecified, 10,000 rows are returned. The
   *  API returns a maximum of 100,000 rows per request, no matter how many you
   *  ask for. `limit` must be positive.
   *  The API can also return fewer rows than the requested `limit`, if there
   *  aren't as many dimension values as the `limit`. For instance, there are
   *  fewer than 300 possible values for the dimension `country`, so when
   *  reporting on only `country`, you can't get more than 300 rows, even if you
   *  set `limit` to a higher value.
   *  To learn more about this pagination parameter, see
   *  Pagination (https://developers.google.com/analytics/devguides/reporting/data/v1/basics#pagination).
   */
  // const limit = 1234
  /**
   *  Aggregation of metrics. Aggregated metric values will be shown in rows
   *  where the dimension_values are set to "RESERVED_(MetricAggregation)".
   */
  // const metricAggregations = 1234
  /**
   *  Specifies how rows are ordered in the response.
   */
  // const orderBys = 1234
  /**
   *  A currency code in ISO4217 format, such as "AED", "USD", "JPY".
   *  If the field is empty, the report uses the property's default currency.
   */
  // const currencyCode = 'abc123'
  /**
   *  Cohort group associated with this request. If there is a cohort group
   *  in the request the 'cohort' dimension must be present.
   */
  // const cohortSpec = {}
  /**
   *  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.
   */
  // const keepEmptyRows = true
  /**
   *  Toggles whether to return the current state of this Analytics Property's
   *  quota. Quota is returned in PropertyQuota (#PropertyQuota).
   */
  // const returnPropertyQuota = true

  // Imports the Data library
  const {BetaAnalyticsDataClient} = require('@google-analytics/data').v1beta;

  // Instantiates a client
  const dataClient = new BetaAnalyticsDataClient();

  async function callRunReport() {
    // Construct request
    const request = {
    };

    // Run request
    const response = await dataClient.runReport(request);
    console.log(response);
  }

  callRunReport();

runReport(request, options, callback)

runReport(request: protos.google.analytics.data.v1beta.IRunReportRequest, options: CallOptions, callback: Callback<protos.google.analytics.data.v1beta.IRunReportResponse, protos.google.analytics.data.v1beta.IRunReportRequest | null | undefined, {} | null | undefined>): void;
Parameters
NameDescription
request protos.google.analytics.data.v1beta.IRunReportRequest
options CallOptions
callback Callback<protos.google.analytics.data.v1beta.IRunReportResponse, protos.google.analytics.data.v1beta.IRunReportRequest | null | undefined, {} | null | undefined>
Returns
TypeDescription
void

runReport(request, callback)

runReport(request: protos.google.analytics.data.v1beta.IRunReportRequest, callback: Callback<protos.google.analytics.data.v1beta.IRunReportResponse, protos.google.analytics.data.v1beta.IRunReportRequest | null | undefined, {} | null | undefined>): void;
Parameters
NameDescription
request protos.google.analytics.data.v1beta.IRunReportRequest
callback Callback<protos.google.analytics.data.v1beta.IRunReportResponse, protos.google.analytics.data.v1beta.IRunReportRequest | null | undefined, {} | null | undefined>
Returns
TypeDescription
void