Google Analytics Data V1alpha Client - Class AlphaAnalyticsDataClient (0.14.0)

Reference documentation and code samples for the Google Analytics Data V1alpha Client class AlphaAnalyticsDataClient.

Service Description: Google Analytics reporting data service.

This class provides the ability to make remote calls to the backing service through method calls that map to API methods. Sample code to get started:

$alphaAnalyticsDataClient = new AlphaAnalyticsDataClient();
try {
    $formattedParent = $alphaAnalyticsDataClient->propertyName('[PROPERTY]');
    $audienceList = new AudienceList();
    $operationResponse = $alphaAnalyticsDataClient->createAudienceList($formattedParent, $audienceList);
    $operationResponse->pollUntilComplete();
    if ($operationResponse->operationSucceeded()) {
        $result = $operationResponse->getResult();
        // doSomethingWith($result)
    } else {
        $error = $operationResponse->getError();
        // handleError($error)
    }
    // Alternatively:
    // start the operation, keep the operation name, and resume later
    $operationResponse = $alphaAnalyticsDataClient->createAudienceList($formattedParent, $audienceList);
    $operationName = $operationResponse->getName();
    // ... do other work
    $newOperationResponse = $alphaAnalyticsDataClient->resumeOperation($operationName, 'createAudienceList');
    while (!$newOperationResponse->isDone()) {
        // ... do other work
        $newOperationResponse->reload();
    }
    if ($newOperationResponse->operationSucceeded()) {
        $result = $newOperationResponse->getResult();
        // doSomethingWith($result)
    } else {
        $error = $newOperationResponse->getError();
        // handleError($error)
    }
} finally {
    $alphaAnalyticsDataClient->close();
}

Many parameters require resource names to be formatted in a particular way. To assist with these names, this class includes a format method for each type of name, and additionally a parseName method to extract the individual identifiers contained within formatted names that are returned by the API.

Namespace

Google \ Analytics \ Data \ V1alpha

Methods

__construct

Constructor.

Parameters
NameDescription
options array

Optional. Options for configuring the service API wrapper.

↳ apiEndpoint string

The address of the API remote host. May optionally include the port, formatted as "

↳ credentials string|array|FetchAuthTokenInterface|CredentialsWrapper

The credentials to be used by the client to authorize API calls. This option accepts either a path to a credentials file, or a decoded credentials file as a PHP array. Advanced usage: In addition, this option can also accept a pre-constructed Google\Auth\FetchAuthTokenInterface object or Google\ApiCore\CredentialsWrapper object. Note that when one of these objects are provided, any settings in $credentialsConfig will be ignored.

↳ credentialsConfig array

Options used to configure credentials, including auth token caching, for the client. For a full list of supporting configuration options, see Google\ApiCore\CredentialsWrapper::build() .

↳ disableRetries bool

Determines whether or not retries defined by the client configuration should be disabled. Defaults to false.

↳ clientConfig string|array

Client method configuration, including retry settings. This option can be either a path to a JSON file, or a PHP array containing the decoded JSON data. By default this settings points to the default client config file, which is provided in the resources folder.

↳ transport string|TransportInterface

The transport used for executing network requests. May be either the string rest or grpc. Defaults to grpc if gRPC support is detected on the system. Advanced usage: Additionally, it is possible to pass in an already instantiated Google\ApiCore\Transport\TransportInterface object. Note that when this object is provided, any settings in $transportConfig, and any $apiEndpoint setting, will be ignored.

↳ transportConfig array

Configuration options that will be used to construct the transport. Options for each supported transport type should be passed in a key for that transport. For example: $transportConfig = [ 'grpc' => [...], 'rest' => [...], ]; See the Google\ApiCore\Transport\GrpcTransport::build() and Google\ApiCore\Transport\RestTransport::build() methods for the supported options.

↳ clientCertSource callable

A callable which returns the client cert as a string. This can be used to provide a certificate and private key to the transport layer for mTLS.

createAudienceList

Creates an audience list for later retrieval. This method quickly returns the audience list's resource name and initiates a long running asynchronous request to form an audience list. To list the users in an audience list, first create the audience list through this method and then send the audience resource name to the QueryAudienceList method.

See Creating an Audience List for an introduction to Audience Lists with examples.

An audience list is a snapshot of the users currently in the audience at the time of audience list creation. Creating audience lists for one audience on different days will return different results as users enter and exit the audience.

Audiences in Google Analytics 4 allow you to segment your users in the ways that are important to your business. To learn more, see https://support.google.com/analytics/answer/9267572. Audience lists contain the users in each audience.

This method is introduced at alpha stability with the intention of gathering feedback on syntax and capabilities before entering beta. To give your feedback on this API, complete the Google Analytics Audience Export API Feedback form.

Parameters
NameDescription
parent string

Required. The parent resource where this audience list will be created. Format: properties/{property}

audienceList Google\Analytics\Data\V1alpha\AudienceList

Required. The audience list to create.

optionalArgs array

Optional.

↳ retrySettings RetrySettings|array

Retry settings to use for this call. Can be a Google\ApiCore\RetrySettings object, or an associative array of retry settings parameters. See the documentation on Google\ApiCore\RetrySettings for example usage.

Returns
TypeDescription
Google\ApiCore\OperationResponse
Example
use Google\Analytics\Data\V1alpha\AlphaAnalyticsDataClient;
use Google\Analytics\Data\V1alpha\AudienceDimension;
use Google\Analytics\Data\V1alpha\AudienceList;
use Google\ApiCore\ApiException;
use Google\ApiCore\OperationResponse;
use Google\Rpc\Status;

/**
 * @param string $formattedParent      The parent resource where this audience list will be created.
 *                                     Format: `properties/{property}`
 *                                     Please see {@see AlphaAnalyticsDataClient::propertyName()} for help formatting this field.
 * @param string $audienceListAudience The audience resource name. This resource name identifies the
 *                                     audience being listed and is shared between the Analytics Data & Admin
 *                                     APIs.
 *
 *                                     Format: `properties/{property}/audiences/{audience}`
 */
function create_audience_list_sample(string $formattedParent, string $audienceListAudience): void
{
    // Create a client.
    $alphaAnalyticsDataClient = new AlphaAnalyticsDataClient();

    // Prepare any non-scalar elements to be passed along with the request.
    $audienceListDimensions = [new AudienceDimension()];
    $audienceList = (new AudienceList())
        ->setAudience($audienceListAudience)
        ->setDimensions($audienceListDimensions);

    // Call the API and handle any network failures.
    try {
        /** @var OperationResponse $response */
        $response = $alphaAnalyticsDataClient->createAudienceList($formattedParent, $audienceList);
        $response->pollUntilComplete();

        if ($response->operationSucceeded()) {
            /** @var AudienceList $result */
            $result = $response->getResult();
            printf('Operation successful with response data: %s' . PHP_EOL, $result->serializeToJsonString());
        } else {
            /** @var Status $error */
            $error = $response->getError();
            printf('Operation failed with error data: %s' . PHP_EOL, $error->serializeToJsonString());
        }
    } catch (ApiException $ex) {
        printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage());
    }
}

/**
 * Helper to execute the sample.
 *
 * This sample 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.
 *  - It may require specifying regional endpoints when creating the service client,
 *    please see the apiEndpoint client configuration option for more details.
 */
function callSample(): void
{
    $formattedParent = AlphaAnalyticsDataClient::propertyName('[PROPERTY]');
    $audienceListAudience = '[AUDIENCE]';

    create_audience_list_sample($formattedParent, $audienceListAudience);
}

createRecurringAudienceList

Creates a recurring audience list. Recurring audience lists produces new audience lists each day. Audience lists are users in an audience at the time of the list's creation.

A recurring audience list ensures that you have audience list based on the most recent data available for use each day. If you manually create audience list, you don't know when an audience list based on an additional day's data is available. This recurring audience list automates the creation of an audience list when an additional day's data is available. You will consume fewer quota tokens by using recurring audience list versus manually creating audience list at various times of day trying to guess when an additional day's data is ready.

This method is introduced at alpha stability with the intention of gathering feedback on syntax and capabilities before entering beta. To give your feedback on this API, complete the Google Analytics Audience Export API Feedback form.

Parameters
NameDescription
parent string

Required. The parent resource where this recurring audience list will be created. Format: properties/{property}

recurringAudienceList Google\Analytics\Data\V1alpha\RecurringAudienceList

Required. The recurring audience list to create.

optionalArgs array

Optional.

↳ retrySettings RetrySettings|array

Retry settings to use for this call. Can be a Google\ApiCore\RetrySettings object, or an associative array of retry settings parameters. See the documentation on Google\ApiCore\RetrySettings for example usage.

Returns
TypeDescription
Google\Analytics\Data\V1alpha\RecurringAudienceList
Example
use Google\Analytics\Data\V1alpha\AlphaAnalyticsDataClient;
use Google\Analytics\Data\V1alpha\AudienceDimension;
use Google\Analytics\Data\V1alpha\RecurringAudienceList;
use Google\ApiCore\ApiException;

/**
 * @param string $formattedParent               The parent resource where this recurring audience list will be
 *                                              created. Format: `properties/{property}`
 *                                              Please see {@see AlphaAnalyticsDataClient::propertyName()} for help formatting this field.
 * @param string $recurringAudienceListAudience The audience resource name. This resource name identifies the
 *                                              audience being listed and is shared between the Analytics Data & Admin
 *                                              APIs.
 *
 *                                              Format: `properties/{property}/audiences/{audience}`
 */
function create_recurring_audience_list_sample(
    string $formattedParent,
    string $recurringAudienceListAudience
): void {
    // Create a client.
    $alphaAnalyticsDataClient = new AlphaAnalyticsDataClient();

    // Prepare any non-scalar elements to be passed along with the request.
    $recurringAudienceListDimensions = [new AudienceDimension()];
    $recurringAudienceList = (new RecurringAudienceList())
        ->setAudience($recurringAudienceListAudience)
        ->setDimensions($recurringAudienceListDimensions);

    // Call the API and handle any network failures.
    try {
        /** @var RecurringAudienceList $response */
        $response = $alphaAnalyticsDataClient->createRecurringAudienceList(
            $formattedParent,
            $recurringAudienceList
        );
        printf('Response data: %s' . PHP_EOL, $response->serializeToJsonString());
    } catch (ApiException $ex) {
        printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage());
    }
}

/**
 * Helper to execute the sample.
 *
 * This sample 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.
 *  - It may require specifying regional endpoints when creating the service client,
 *    please see the apiEndpoint client configuration option for more details.
 */
function callSample(): void
{
    $formattedParent = AlphaAnalyticsDataClient::propertyName('[PROPERTY]');
    $recurringAudienceListAudience = '[AUDIENCE]';

    create_recurring_audience_list_sample($formattedParent, $recurringAudienceListAudience);
}

getAudienceList

Gets configuration metadata about a specific audience list. This method can be used to understand an audience list after it has been created.

See Creating an Audience List for an introduction to Audience Lists with examples.

This method is introduced at alpha stability with the intention of gathering feedback on syntax and capabilities before entering beta. To give your feedback on this API, complete the Google Analytics Audience Export API Feedback form.

Parameters
NameDescription
name string

Required. The audience list resource name. Format: properties/{property}/audienceLists/{audience_list}

optionalArgs array

Optional.

↳ retrySettings RetrySettings|array

Retry settings to use for this call. Can be a Google\ApiCore\RetrySettings object, or an associative array of retry settings parameters. See the documentation on Google\ApiCore\RetrySettings for example usage.

Returns
TypeDescription
Google\Analytics\Data\V1alpha\AudienceList
Example
use Google\Analytics\Data\V1alpha\AlphaAnalyticsDataClient;
use Google\Analytics\Data\V1alpha\AudienceList;
use Google\ApiCore\ApiException;

/**
 * @param string $formattedName The audience list resource name.
 *                              Format: `properties/{property}/audienceLists/{audience_list}`
 *                              Please see {@see AlphaAnalyticsDataClient::audienceListName()} for help formatting this field.
 */
function get_audience_list_sample(string $formattedName): void
{
    // Create a client.
    $alphaAnalyticsDataClient = new AlphaAnalyticsDataClient();

    // Call the API and handle any network failures.
    try {
        /** @var AudienceList $response */
        $response = $alphaAnalyticsDataClient->getAudienceList($formattedName);
        printf('Response data: %s' . PHP_EOL, $response->serializeToJsonString());
    } catch (ApiException $ex) {
        printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage());
    }
}

/**
 * Helper to execute the sample.
 *
 * This sample 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.
 *  - It may require specifying regional endpoints when creating the service client,
 *    please see the apiEndpoint client configuration option for more details.
 */
function callSample(): void
{
    $formattedName = AlphaAnalyticsDataClient::audienceListName('[PROPERTY]', '[AUDIENCE_LIST]');

    get_audience_list_sample($formattedName);
}

getRecurringAudienceList

Gets configuration metadata about a specific recurring audience list. This method can be used to understand a recurring audience list's state after it has been created. For example, a recurring audience list resource will generate audience list instances for each day, and this method can be used to get the resource name of the most recent audience list instance.

This method is introduced at alpha stability with the intention of gathering feedback on syntax and capabilities before entering beta. To give your feedback on this API, complete the Google Analytics Audience Export API Feedback form.

Parameters
NameDescription
name string

Required. The recurring audience list resource name. Format: properties/{property}/recurringAudienceLists/{recurring_audience_list}

optionalArgs array

Optional.

↳ retrySettings RetrySettings|array

Retry settings to use for this call. Can be a Google\ApiCore\RetrySettings object, or an associative array of retry settings parameters. See the documentation on Google\ApiCore\RetrySettings for example usage.

Returns
TypeDescription
Google\Analytics\Data\V1alpha\RecurringAudienceList
Example
use Google\Analytics\Data\V1alpha\AlphaAnalyticsDataClient;
use Google\Analytics\Data\V1alpha\RecurringAudienceList;
use Google\ApiCore\ApiException;

/**
 * @param string $formattedName The recurring audience list resource name.
 *                              Format:
 *                              `properties/{property}/recurringAudienceLists/{recurring_audience_list}`
 *                              Please see {@see AlphaAnalyticsDataClient::recurringAudienceListName()} for help formatting this field.
 */
function get_recurring_audience_list_sample(string $formattedName): void
{
    // Create a client.
    $alphaAnalyticsDataClient = new AlphaAnalyticsDataClient();

    // Call the API and handle any network failures.
    try {
        /** @var RecurringAudienceList $response */
        $response = $alphaAnalyticsDataClient->getRecurringAudienceList($formattedName);
        printf('Response data: %s' . PHP_EOL, $response->serializeToJsonString());
    } catch (ApiException $ex) {
        printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage());
    }
}

/**
 * Helper to execute the sample.
 *
 * This sample 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.
 *  - It may require specifying regional endpoints when creating the service client,
 *    please see the apiEndpoint client configuration option for more details.
 */
function callSample(): void
{
    $formattedName = AlphaAnalyticsDataClient::recurringAudienceListName(
        '[PROPERTY]',
        '[RECURRING_AUDIENCE_LIST]'
    );

    get_recurring_audience_list_sample($formattedName);
}

listAudienceLists

Lists all audience lists for a property. This method can be used for you to find and reuse existing audience lists rather than creating unnecessary new audience lists. The same audience can have multiple audience lists that represent the list of users that were in an audience on different days.

See Creating an Audience List for an introduction to Audience Lists with examples.

This method is introduced at alpha stability with the intention of gathering feedback on syntax and capabilities before entering beta. To give your feedback on this API, complete the Google Analytics Audience Export API Feedback form.

Parameters
NameDescription
parent string

Required. All audience lists for this property will be listed in the response. Format: properties/{property}

optionalArgs array

Optional.

↳ pageSize int

The maximum number of resources contained in the underlying API response. The API may return fewer values in a page, even if there are additional values to be retrieved.

↳ pageToken string

A page token is used to specify a page of values to be returned. If no page token is specified (the default), the first page of values will be returned. Any page token used here must have been generated by a previous call to the API.

↳ retrySettings RetrySettings|array

Retry settings to use for this call. Can be a Google\ApiCore\RetrySettings object, or an associative array of retry settings parameters. See the documentation on Google\ApiCore\RetrySettings for example usage.

Returns
TypeDescription
Google\ApiCore\PagedListResponse
Example
use Google\Analytics\Data\V1alpha\AlphaAnalyticsDataClient;
use Google\Analytics\Data\V1alpha\AudienceList;
use Google\ApiCore\ApiException;
use Google\ApiCore\PagedListResponse;

/**
 * @param string $formattedParent All audience lists for this property will be listed in the
 *                                response. Format: `properties/{property}`
 *                                Please see {@see AlphaAnalyticsDataClient::propertyName()} for help formatting this field.
 */
function list_audience_lists_sample(string $formattedParent): void
{
    // Create a client.
    $alphaAnalyticsDataClient = new AlphaAnalyticsDataClient();

    // Call the API and handle any network failures.
    try {
        /** @var PagedListResponse $response */
        $response = $alphaAnalyticsDataClient->listAudienceLists($formattedParent);

        /** @var AudienceList $element */
        foreach ($response as $element) {
            printf('Element data: %s' . PHP_EOL, $element->serializeToJsonString());
        }
    } catch (ApiException $ex) {
        printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage());
    }
}

/**
 * Helper to execute the sample.
 *
 * This sample 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.
 *  - It may require specifying regional endpoints when creating the service client,
 *    please see the apiEndpoint client configuration option for more details.
 */
function callSample(): void
{
    $formattedParent = AlphaAnalyticsDataClient::propertyName('[PROPERTY]');

    list_audience_lists_sample($formattedParent);
}

listRecurringAudienceLists

Lists all recurring audience lists for a property. This method can be used for you to find and reuse existing recurring audience lists rather than creating unnecessary new recurring audience lists. The same audience can have multiple recurring audience lists that represent different dimension combinations; for example, just the dimension deviceId or both the dimensions deviceId and userId.

This method is introduced at alpha stability with the intention of gathering feedback on syntax and capabilities before entering beta. To give your feedback on this API, complete the Google Analytics Audience Export API Feedback form.

Parameters
NameDescription
parent string

Required. All recurring audience lists for this property will be listed in the response. Format: properties/{property}

optionalArgs array

Optional.

↳ pageSize int

The maximum number of resources contained in the underlying API response. The API may return fewer values in a page, even if there are additional values to be retrieved.

↳ pageToken string

A page token is used to specify a page of values to be returned. If no page token is specified (the default), the first page of values will be returned. Any page token used here must have been generated by a previous call to the API.

↳ retrySettings RetrySettings|array

Retry settings to use for this call. Can be a Google\ApiCore\RetrySettings object, or an associative array of retry settings parameters. See the documentation on Google\ApiCore\RetrySettings for example usage.

Returns
TypeDescription
Google\ApiCore\PagedListResponse
Example
use Google\Analytics\Data\V1alpha\AlphaAnalyticsDataClient;
use Google\Analytics\Data\V1alpha\RecurringAudienceList;
use Google\ApiCore\ApiException;
use Google\ApiCore\PagedListResponse;

/**
 * @param string $formattedParent All recurring audience lists for this property will be listed in
 *                                the response. Format: `properties/{property}`
 *                                Please see {@see AlphaAnalyticsDataClient::propertyName()} for help formatting this field.
 */
function list_recurring_audience_lists_sample(string $formattedParent): void
{
    // Create a client.
    $alphaAnalyticsDataClient = new AlphaAnalyticsDataClient();

    // Call the API and handle any network failures.
    try {
        /** @var PagedListResponse $response */
        $response = $alphaAnalyticsDataClient->listRecurringAudienceLists($formattedParent);

        /** @var RecurringAudienceList $element */
        foreach ($response as $element) {
            printf('Element data: %s' . PHP_EOL, $element->serializeToJsonString());
        }
    } catch (ApiException $ex) {
        printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage());
    }
}

/**
 * Helper to execute the sample.
 *
 * This sample 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.
 *  - It may require specifying regional endpoints when creating the service client,
 *    please see the apiEndpoint client configuration option for more details.
 */
function callSample(): void
{
    $formattedParent = AlphaAnalyticsDataClient::propertyName('[PROPERTY]');

    list_recurring_audience_lists_sample($formattedParent);
}

queryAudienceList

Retrieves an audience list of users. After creating an audience, the users are not immediately available for listing. First, a request to CreateAudienceList is necessary to create an audience list of users, and then second, this method is used to retrieve the users in the audience list.

See Creating an Audience List for an introduction to Audience Lists with examples.

Audiences in Google Analytics 4 allow you to segment your users in the ways that are important to your business. To learn more, see https://support.google.com/analytics/answer/9267572.

This method is introduced at alpha stability with the intention of gathering feedback on syntax and capabilities before entering beta. To give your feedback on this API, complete the Google Analytics Audience Export API Feedback form.

Parameters
NameDescription
name string

Required. The name of the audience list to retrieve users from. Format: properties/{property}/audienceLists/{audience_list}

optionalArgs array

Optional.

↳ offset int

Optional. 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.

↳ limit int

Optional. The number of rows to return. If unspecified, 10,000 rows are returned. The API returns a maximum of 250,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. To learn more about this pagination parameter, see Pagination.

↳ retrySettings RetrySettings|array

Retry settings to use for this call. Can be a Google\ApiCore\RetrySettings object, or an associative array of retry settings parameters. See the documentation on Google\ApiCore\RetrySettings for example usage.

Returns
TypeDescription
Google\Analytics\Data\V1alpha\QueryAudienceListResponse
Example
use Google\Analytics\Data\V1alpha\AlphaAnalyticsDataClient;
use Google\Analytics\Data\V1alpha\QueryAudienceListResponse;
use Google\ApiCore\ApiException;

/**
 * @param string $name The name of the audience list to retrieve users from.
 *                     Format: `properties/{property}/audienceLists/{audience_list}`
 */
function query_audience_list_sample(string $name): void
{
    // Create a client.
    $alphaAnalyticsDataClient = new AlphaAnalyticsDataClient();

    // Call the API and handle any network failures.
    try {
        /** @var QueryAudienceListResponse $response */
        $response = $alphaAnalyticsDataClient->queryAudienceList($name);
        printf('Response data: %s' . PHP_EOL, $response->serializeToJsonString());
    } catch (ApiException $ex) {
        printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage());
    }
}

/**
 * Helper to execute the sample.
 *
 * This sample 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.
 *  - It may require specifying regional endpoints when creating the service client,
 *    please see the apiEndpoint client configuration option for more details.
 */
function callSample(): void
{
    $name = '[NAME]';

    query_audience_list_sample($name);
}

runFunnelReport

Returns a customized funnel report of your Google Analytics event data. The data returned from the API is as a table with columns for the requested dimensions and metrics.

Funnel exploration lets you visualize the steps your users take to complete a task and quickly see how well they are succeeding or failing at each step. For example, how do prospects become shoppers and then become buyers? How do one time buyers become repeat buyers? With this information, you can improve inefficient or abandoned customer journeys. To learn more, see GA4 Funnel Explorations.

This method is introduced at alpha stability with the intention of gathering feedback on syntax and capabilities before entering beta. To give your feedback on this API, complete the Google Analytics Data API Funnel Reporting Feedback.

Parameters
NameDescription
optionalArgs array

Optional.

↳ property string

Optional. 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. Within a batch request, this property should either be unspecified or consistent with the batch-level property. Example: properties/1234

↳ dateRanges DateRange[]

Optional. 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.

↳ funnel Funnel

Optional. The configuration of this request's funnel. This funnel configuration is required.

↳ funnelBreakdown FunnelBreakdown

Optional. If specified, this breakdown adds a dimension to the funnel table sub report response. This breakdown dimension expands each funnel step to the unique values of the breakdown dimension. For example, a breakdown by the deviceCategory dimension will create rows for mobile, tablet, desktop, and the total.

↳ funnelNextAction FunnelNextAction

Optional. If specified, next action adds a dimension to the funnel visualization sub report response. This next action dimension expands each funnel step to the unique values of the next action. For example a next action of the eventName dimension will create rows for several events (for example session_start & click) and the total. Next action only supports eventName and most Page / Screen dimensions like pageTitle and pagePath.

↳ funnelVisualizationType int

Optional. The funnel visualization type controls the dimensions present in the funnel visualization sub report response. If not specified, STANDARD_FUNNEL is used. For allowed values, use constants defined on Google\Analytics\Data\V1alpha\RunFunnelReportRequest\FunnelVisualizationType

↳ segments Segment[]

Optional. The configurations of segments. Segments are subsets of a property's data. In a funnel report with segments, the funnel is evaluated in each segment. Each segment specified in this request produces a separate row in the response; in the response, each segment identified by its name. The segments parameter is optional. Requests are limited to 4 segments.

↳ limit int

Optional. The number of rows to return. If unspecified, 10,000 rows are returned. The API returns a maximum of 250,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.

↳ dimensionFilter FilterExpression

Optional. Dimension filters allow you to ask for only specific dimension values in the report. To learn more, see Creating a Report: Dimension Filters for examples. Metrics cannot be used in this filter.

↳ returnPropertyQuota bool

Optional. Toggles whether to return the current state of this Analytics Property's quota. Quota is returned in PropertyQuota.

↳ retrySettings RetrySettings|array

Retry settings to use for this call. Can be a Google\ApiCore\RetrySettings object, or an associative array of retry settings parameters. See the documentation on Google\ApiCore\RetrySettings for example usage.

Returns
TypeDescription
Google\Analytics\Data\V1alpha\RunFunnelReportResponse
Example
use Google\Analytics\Data\V1alpha\AlphaAnalyticsDataClient;
use Google\Analytics\Data\V1alpha\RunFunnelReportResponse;
use Google\ApiCore\ApiException;

/**
 * This sample 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.
 *  - It may require specifying regional endpoints when creating the service client,
 *    please see the apiEndpoint client configuration option for more details.
 */
function run_funnel_report_sample(): void
{
    // Create a client.
    $alphaAnalyticsDataClient = new AlphaAnalyticsDataClient();

    // Call the API and handle any network failures.
    try {
        /** @var RunFunnelReportResponse $response */
        $response = $alphaAnalyticsDataClient->runFunnelReport();
        printf('Response data: %s' . PHP_EOL, $response->serializeToJsonString());
    } catch (ApiException $ex) {
        printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage());
    }
}

sheetExportAudienceList

Exports an audience list of users to a Google Sheet. After creating an audience, the users are not immediately available for listing. First, a request to CreateAudienceList is necessary to create an audience list of users, and then second, this method is used to export those users in the audience list to a Google Sheet.

See Creating an Audience List for an introduction to Audience Lists with examples.

Audiences in Google Analytics 4 allow you to segment your users in the ways that are important to your business. To learn more, see https://support.google.com/analytics/answer/9267572.

This method is introduced at alpha stability with the intention of gathering feedback on syntax and capabilities before entering beta. To give your feedback on this API, complete the Google Analytics Audience Export API Feedback form.

Parameters
NameDescription
name string

Required. The name of the audience list to retrieve users from. Format: properties/{property}/audienceLists/{audience_list}

optionalArgs array

Optional.

↳ offset int

Optional. 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.

↳ limit int

Optional. The number of rows to return. If unspecified, 10,000 rows are returned. The API returns a maximum of 250,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. To learn more about this pagination parameter, see Pagination.

↳ retrySettings RetrySettings|array

Retry settings to use for this call. Can be a Google\ApiCore\RetrySettings object, or an associative array of retry settings parameters. See the documentation on Google\ApiCore\RetrySettings for example usage.

Returns
TypeDescription
Google\Analytics\Data\V1alpha\SheetExportAudienceListResponse
Example
use Google\Analytics\Data\V1alpha\AlphaAnalyticsDataClient;
use Google\Analytics\Data\V1alpha\SheetExportAudienceListResponse;
use Google\ApiCore\ApiException;

/**
 * @param string $formattedName The name of the audience list to retrieve users from.
 *                              Format: `properties/{property}/audienceLists/{audience_list}`
 *                              Please see {@see AlphaAnalyticsDataClient::audienceListName()} for help formatting this field.
 */
function sheet_export_audience_list_sample(string $formattedName): void
{
    // Create a client.
    $alphaAnalyticsDataClient = new AlphaAnalyticsDataClient();

    // Call the API and handle any network failures.
    try {
        /** @var SheetExportAudienceListResponse $response */
        $response = $alphaAnalyticsDataClient->sheetExportAudienceList($formattedName);
        printf('Response data: %s' . PHP_EOL, $response->serializeToJsonString());
    } catch (ApiException $ex) {
        printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage());
    }
}

/**
 * Helper to execute the sample.
 *
 * This sample 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.
 *  - It may require specifying regional endpoints when creating the service client,
 *    please see the apiEndpoint client configuration option for more details.
 */
function callSample(): void
{
    $formattedName = AlphaAnalyticsDataClient::audienceListName('[PROPERTY]', '[AUDIENCE_LIST]');

    sheet_export_audience_list_sample($formattedName);
}

getOperationsClient

Return an OperationsClient object with the same endpoint as $this.

Returns
TypeDescription
Google\ApiCore\LongRunning\OperationsClient

resumeOperation

Resume an existing long running operation that was previously started by a long running API method. If $methodName is not provided, or does not match a long running API method, then the operation can still be resumed, but the OperationResponse object will not deserialize the final response.

Parameters
NameDescription
operationName string

The name of the long running operation

methodName string

The name of the method used to start the operation

Returns
TypeDescription
Google\ApiCore\OperationResponse

static::audienceListName

Formats a string containing the fully-qualified path to represent a audience_list resource.

Parameters
NameDescription
property string
audienceList string
Returns
TypeDescription
stringThe formatted audience_list resource.

static::propertyName

Formats a string containing the fully-qualified path to represent a property resource.

Parameter
NameDescription
property string
Returns
TypeDescription
stringThe formatted property resource.

static::recurringAudienceListName

Formats a string containing the fully-qualified path to represent a recurring_audience_list resource.

Parameters
NameDescription
property string
recurringAudienceList string
Returns
TypeDescription
stringThe formatted recurring_audience_list resource.

static::parseName

Parses a formatted name string and returns an associative array of the components in the name.

The following name formats are supported: Template: Pattern

  • audienceList: properties/{property}/audienceLists/{audience_list}
  • property: properties/{property}
  • recurringAudienceList: properties/{property}/recurringAudienceLists/{recurring_audience_list}

The optional $template argument can be supplied to specify a particular pattern, and must match one of the templates listed above. If no $template argument is provided, or if the $template argument does not match one of the templates listed, then parseName will check each of the supported templates, and return the first match.

Parameters
NameDescription
formattedName string

The formatted name string

template string

Optional name of template to match

Returns
TypeDescription
arrayAn associative array from name component IDs to component values.

Constants

SERVICE_NAME

Value: 'google.analytics.data.v1alpha.AlphaAnalyticsData'

The name of the service.

SERVICE_ADDRESS

Value: 'analyticsdata.googleapis.com'

The default address of the service.

DEFAULT_SERVICE_PORT

Value: 443

The default port of the service.

CODEGEN_NAME

Value: 'gapic'

The name of the code generator, to be included in the agent header.