Show / Hide Table of Contents

Class BetaAnalyticsDataClient

BetaAnalyticsData client wrapper, for convenient use.

Inheritance
System.Object
BetaAnalyticsDataClient
BetaAnalyticsDataClientImpl
Inherited Members
System.Object.GetHashCode()
System.Object.GetType()
System.Object.MemberwiseClone()
System.Object.ToString()
Namespace: Google.Analytics.Data.V1Beta
Assembly: Google.Analytics.Data.V1Beta.dll
Syntax
public abstract class BetaAnalyticsDataClient
Remarks

Google Analytics reporting data service.

Properties

DefaultEndpoint

The default endpoint for the BetaAnalyticsData service, which is a host of "analyticsdata.googleapis.com" and a port of 443.

Declaration
public static string DefaultEndpoint { get; }
Property Value
Type Description
System.String

DefaultScopes

The default BetaAnalyticsData scopes.

Declaration
public static IReadOnlyList<string> DefaultScopes { get; }
Property Value
Type Description
System.Collections.Generic.IReadOnlyList<System.String>
Remarks

The default BetaAnalyticsData scopes are:

  • https://www.googleapis.com/auth/analytics
  • https://www.googleapis.com/auth/analytics.readonly

GrpcClient

The underlying gRPC BetaAnalyticsData client

Declaration
public virtual BetaAnalyticsData.BetaAnalyticsDataClient GrpcClient { get; }
Property Value
Type Description
BetaAnalyticsData.BetaAnalyticsDataClient

Methods

BatchRunPivotReports(BatchRunPivotReportsRequest, CallSettings)

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

Declaration
public virtual BatchRunPivotReportsResponse BatchRunPivotReports(BatchRunPivotReportsRequest request, CallSettings callSettings = null)
Parameters
Type Name Description
BatchRunPivotReportsRequest request

The request object containing all of the parameters for the API call.

Google.Api.Gax.Grpc.CallSettings callSettings

If not null, applies overrides to this RPC call.

Returns
Type Description
BatchRunPivotReportsResponse

The RPC response.

Sample code
// Create client
BetaAnalyticsDataClient betaAnalyticsDataClient = BetaAnalyticsDataClient.Create();
// Initialize request argument(s)
BatchRunPivotReportsRequest request = new BatchRunPivotReportsRequest
{
    Property = "",
    Requests =
    {
        new RunPivotReportRequest(),
    },
};
// Make the request
BatchRunPivotReportsResponse response = betaAnalyticsDataClient.BatchRunPivotReports(request);

BatchRunPivotReportsAsync(BatchRunPivotReportsRequest, CallSettings)

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

Declaration
public virtual Task<BatchRunPivotReportsResponse> BatchRunPivotReportsAsync(BatchRunPivotReportsRequest request, CallSettings callSettings = null)
Parameters
Type Name Description
BatchRunPivotReportsRequest request

The request object containing all of the parameters for the API call.

Google.Api.Gax.Grpc.CallSettings callSettings

If not null, applies overrides to this RPC call.

Returns
Type Description
System.Threading.Tasks.Task<BatchRunPivotReportsResponse>

A Task containing the RPC response.

Sample code
// Create client
BetaAnalyticsDataClient betaAnalyticsDataClient = await BetaAnalyticsDataClient.CreateAsync();
// Initialize request argument(s)
BatchRunPivotReportsRequest request = new BatchRunPivotReportsRequest
{
    Property = "",
    Requests =
    {
        new RunPivotReportRequest(),
    },
};
// Make the request
BatchRunPivotReportsResponse response = await betaAnalyticsDataClient.BatchRunPivotReportsAsync(request);

BatchRunPivotReportsAsync(BatchRunPivotReportsRequest, CancellationToken)

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

Declaration
public virtual Task<BatchRunPivotReportsResponse> BatchRunPivotReportsAsync(BatchRunPivotReportsRequest request, CancellationToken cancellationToken)
Parameters
Type Name Description
BatchRunPivotReportsRequest request

The request object containing all of the parameters for the API call.

System.Threading.CancellationToken cancellationToken

A System.Threading.CancellationToken to use for this RPC.

Returns
Type Description
System.Threading.Tasks.Task<BatchRunPivotReportsResponse>

A Task containing the RPC response.

Sample code
// Create client
BetaAnalyticsDataClient betaAnalyticsDataClient = await BetaAnalyticsDataClient.CreateAsync();
// Initialize request argument(s)
BatchRunPivotReportsRequest request = new BatchRunPivotReportsRequest
{
    Property = "",
    Requests =
    {
        new RunPivotReportRequest(),
    },
};
// Make the request
BatchRunPivotReportsResponse response = await betaAnalyticsDataClient.BatchRunPivotReportsAsync(request);

BatchRunReports(BatchRunReportsRequest, CallSettings)

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

Declaration
public virtual BatchRunReportsResponse BatchRunReports(BatchRunReportsRequest request, CallSettings callSettings = null)
Parameters
Type Name Description
BatchRunReportsRequest request

The request object containing all of the parameters for the API call.

Google.Api.Gax.Grpc.CallSettings callSettings

If not null, applies overrides to this RPC call.

Returns
Type Description
BatchRunReportsResponse

The RPC response.

Sample code
// Create client
BetaAnalyticsDataClient betaAnalyticsDataClient = BetaAnalyticsDataClient.Create();
// Initialize request argument(s)
BatchRunReportsRequest request = new BatchRunReportsRequest
{
    Property = "",
    Requests =
    {
        new RunReportRequest(),
    },
};
// Make the request
BatchRunReportsResponse response = betaAnalyticsDataClient.BatchRunReports(request);

BatchRunReportsAsync(BatchRunReportsRequest, CallSettings)

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

Declaration
public virtual Task<BatchRunReportsResponse> BatchRunReportsAsync(BatchRunReportsRequest request, CallSettings callSettings = null)
Parameters
Type Name Description
BatchRunReportsRequest request

The request object containing all of the parameters for the API call.

Google.Api.Gax.Grpc.CallSettings callSettings

If not null, applies overrides to this RPC call.

Returns
Type Description
System.Threading.Tasks.Task<BatchRunReportsResponse>

A Task containing the RPC response.

Sample code
// Create client
BetaAnalyticsDataClient betaAnalyticsDataClient = await BetaAnalyticsDataClient.CreateAsync();
// Initialize request argument(s)
BatchRunReportsRequest request = new BatchRunReportsRequest
{
    Property = "",
    Requests =
    {
        new RunReportRequest(),
    },
};
// Make the request
BatchRunReportsResponse response = await betaAnalyticsDataClient.BatchRunReportsAsync(request);

BatchRunReportsAsync(BatchRunReportsRequest, CancellationToken)

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

Declaration
public virtual Task<BatchRunReportsResponse> BatchRunReportsAsync(BatchRunReportsRequest request, CancellationToken cancellationToken)
Parameters
Type Name Description
BatchRunReportsRequest request

The request object containing all of the parameters for the API call.

System.Threading.CancellationToken cancellationToken

A System.Threading.CancellationToken to use for this RPC.

Returns
Type Description
System.Threading.Tasks.Task<BatchRunReportsResponse>

A Task containing the RPC response.

Sample code
// Create client
BetaAnalyticsDataClient betaAnalyticsDataClient = await BetaAnalyticsDataClient.CreateAsync();
// Initialize request argument(s)
BatchRunReportsRequest request = new BatchRunReportsRequest
{
    Property = "",
    Requests =
    {
        new RunReportRequest(),
    },
};
// Make the request
BatchRunReportsResponse response = await betaAnalyticsDataClient.BatchRunReportsAsync(request);

CheckCompatibility(CheckCompatibilityRequest, CallSettings)

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.

Declaration
public virtual CheckCompatibilityResponse CheckCompatibility(CheckCompatibilityRequest request, CallSettings callSettings = null)
Parameters
Type Name Description
CheckCompatibilityRequest request

The request object containing all of the parameters for the API call.

Google.Api.Gax.Grpc.CallSettings callSettings

If not null, applies overrides to this RPC call.

Returns
Type Description
CheckCompatibilityResponse

The RPC response.

Sample code
// Create client
BetaAnalyticsDataClient betaAnalyticsDataClient = BetaAnalyticsDataClient.Create();
// Initialize request argument(s)
CheckCompatibilityRequest request = new CheckCompatibilityRequest
{
    Property = "",
    Dimensions = { new Dimension(), },
    Metrics = { new Metric(), },
    DimensionFilter = new FilterExpression(),
    MetricFilter = new FilterExpression(),
    CompatibilityFilter = Compatibility.Unspecified,
};
// Make the request
CheckCompatibilityResponse response = betaAnalyticsDataClient.CheckCompatibility(request);

CheckCompatibilityAsync(CheckCompatibilityRequest, CallSettings)

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.

Declaration
public virtual Task<CheckCompatibilityResponse> CheckCompatibilityAsync(CheckCompatibilityRequest request, CallSettings callSettings = null)
Parameters
Type Name Description
CheckCompatibilityRequest request

The request object containing all of the parameters for the API call.

Google.Api.Gax.Grpc.CallSettings callSettings

If not null, applies overrides to this RPC call.

Returns
Type Description
System.Threading.Tasks.Task<CheckCompatibilityResponse>

A Task containing the RPC response.

Sample code
// Create client
BetaAnalyticsDataClient betaAnalyticsDataClient = await BetaAnalyticsDataClient.CreateAsync();
// Initialize request argument(s)
CheckCompatibilityRequest request = new CheckCompatibilityRequest
{
    Property = "",
    Dimensions = { new Dimension(), },
    Metrics = { new Metric(), },
    DimensionFilter = new FilterExpression(),
    MetricFilter = new FilterExpression(),
    CompatibilityFilter = Compatibility.Unspecified,
};
// Make the request
CheckCompatibilityResponse response = await betaAnalyticsDataClient.CheckCompatibilityAsync(request);

CheckCompatibilityAsync(CheckCompatibilityRequest, CancellationToken)

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.

Declaration
public virtual Task<CheckCompatibilityResponse> CheckCompatibilityAsync(CheckCompatibilityRequest request, CancellationToken cancellationToken)
Parameters
Type Name Description
CheckCompatibilityRequest request

The request object containing all of the parameters for the API call.

System.Threading.CancellationToken cancellationToken

A System.Threading.CancellationToken to use for this RPC.

Returns
Type Description
System.Threading.Tasks.Task<CheckCompatibilityResponse>

A Task containing the RPC response.

Sample code
// Create client
BetaAnalyticsDataClient betaAnalyticsDataClient = await BetaAnalyticsDataClient.CreateAsync();
// Initialize request argument(s)
CheckCompatibilityRequest request = new CheckCompatibilityRequest
{
    Property = "",
    Dimensions = { new Dimension(), },
    Metrics = { new Metric(), },
    DimensionFilter = new FilterExpression(),
    MetricFilter = new FilterExpression(),
    CompatibilityFilter = Compatibility.Unspecified,
};
// Make the request
CheckCompatibilityResponse response = await betaAnalyticsDataClient.CheckCompatibilityAsync(request);

Create()

Synchronously creates a BetaAnalyticsDataClient using the default credentials, endpoint and settings. To specify custom credentials or other settings, use BetaAnalyticsDataClientBuilder.

Declaration
public static BetaAnalyticsDataClient Create()
Returns
Type Description
BetaAnalyticsDataClient

The created BetaAnalyticsDataClient.

CreateAsync(CancellationToken)

Asynchronously creates a BetaAnalyticsDataClient using the default credentials, endpoint and settings. To specify custom credentials or other settings, use BetaAnalyticsDataClientBuilder.

Declaration
public static Task<BetaAnalyticsDataClient> CreateAsync(CancellationToken cancellationToken = default(CancellationToken))
Parameters
Type Name Description
System.Threading.CancellationToken cancellationToken

The System.Threading.CancellationToken to use while creating the client.

Returns
Type Description
System.Threading.Tasks.Task<BetaAnalyticsDataClient>

The task representing the created BetaAnalyticsDataClient.

GetMetadata(GetMetadataRequest, CallSettings)

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.

Declaration
public virtual Metadata GetMetadata(GetMetadataRequest request, CallSettings callSettings = null)
Parameters
Type Name Description
GetMetadataRequest request

The request object containing all of the parameters for the API call.

Google.Api.Gax.Grpc.CallSettings callSettings

If not null, applies overrides to this RPC call.

Returns
Type Description
Metadata

The RPC response.

Sample code
// Create client
BetaAnalyticsDataClient betaAnalyticsDataClient = BetaAnalyticsDataClient.Create();
// Initialize request argument(s)
GetMetadataRequest request = new GetMetadataRequest
{
    MetadataName = MetadataName.FromProperty("[PROPERTY]"),
};
// Make the request
Metadata response = betaAnalyticsDataClient.GetMetadata(request);

GetMetadata(MetadataName, CallSettings)

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.

Declaration
public virtual Metadata GetMetadata(MetadataName name, CallSettings callSettings = null)
Parameters
Type Name Description
MetadataName name

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.

Google.Api.Gax.Grpc.CallSettings callSettings

If not null, applies overrides to this RPC call.

Returns
Type Description
Metadata

The RPC response.

Sample code
// Create client
BetaAnalyticsDataClient betaAnalyticsDataClient = BetaAnalyticsDataClient.Create();
// Initialize request argument(s)
MetadataName name = MetadataName.FromProperty("[PROPERTY]");
// Make the request
Metadata response = betaAnalyticsDataClient.GetMetadata(name);

GetMetadata(String, CallSettings)

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.

Declaration
public virtual Metadata GetMetadata(string name, CallSettings callSettings = null)
Parameters
Type Name Description
System.String name

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.

Google.Api.Gax.Grpc.CallSettings callSettings

If not null, applies overrides to this RPC call.

Returns
Type Description
Metadata

The RPC response.

Sample code
// Create client
BetaAnalyticsDataClient betaAnalyticsDataClient = BetaAnalyticsDataClient.Create();
// Initialize request argument(s)
string name = "properties/[PROPERTY]/metadata";
// Make the request
Metadata response = betaAnalyticsDataClient.GetMetadata(name);

GetMetadataAsync(GetMetadataRequest, CallSettings)

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.

Declaration
public virtual Task<Metadata> GetMetadataAsync(GetMetadataRequest request, CallSettings callSettings = null)
Parameters
Type Name Description
GetMetadataRequest request

The request object containing all of the parameters for the API call.

Google.Api.Gax.Grpc.CallSettings callSettings

If not null, applies overrides to this RPC call.

Returns
Type Description
System.Threading.Tasks.Task<Metadata>

A Task containing the RPC response.

Sample code
// Create client
BetaAnalyticsDataClient betaAnalyticsDataClient = await BetaAnalyticsDataClient.CreateAsync();
// Initialize request argument(s)
GetMetadataRequest request = new GetMetadataRequest
{
    MetadataName = MetadataName.FromProperty("[PROPERTY]"),
};
// Make the request
Metadata response = await betaAnalyticsDataClient.GetMetadataAsync(request);

GetMetadataAsync(GetMetadataRequest, CancellationToken)

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.

Declaration
public virtual Task<Metadata> GetMetadataAsync(GetMetadataRequest request, CancellationToken cancellationToken)
Parameters
Type Name Description
GetMetadataRequest request

The request object containing all of the parameters for the API call.

System.Threading.CancellationToken cancellationToken

A System.Threading.CancellationToken to use for this RPC.

Returns
Type Description
System.Threading.Tasks.Task<Metadata>

A Task containing the RPC response.

Sample code
// Create client
BetaAnalyticsDataClient betaAnalyticsDataClient = await BetaAnalyticsDataClient.CreateAsync();
// Initialize request argument(s)
GetMetadataRequest request = new GetMetadataRequest
{
    MetadataName = MetadataName.FromProperty("[PROPERTY]"),
};
// Make the request
Metadata response = await betaAnalyticsDataClient.GetMetadataAsync(request);

GetMetadataAsync(MetadataName, CallSettings)

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.

Declaration
public virtual Task<Metadata> GetMetadataAsync(MetadataName name, CallSettings callSettings = null)
Parameters
Type Name Description
MetadataName name

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.

Google.Api.Gax.Grpc.CallSettings callSettings

If not null, applies overrides to this RPC call.

Returns
Type Description
System.Threading.Tasks.Task<Metadata>

A Task containing the RPC response.

Sample code
// Create client
BetaAnalyticsDataClient betaAnalyticsDataClient = await BetaAnalyticsDataClient.CreateAsync();
// Initialize request argument(s)
MetadataName name = MetadataName.FromProperty("[PROPERTY]");
// Make the request
Metadata response = await betaAnalyticsDataClient.GetMetadataAsync(name);

GetMetadataAsync(MetadataName, CancellationToken)

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.

Declaration
public virtual Task<Metadata> GetMetadataAsync(MetadataName name, CancellationToken cancellationToken)
Parameters
Type Name Description
MetadataName name

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.

System.Threading.CancellationToken cancellationToken

A System.Threading.CancellationToken to use for this RPC.

Returns
Type Description
System.Threading.Tasks.Task<Metadata>

A Task containing the RPC response.

Sample code
// Create client
BetaAnalyticsDataClient betaAnalyticsDataClient = await BetaAnalyticsDataClient.CreateAsync();
// Initialize request argument(s)
MetadataName name = MetadataName.FromProperty("[PROPERTY]");
// Make the request
Metadata response = await betaAnalyticsDataClient.GetMetadataAsync(name);

GetMetadataAsync(String, CallSettings)

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.

Declaration
public virtual Task<Metadata> GetMetadataAsync(string name, CallSettings callSettings = null)
Parameters
Type Name Description
System.String name

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.

Google.Api.Gax.Grpc.CallSettings callSettings

If not null, applies overrides to this RPC call.

Returns
Type Description
System.Threading.Tasks.Task<Metadata>

A Task containing the RPC response.

Sample code
// Create client
BetaAnalyticsDataClient betaAnalyticsDataClient = await BetaAnalyticsDataClient.CreateAsync();
// Initialize request argument(s)
string name = "properties/[PROPERTY]/metadata";
// Make the request
Metadata response = await betaAnalyticsDataClient.GetMetadataAsync(name);

GetMetadataAsync(String, CancellationToken)

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.

Declaration
public virtual Task<Metadata> GetMetadataAsync(string name, CancellationToken cancellationToken)
Parameters
Type Name Description
System.String name

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.

System.Threading.CancellationToken cancellationToken

A System.Threading.CancellationToken to use for this RPC.

Returns
Type Description
System.Threading.Tasks.Task<Metadata>

A Task containing the RPC response.

Sample code
// Create client
BetaAnalyticsDataClient betaAnalyticsDataClient = await BetaAnalyticsDataClient.CreateAsync();
// Initialize request argument(s)
string name = "properties/[PROPERTY]/metadata";
// Make the request
Metadata response = await betaAnalyticsDataClient.GetMetadataAsync(name);

RunPivotReport(RunPivotReportRequest, CallSettings)

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.

Declaration
public virtual RunPivotReportResponse RunPivotReport(RunPivotReportRequest request, CallSettings callSettings = null)
Parameters
Type Name Description
RunPivotReportRequest request

The request object containing all of the parameters for the API call.

Google.Api.Gax.Grpc.CallSettings callSettings

If not null, applies overrides to this RPC call.

Returns
Type Description
RunPivotReportResponse

The RPC response.

Sample code
// Create client
BetaAnalyticsDataClient betaAnalyticsDataClient = BetaAnalyticsDataClient.Create();
// Initialize request argument(s)
RunPivotReportRequest request = new RunPivotReportRequest
{
    Property = "",
    Dimensions = { new Dimension(), },
    Metrics = { new Metric(), },
    DateRanges = { new DateRange(), },
    Pivots = { new Pivot(), },
    DimensionFilter = new FilterExpression(),
    MetricFilter = new FilterExpression(),
    CurrencyCode = "",
    CohortSpec = new CohortSpec(),
    KeepEmptyRows = false,
    ReturnPropertyQuota = false,
};
// Make the request
RunPivotReportResponse response = betaAnalyticsDataClient.RunPivotReport(request);

RunPivotReportAsync(RunPivotReportRequest, CallSettings)

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.

Declaration
public virtual Task<RunPivotReportResponse> RunPivotReportAsync(RunPivotReportRequest request, CallSettings callSettings = null)
Parameters
Type Name Description
RunPivotReportRequest request

The request object containing all of the parameters for the API call.

Google.Api.Gax.Grpc.CallSettings callSettings

If not null, applies overrides to this RPC call.

Returns
Type Description
System.Threading.Tasks.Task<RunPivotReportResponse>

A Task containing the RPC response.

Sample code
// Create client
BetaAnalyticsDataClient betaAnalyticsDataClient = await BetaAnalyticsDataClient.CreateAsync();
// Initialize request argument(s)
RunPivotReportRequest request = new RunPivotReportRequest
{
    Property = "",
    Dimensions = { new Dimension(), },
    Metrics = { new Metric(), },
    DateRanges = { new DateRange(), },
    Pivots = { new Pivot(), },
    DimensionFilter = new FilterExpression(),
    MetricFilter = new FilterExpression(),
    CurrencyCode = "",
    CohortSpec = new CohortSpec(),
    KeepEmptyRows = false,
    ReturnPropertyQuota = false,
};
// Make the request
RunPivotReportResponse response = await betaAnalyticsDataClient.RunPivotReportAsync(request);

RunPivotReportAsync(RunPivotReportRequest, CancellationToken)

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.

Declaration
public virtual Task<RunPivotReportResponse> RunPivotReportAsync(RunPivotReportRequest request, CancellationToken cancellationToken)
Parameters
Type Name Description
RunPivotReportRequest request

The request object containing all of the parameters for the API call.

System.Threading.CancellationToken cancellationToken

A System.Threading.CancellationToken to use for this RPC.

Returns
Type Description
System.Threading.Tasks.Task<RunPivotReportResponse>

A Task containing the RPC response.

Sample code
// Create client
BetaAnalyticsDataClient betaAnalyticsDataClient = await BetaAnalyticsDataClient.CreateAsync();
// Initialize request argument(s)
RunPivotReportRequest request = new RunPivotReportRequest
{
    Property = "",
    Dimensions = { new Dimension(), },
    Metrics = { new Metric(), },
    DateRanges = { new DateRange(), },
    Pivots = { new Pivot(), },
    DimensionFilter = new FilterExpression(),
    MetricFilter = new FilterExpression(),
    CurrencyCode = "",
    CohortSpec = new CohortSpec(),
    KeepEmptyRows = false,
    ReturnPropertyQuota = false,
};
// Make the request
RunPivotReportResponse response = await betaAnalyticsDataClient.RunPivotReportAsync(request);

RunRealtimeReport(RunRealtimeReportRequest, CallSettings)

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.

Declaration
public virtual RunRealtimeReportResponse RunRealtimeReport(RunRealtimeReportRequest request, CallSettings callSettings = null)
Parameters
Type Name Description
RunRealtimeReportRequest request

The request object containing all of the parameters for the API call.

Google.Api.Gax.Grpc.CallSettings callSettings

If not null, applies overrides to this RPC call.

Returns
Type Description
RunRealtimeReportResponse

The RPC response.

Sample code
// Create client
BetaAnalyticsDataClient betaAnalyticsDataClient = BetaAnalyticsDataClient.Create();
// Initialize request argument(s)
RunRealtimeReportRequest request = new RunRealtimeReportRequest
{
    Property = "",
    Dimensions = { new Dimension(), },
    Metrics = { new Metric(), },
    DimensionFilter = new FilterExpression(),
    MetricFilter = new FilterExpression(),
    Limit = 0L,
    MetricAggregations =
    {
        MetricAggregation.Unspecified,
    },
    OrderBys = { new OrderBy(), },
    ReturnPropertyQuota = false,
    MinuteRanges = { new MinuteRange(), },
};
// Make the request
RunRealtimeReportResponse response = betaAnalyticsDataClient.RunRealtimeReport(request);

RunRealtimeReportAsync(RunRealtimeReportRequest, CallSettings)

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.

Declaration
public virtual Task<RunRealtimeReportResponse> RunRealtimeReportAsync(RunRealtimeReportRequest request, CallSettings callSettings = null)
Parameters
Type Name Description
RunRealtimeReportRequest request

The request object containing all of the parameters for the API call.

Google.Api.Gax.Grpc.CallSettings callSettings

If not null, applies overrides to this RPC call.

Returns
Type Description
System.Threading.Tasks.Task<RunRealtimeReportResponse>

A Task containing the RPC response.

Sample code
// Create client
BetaAnalyticsDataClient betaAnalyticsDataClient = await BetaAnalyticsDataClient.CreateAsync();
// Initialize request argument(s)
RunRealtimeReportRequest request = new RunRealtimeReportRequest
{
    Property = "",
    Dimensions = { new Dimension(), },
    Metrics = { new Metric(), },
    DimensionFilter = new FilterExpression(),
    MetricFilter = new FilterExpression(),
    Limit = 0L,
    MetricAggregations =
    {
        MetricAggregation.Unspecified,
    },
    OrderBys = { new OrderBy(), },
    ReturnPropertyQuota = false,
    MinuteRanges = { new MinuteRange(), },
};
// Make the request
RunRealtimeReportResponse response = await betaAnalyticsDataClient.RunRealtimeReportAsync(request);

RunRealtimeReportAsync(RunRealtimeReportRequest, CancellationToken)

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.

Declaration
public virtual Task<RunRealtimeReportResponse> RunRealtimeReportAsync(RunRealtimeReportRequest request, CancellationToken cancellationToken)
Parameters
Type Name Description
RunRealtimeReportRequest request

The request object containing all of the parameters for the API call.

System.Threading.CancellationToken cancellationToken

A System.Threading.CancellationToken to use for this RPC.

Returns
Type Description
System.Threading.Tasks.Task<RunRealtimeReportResponse>

A Task containing the RPC response.

Sample code
// Create client
BetaAnalyticsDataClient betaAnalyticsDataClient = await BetaAnalyticsDataClient.CreateAsync();
// Initialize request argument(s)
RunRealtimeReportRequest request = new RunRealtimeReportRequest
{
    Property = "",
    Dimensions = { new Dimension(), },
    Metrics = { new Metric(), },
    DimensionFilter = new FilterExpression(),
    MetricFilter = new FilterExpression(),
    Limit = 0L,
    MetricAggregations =
    {
        MetricAggregation.Unspecified,
    },
    OrderBys = { new OrderBy(), },
    ReturnPropertyQuota = false,
    MinuteRanges = { new MinuteRange(), },
};
// Make the request
RunRealtimeReportResponse response = await betaAnalyticsDataClient.RunRealtimeReportAsync(request);

RunReport(RunReportRequest, CallSettings)

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.

Declaration
public virtual RunReportResponse RunReport(RunReportRequest request, CallSettings callSettings = null)
Parameters
Type Name Description
RunReportRequest request

The request object containing all of the parameters for the API call.

Google.Api.Gax.Grpc.CallSettings callSettings

If not null, applies overrides to this RPC call.

Returns
Type Description
RunReportResponse

The RPC response.

Sample code
// Create client
BetaAnalyticsDataClient betaAnalyticsDataClient = BetaAnalyticsDataClient.Create();
// Initialize request argument(s)
RunReportRequest request = new RunReportRequest
{
    Property = "",
    Dimensions = { new Dimension(), },
    Metrics = { new Metric(), },
    DateRanges = { new DateRange(), },
    DimensionFilter = new FilterExpression(),
    MetricFilter = new FilterExpression(),
    Offset = 0L,
    Limit = 0L,
    MetricAggregations =
    {
        MetricAggregation.Unspecified,
    },
    OrderBys = { new OrderBy(), },
    CurrencyCode = "",
    CohortSpec = new CohortSpec(),
    KeepEmptyRows = false,
    ReturnPropertyQuota = false,
};
// Make the request
RunReportResponse response = betaAnalyticsDataClient.RunReport(request);

RunReportAsync(RunReportRequest, CallSettings)

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.

Declaration
public virtual Task<RunReportResponse> RunReportAsync(RunReportRequest request, CallSettings callSettings = null)
Parameters
Type Name Description
RunReportRequest request

The request object containing all of the parameters for the API call.

Google.Api.Gax.Grpc.CallSettings callSettings

If not null, applies overrides to this RPC call.

Returns
Type Description
System.Threading.Tasks.Task<RunReportResponse>

A Task containing the RPC response.

Sample code
// Create client
BetaAnalyticsDataClient betaAnalyticsDataClient = await BetaAnalyticsDataClient.CreateAsync();
// Initialize request argument(s)
RunReportRequest request = new RunReportRequest
{
    Property = "",
    Dimensions = { new Dimension(), },
    Metrics = { new Metric(), },
    DateRanges = { new DateRange(), },
    DimensionFilter = new FilterExpression(),
    MetricFilter = new FilterExpression(),
    Offset = 0L,
    Limit = 0L,
    MetricAggregations =
    {
        MetricAggregation.Unspecified,
    },
    OrderBys = { new OrderBy(), },
    CurrencyCode = "",
    CohortSpec = new CohortSpec(),
    KeepEmptyRows = false,
    ReturnPropertyQuota = false,
};
// Make the request
RunReportResponse response = await betaAnalyticsDataClient.RunReportAsync(request);

RunReportAsync(RunReportRequest, CancellationToken)

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.

Declaration
public virtual Task<RunReportResponse> RunReportAsync(RunReportRequest request, CancellationToken cancellationToken)
Parameters
Type Name Description
RunReportRequest request

The request object containing all of the parameters for the API call.

System.Threading.CancellationToken cancellationToken

A System.Threading.CancellationToken to use for this RPC.

Returns
Type Description
System.Threading.Tasks.Task<RunReportResponse>

A Task containing the RPC response.

Sample code
// Create client
BetaAnalyticsDataClient betaAnalyticsDataClient = await BetaAnalyticsDataClient.CreateAsync();
// Initialize request argument(s)
RunReportRequest request = new RunReportRequest
{
    Property = "",
    Dimensions = { new Dimension(), },
    Metrics = { new Metric(), },
    DateRanges = { new DateRange(), },
    DimensionFilter = new FilterExpression(),
    MetricFilter = new FilterExpression(),
    Offset = 0L,
    Limit = 0L,
    MetricAggregations =
    {
        MetricAggregation.Unspecified,
    },
    OrderBys = { new OrderBy(), },
    CurrencyCode = "",
    CohortSpec = new CohortSpec(),
    KeepEmptyRows = false,
    ReturnPropertyQuota = false,
};
// Make the request
RunReportResponse response = await betaAnalyticsDataClient.RunReportAsync(request);

ShutdownDefaultChannelsAsync()

Shuts down any channels automatically created by Create() and CreateAsync(CancellationToken). Channels which weren't automatically created are not affected.

Declaration
public static Task ShutdownDefaultChannelsAsync()
Returns
Type Description
System.Threading.Tasks.Task

A task representing the asynchronous shutdown operation.

Remarks

After calling this method, further calls to Create() and CreateAsync(CancellationToken) will create new channels, which could in turn be shut down by another call to this method.

In This Article
Back to top