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.
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 \ ClientMethods
__construct
Constructor.
Parameters | |
---|---|
Name | Description |
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 |
↳ 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 |
↳ 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. |
↳ logger |
false|LoggerInterface
A PSR-3 compliant logger. If set to false, logging is disabled, ignoring the 'GOOGLE_SDK_PHP_LOGGING' environment flag |
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 available at beta stability at audienceExports.create. To give your feedback on this API, complete the Google Analytics Audience Export API Feedback form.
The async variant is AlphaAnalyticsDataClient::createAudienceListAsync() .
Parameters | |
---|---|
Name | Description |
request |
Google\Analytics\Data\V1alpha\CreateAudienceListRequest
A request to house fields associated with the call. |
callOptions |
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 | |
---|---|
Type | Description |
Google\ApiCore\OperationResponse |
use Google\Analytics\Data\V1alpha\AudienceDimension;
use Google\Analytics\Data\V1alpha\AudienceList;
use Google\Analytics\Data\V1alpha\Client\AlphaAnalyticsDataClient;
use Google\Analytics\Data\V1alpha\CreateAudienceListRequest;
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 the request message.
$audienceListDimensions = [new AudienceDimension()];
$audienceList = (new AudienceList())
->setAudience($audienceListAudience)
->setDimensions($audienceListDimensions);
$request = (new CreateAudienceListRequest())
->setParent($formattedParent)
->setAudienceList($audienceList);
// Call the API and handle any network failures.
try {
/** @var OperationResponse $response */
$response = $alphaAnalyticsDataClient->createAudienceList($request);
$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.
The async variant is AlphaAnalyticsDataClient::createRecurringAudienceListAsync() .
Parameters | |
---|---|
Name | Description |
request |
Google\Analytics\Data\V1alpha\CreateRecurringAudienceListRequest
A request to house fields associated with the call. |
callOptions |
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 | |
---|---|
Type | Description |
Google\Analytics\Data\V1alpha\RecurringAudienceList |
use Google\Analytics\Data\V1alpha\AudienceDimension;
use Google\Analytics\Data\V1alpha\Client\AlphaAnalyticsDataClient;
use Google\Analytics\Data\V1alpha\CreateRecurringAudienceListRequest;
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 the request message.
$recurringAudienceListDimensions = [new AudienceDimension()];
$recurringAudienceList = (new RecurringAudienceList())
->setAudience($recurringAudienceListAudience)
->setDimensions($recurringAudienceListDimensions);
$request = (new CreateRecurringAudienceListRequest())
->setParent($formattedParent)
->setRecurringAudienceList($recurringAudienceList);
// Call the API and handle any network failures.
try {
/** @var RecurringAudienceList $response */
$response = $alphaAnalyticsDataClient->createRecurringAudienceList($request);
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);
}
createReportTask
Initiates the creation of a report task. This method quickly returns a report task and initiates a long running asynchronous request to form a customized report of your Google Analytics event data.
A report task will be retained and available for querying for 72 hours after it has been created.
A report task created by one user can be listed and queried by all users who have access to the property.
The async variant is AlphaAnalyticsDataClient::createReportTaskAsync() .
Parameters | |
---|---|
Name | Description |
request |
Google\Analytics\Data\V1alpha\CreateReportTaskRequest
A request to house fields associated with the call. |
callOptions |
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 | |
---|---|
Type | Description |
Google\ApiCore\OperationResponse |
use Google\Analytics\Data\V1alpha\Client\AlphaAnalyticsDataClient;
use Google\Analytics\Data\V1alpha\CreateReportTaskRequest;
use Google\Analytics\Data\V1alpha\ReportTask;
use Google\ApiCore\ApiException;
use Google\ApiCore\OperationResponse;
use Google\Rpc\Status;
/**
* @param string $formattedParent The parent resource where this report task will be created.
* Format: `properties/{propertyId}`
* Please see {@see AlphaAnalyticsDataClient::propertyName()} for help formatting this field.
*/
function create_report_task_sample(string $formattedParent): void
{
// Create a client.
$alphaAnalyticsDataClient = new AlphaAnalyticsDataClient();
// Prepare the request message.
$reportTask = new ReportTask();
$request = (new CreateReportTaskRequest())
->setParent($formattedParent)
->setReportTask($reportTask);
// Call the API and handle any network failures.
try {
/** @var OperationResponse $response */
$response = $alphaAnalyticsDataClient->createReportTask($request);
$response->pollUntilComplete();
if ($response->operationSucceeded()) {
/** @var ReportTask $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]');
create_report_task_sample($formattedParent);
}
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 available at beta stability at audienceExports.get. To give your feedback on this API, complete the Google Analytics Audience Export API Feedback form.
The async variant is AlphaAnalyticsDataClient::getAudienceListAsync() .
Parameters | |
---|---|
Name | Description |
request |
Google\Analytics\Data\V1alpha\GetAudienceListRequest
A request to house fields associated with the call. |
callOptions |
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 | |
---|---|
Type | Description |
Google\Analytics\Data\V1alpha\AudienceList |
use Google\Analytics\Data\V1alpha\AudienceList;
use Google\Analytics\Data\V1alpha\Client\AlphaAnalyticsDataClient;
use Google\Analytics\Data\V1alpha\GetAudienceListRequest;
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();
// Prepare the request message.
$request = (new GetAudienceListRequest())
->setName($formattedName);
// Call the API and handle any network failures.
try {
/** @var AudienceList $response */
$response = $alphaAnalyticsDataClient->getAudienceList($request);
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);
}
getPropertyQuotasSnapshot
Get all property quotas organized by quota category for a given property.
This will charge 1 property quota from the category with the most quota.
The async variant is AlphaAnalyticsDataClient::getPropertyQuotasSnapshotAsync() .
Parameters | |
---|---|
Name | Description |
request |
Google\Analytics\Data\V1alpha\GetPropertyQuotasSnapshotRequest
A request to house fields associated with the call. |
callOptions |
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 | |
---|---|
Type | Description |
Google\Analytics\Data\V1alpha\PropertyQuotasSnapshot |
use Google\Analytics\Data\V1alpha\Client\AlphaAnalyticsDataClient;
use Google\Analytics\Data\V1alpha\GetPropertyQuotasSnapshotRequest;
use Google\Analytics\Data\V1alpha\PropertyQuotasSnapshot;
use Google\ApiCore\ApiException;
/**
* @param string $formattedName Quotas from this property will be listed in the response.
* Format: `properties/{property}/propertyQuotasSnapshot`
* Please see {@see AlphaAnalyticsDataClient::propertyQuotasSnapshotName()} for help formatting this field.
*/
function get_property_quotas_snapshot_sample(string $formattedName): void
{
// Create a client.
$alphaAnalyticsDataClient = new AlphaAnalyticsDataClient();
// Prepare the request message.
$request = (new GetPropertyQuotasSnapshotRequest())
->setName($formattedName);
// Call the API and handle any network failures.
try {
/** @var PropertyQuotasSnapshot $response */
$response = $alphaAnalyticsDataClient->getPropertyQuotasSnapshot($request);
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::propertyQuotasSnapshotName('[PROPERTY]');
get_property_quotas_snapshot_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.
The async variant is AlphaAnalyticsDataClient::getRecurringAudienceListAsync() .
Parameters | |
---|---|
Name | Description |
request |
Google\Analytics\Data\V1alpha\GetRecurringAudienceListRequest
A request to house fields associated with the call. |
callOptions |
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 | |
---|---|
Type | Description |
Google\Analytics\Data\V1alpha\RecurringAudienceList |
use Google\Analytics\Data\V1alpha\Client\AlphaAnalyticsDataClient;
use Google\Analytics\Data\V1alpha\GetRecurringAudienceListRequest;
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();
// Prepare the request message.
$request = (new GetRecurringAudienceListRequest())
->setName($formattedName);
// Call the API and handle any network failures.
try {
/** @var RecurringAudienceList $response */
$response = $alphaAnalyticsDataClient->getRecurringAudienceList($request);
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);
}
getReportTask
Gets report metadata about a specific report task. After creating a report task, use this method to check its processing state or inspect its report definition.
The async variant is AlphaAnalyticsDataClient::getReportTaskAsync() .
Parameters | |
---|---|
Name | Description |
request |
Google\Analytics\Data\V1alpha\GetReportTaskRequest
A request to house fields associated with the call. |
callOptions |
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 | |
---|---|
Type | Description |
Google\Analytics\Data\V1alpha\ReportTask |
use Google\Analytics\Data\V1alpha\Client\AlphaAnalyticsDataClient;
use Google\Analytics\Data\V1alpha\GetReportTaskRequest;
use Google\Analytics\Data\V1alpha\ReportTask;
use Google\ApiCore\ApiException;
/**
* @param string $formattedName The report task resource name.
* Format: `properties/{property}/reportTasks/{report_task}`
* Please see {@see AlphaAnalyticsDataClient::reportTaskName()} for help formatting this field.
*/
function get_report_task_sample(string $formattedName): void
{
// Create a client.
$alphaAnalyticsDataClient = new AlphaAnalyticsDataClient();
// Prepare the request message.
$request = (new GetReportTaskRequest())
->setName($formattedName);
// Call the API and handle any network failures.
try {
/** @var ReportTask $response */
$response = $alphaAnalyticsDataClient->getReportTask($request);
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::reportTaskName('[PROPERTY]', '[REPORT_TASK]');
get_report_task_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 available at beta stability at audienceExports.list. To give your feedback on this API, complete the Google Analytics Audience Export API Feedback form.
The async variant is AlphaAnalyticsDataClient::listAudienceListsAsync() .
Parameters | |
---|---|
Name | Description |
request |
Google\Analytics\Data\V1alpha\ListAudienceListsRequest
A request to house fields associated with the call. |
callOptions |
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 | |
---|---|
Type | Description |
Google\ApiCore\PagedListResponse |
use Google\Analytics\Data\V1alpha\AudienceList;
use Google\Analytics\Data\V1alpha\Client\AlphaAnalyticsDataClient;
use Google\Analytics\Data\V1alpha\ListAudienceListsRequest;
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();
// Prepare the request message.
$request = (new ListAudienceListsRequest())
->setParent($formattedParent);
// Call the API and handle any network failures.
try {
/** @var PagedListResponse $response */
$response = $alphaAnalyticsDataClient->listAudienceLists($request);
/** @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.
The async variant is AlphaAnalyticsDataClient::listRecurringAudienceListsAsync() .
Parameters | |
---|---|
Name | Description |
request |
Google\Analytics\Data\V1alpha\ListRecurringAudienceListsRequest
A request to house fields associated with the call. |
callOptions |
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 | |
---|---|
Type | Description |
Google\ApiCore\PagedListResponse |
use Google\Analytics\Data\V1alpha\Client\AlphaAnalyticsDataClient;
use Google\Analytics\Data\V1alpha\ListRecurringAudienceListsRequest;
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();
// Prepare the request message.
$request = (new ListRecurringAudienceListsRequest())
->setParent($formattedParent);
// Call the API and handle any network failures.
try {
/** @var PagedListResponse $response */
$response = $alphaAnalyticsDataClient->listRecurringAudienceLists($request);
/** @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);
}
listReportTasks
Lists all report tasks for a property.
The async variant is AlphaAnalyticsDataClient::listReportTasksAsync() .
Parameters | |
---|---|
Name | Description |
request |
Google\Analytics\Data\V1alpha\ListReportTasksRequest
A request to house fields associated with the call. |
callOptions |
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 | |
---|---|
Type | Description |
Google\ApiCore\PagedListResponse |
use Google\Analytics\Data\V1alpha\Client\AlphaAnalyticsDataClient;
use Google\Analytics\Data\V1alpha\ListReportTasksRequest;
use Google\Analytics\Data\V1alpha\ReportTask;
use Google\ApiCore\ApiException;
use Google\ApiCore\PagedListResponse;
/**
* @param string $formattedParent All report tasks for this property will be listed in the
* response. Format: `properties/{property}`
* Please see {@see AlphaAnalyticsDataClient::propertyName()} for help formatting this field.
*/
function list_report_tasks_sample(string $formattedParent): void
{
// Create a client.
$alphaAnalyticsDataClient = new AlphaAnalyticsDataClient();
// Prepare the request message.
$request = (new ListReportTasksRequest())
->setParent($formattedParent);
// Call the API and handle any network failures.
try {
/** @var PagedListResponse $response */
$response = $alphaAnalyticsDataClient->listReportTasks($request);
/** @var ReportTask $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_report_tasks_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 available at beta stability at audienceExports.query. To give your feedback on this API, complete the Google Analytics Audience Export API Feedback form.
The async variant is AlphaAnalyticsDataClient::queryAudienceListAsync() .
Parameters | |
---|---|
Name | Description |
request |
Google\Analytics\Data\V1alpha\QueryAudienceListRequest
A request to house fields associated with the call. |
callOptions |
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 | |
---|---|
Type | Description |
Google\Analytics\Data\V1alpha\QueryAudienceListResponse |
use Google\Analytics\Data\V1alpha\Client\AlphaAnalyticsDataClient;
use Google\Analytics\Data\V1alpha\QueryAudienceListRequest;
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();
// Prepare the request message.
$request = (new QueryAudienceListRequest())
->setName($name);
// Call the API and handle any network failures.
try {
/** @var QueryAudienceListResponse $response */
$response = $alphaAnalyticsDataClient->queryAudienceList($request);
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);
}
queryReportTask
Retrieves a report task's content. After requesting the CreateReportTask
,
you are able to retrieve the report content once the report is
ACTIVE. This method will return an error if the report task's state is not
ACTIVE
. A query response will return the tabular row & column values of
the report.
The async variant is AlphaAnalyticsDataClient::queryReportTaskAsync() .
Parameters | |
---|---|
Name | Description |
request |
Google\Analytics\Data\V1alpha\QueryReportTaskRequest
A request to house fields associated with the call. |
callOptions |
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 | |
---|---|
Type | Description |
Google\Analytics\Data\V1alpha\QueryReportTaskResponse |
use Google\Analytics\Data\V1alpha\Client\AlphaAnalyticsDataClient;
use Google\Analytics\Data\V1alpha\QueryReportTaskRequest;
use Google\Analytics\Data\V1alpha\QueryReportTaskResponse;
use Google\ApiCore\ApiException;
/**
* @param string $name The report source name.
* Format: `properties/{property}/reportTasks/{report}`
*/
function query_report_task_sample(string $name): void
{
// Create a client.
$alphaAnalyticsDataClient = new AlphaAnalyticsDataClient();
// Prepare the request message.
$request = (new QueryReportTaskRequest())
->setName($name);
// Call the API and handle any network failures.
try {
/** @var QueryReportTaskResponse $response */
$response = $alphaAnalyticsDataClient->queryReportTask($request);
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_report_task_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.
The async variant is AlphaAnalyticsDataClient::runFunnelReportAsync() .
Parameters | |
---|---|
Name | Description |
request |
Google\Analytics\Data\V1alpha\RunFunnelReportRequest
A request to house fields associated with the call. |
callOptions |
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 | |
---|---|
Type | Description |
Google\Analytics\Data\V1alpha\RunFunnelReportResponse |
use Google\Analytics\Data\V1alpha\Client\AlphaAnalyticsDataClient;
use Google\Analytics\Data\V1alpha\RunFunnelReportRequest;
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();
// Prepare the request message.
$request = new RunFunnelReportRequest();
// Call the API and handle any network failures.
try {
/** @var RunFunnelReportResponse $response */
$response = $alphaAnalyticsDataClient->runFunnelReport($request);
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.
The async variant is AlphaAnalyticsDataClient::sheetExportAudienceListAsync() .
Parameters | |
---|---|
Name | Description |
request |
Google\Analytics\Data\V1alpha\SheetExportAudienceListRequest
A request to house fields associated with the call. |
callOptions |
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 | |
---|---|
Type | Description |
Google\Analytics\Data\V1alpha\SheetExportAudienceListResponse |
use Google\Analytics\Data\V1alpha\Client\AlphaAnalyticsDataClient;
use Google\Analytics\Data\V1alpha\SheetExportAudienceListRequest;
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();
// Prepare the request message.
$request = (new SheetExportAudienceListRequest())
->setName($formattedName);
// Call the API and handle any network failures.
try {
/** @var SheetExportAudienceListResponse $response */
$response = $alphaAnalyticsDataClient->sheetExportAudienceList($request);
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);
}
createAudienceListAsync
Parameters | |
---|---|
Name | Description |
request |
Google\Analytics\Data\V1alpha\CreateAudienceListRequest
|
optionalArgs |
array
|
Returns | |
---|---|
Type | Description |
GuzzleHttp\Promise\PromiseInterface<Google\ApiCore\OperationResponse> |
createRecurringAudienceListAsync
Parameters | |
---|---|
Name | Description |
request |
Google\Analytics\Data\V1alpha\CreateRecurringAudienceListRequest
|
optionalArgs |
array
|
Returns | |
---|---|
Type | Description |
GuzzleHttp\Promise\PromiseInterface<Google\Analytics\Data\V1alpha\RecurringAudienceList> |
createReportTaskAsync
Parameters | |
---|---|
Name | Description |
request |
Google\Analytics\Data\V1alpha\CreateReportTaskRequest
|
optionalArgs |
array
|
Returns | |
---|---|
Type | Description |
GuzzleHttp\Promise\PromiseInterface<Google\ApiCore\OperationResponse> |
getAudienceListAsync
Parameters | |
---|---|
Name | Description |
request |
Google\Analytics\Data\V1alpha\GetAudienceListRequest
|
optionalArgs |
array
|
Returns | |
---|---|
Type | Description |
GuzzleHttp\Promise\PromiseInterface<Google\Analytics\Data\V1alpha\AudienceList> |
getPropertyQuotasSnapshotAsync
Parameters | |
---|---|
Name | Description |
request |
Google\Analytics\Data\V1alpha\GetPropertyQuotasSnapshotRequest
|
optionalArgs |
array
|
Returns | |
---|---|
Type | Description |
GuzzleHttp\Promise\PromiseInterface<Google\Analytics\Data\V1alpha\PropertyQuotasSnapshot> |
getRecurringAudienceListAsync
Parameters | |
---|---|
Name | Description |
request |
Google\Analytics\Data\V1alpha\GetRecurringAudienceListRequest
|
optionalArgs |
array
|
Returns | |
---|---|
Type | Description |
GuzzleHttp\Promise\PromiseInterface<Google\Analytics\Data\V1alpha\RecurringAudienceList> |
getReportTaskAsync
Parameters | |
---|---|
Name | Description |
request |
Google\Analytics\Data\V1alpha\GetReportTaskRequest
|
optionalArgs |
array
|
Returns | |
---|---|
Type | Description |
GuzzleHttp\Promise\PromiseInterface<Google\Analytics\Data\V1alpha\ReportTask> |
listAudienceListsAsync
Parameters | |
---|---|
Name | Description |
request |
Google\Analytics\Data\V1alpha\ListAudienceListsRequest
|
optionalArgs |
array
|
Returns | |
---|---|
Type | Description |
GuzzleHttp\Promise\PromiseInterface<Google\ApiCore\PagedListResponse> |
listRecurringAudienceListsAsync
Parameters | |
---|---|
Name | Description |
request |
Google\Analytics\Data\V1alpha\ListRecurringAudienceListsRequest
|
optionalArgs |
array
|
Returns | |
---|---|
Type | Description |
GuzzleHttp\Promise\PromiseInterface<Google\ApiCore\PagedListResponse> |
listReportTasksAsync
Parameters | |
---|---|
Name | Description |
request |
Google\Analytics\Data\V1alpha\ListReportTasksRequest
|
optionalArgs |
array
|
Returns | |
---|---|
Type | Description |
GuzzleHttp\Promise\PromiseInterface<Google\ApiCore\PagedListResponse> |
queryAudienceListAsync
Parameters | |
---|---|
Name | Description |
request |
Google\Analytics\Data\V1alpha\QueryAudienceListRequest
|
optionalArgs |
array
|
Returns | |
---|---|
Type | Description |
GuzzleHttp\Promise\PromiseInterface<Google\Analytics\Data\V1alpha\QueryAudienceListResponse> |
queryReportTaskAsync
Parameters | |
---|---|
Name | Description |
request |
Google\Analytics\Data\V1alpha\QueryReportTaskRequest
|
optionalArgs |
array
|
Returns | |
---|---|
Type | Description |
GuzzleHttp\Promise\PromiseInterface<Google\Analytics\Data\V1alpha\QueryReportTaskResponse> |
runFunnelReportAsync
Parameters | |
---|---|
Name | Description |
request |
Google\Analytics\Data\V1alpha\RunFunnelReportRequest
|
optionalArgs |
array
|
Returns | |
---|---|
Type | Description |
GuzzleHttp\Promise\PromiseInterface<Google\Analytics\Data\V1alpha\RunFunnelReportResponse> |
sheetExportAudienceListAsync
Parameters | |
---|---|
Name | Description |
request |
Google\Analytics\Data\V1alpha\SheetExportAudienceListRequest
|
optionalArgs |
array
|
Returns | |
---|---|
Type | Description |
GuzzleHttp\Promise\PromiseInterface<Google\Analytics\Data\V1alpha\SheetExportAudienceListResponse> |
getOperationsClient
Return an OperationsClient object with the same endpoint as $this.
Returns | |
---|---|
Type | Description |
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 | |
---|---|
Name | Description |
operationName |
string
The name of the long running operation |
methodName |
string
The name of the method used to start the operation |
Returns | |
---|---|
Type | Description |
Google\ApiCore\OperationResponse |
static::audienceListName
Formats a string containing the fully-qualified path to represent a audience_list resource.
Parameters | |
---|---|
Name | Description |
property |
string
|
audienceList |
string
|
Returns | |
---|---|
Type | Description |
string |
The formatted audience_list resource. |
static::propertyName
Formats a string containing the fully-qualified path to represent a property resource.
Parameter | |
---|---|
Name | Description |
property |
string
|
Returns | |
---|---|
Type | Description |
string |
The formatted property resource. |
static::propertyQuotasSnapshotName
Formats a string containing the fully-qualified path to represent a property_quotas_snapshot resource.
Parameter | |
---|---|
Name | Description |
property |
string
|
Returns | |
---|---|
Type | Description |
string |
The formatted property_quotas_snapshot resource. |
static::recurringAudienceListName
Formats a string containing the fully-qualified path to represent a recurring_audience_list resource.
Parameters | |
---|---|
Name | Description |
property |
string
|
recurringAudienceList |
string
|
Returns | |
---|---|
Type | Description |
string |
The formatted recurring_audience_list resource. |
static::reportTaskName
Formats a string containing the fully-qualified path to represent a report_task resource.
Parameters | |
---|---|
Name | Description |
property |
string
|
reportTask |
string
|
Returns | |
---|---|
Type | Description |
string |
The formatted report_task 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}
- propertyQuotasSnapshot: properties/{property}/propertyQuotasSnapshot
- recurringAudienceList: properties/{property}/recurringAudienceLists/{recurring_audience_list}
- reportTask: properties/{property}/reportTasks/{report_task}
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 | |
---|---|
Name | Description |
formattedName |
string
The formatted name string |
template |
?string
Optional name of template to match |
Returns | |
---|---|
Type | Description |
array |
An associative array from name component IDs to component values. |