Reference documentation and code samples for the Google Analytics Admin V1beta Client class AnalyticsAdminServiceClient.
Service Description: Service Interface for the Analytics Admin API (GA4).
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:
$analyticsAdminServiceClient = new AnalyticsAdminServiceClient();
try {
$formattedProperty = $analyticsAdminServiceClient->propertyName('[PROPERTY]');
$acknowledgement = 'acknowledgement';
$response = $analyticsAdminServiceClient->acknowledgeUserDataCollection($formattedProperty, $acknowledgement);
} finally {
$analyticsAdminServiceClient->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 \ Admin \ V1betaMethods
__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. |
acknowledgeUserDataCollection
Acknowledges the terms of user data collection for the specified property.
This acknowledgement must be completed (either in the Google Analytics UI or through this API) before MeasurementProtocolSecret resources may be created.
Parameters | |
---|---|
Name | Description |
property |
string
Required. The property for which to acknowledge user data collection. |
acknowledgement |
string
Required. An acknowledgement that the caller of this method understands the terms of user data collection. This field must contain the exact value: "I acknowledge that I have the necessary privacy disclosures and rights from my end users for the collection and processing of their data, including the association of such data with the visitation information Google Analytics collects from my site and/or app property." |
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 | |
---|---|
Type | Description |
Google\Analytics\Admin\V1beta\AcknowledgeUserDataCollectionResponse |
use Google\Analytics\Admin\V1beta\AcknowledgeUserDataCollectionRequest;
use Google\Analytics\Admin\V1beta\AcknowledgeUserDataCollectionResponse;
use Google\Analytics\Admin\V1beta\Client\AnalyticsAdminServiceClient;
use Google\ApiCore\ApiException;
/**
* @param string $formattedProperty The property for which to acknowledge user data collection. Please see
* {@see AnalyticsAdminServiceClient::propertyName()} for help formatting this field.
* @param string $acknowledgement An acknowledgement that the caller of this method understands the
* terms of user data collection.
*
* This field must contain the exact value:
* "I acknowledge that I have the necessary privacy disclosures and rights
* from my end users for the collection and processing of their data,
* including the association of such data with the visitation information
* Google Analytics collects from my site and/or app property."
*/
function acknowledge_user_data_collection_sample(
string $formattedProperty,
string $acknowledgement
): void {
// Create a client.
$analyticsAdminServiceClient = new AnalyticsAdminServiceClient();
// Prepare the request message.
$request = (new AcknowledgeUserDataCollectionRequest())
->setProperty($formattedProperty)
->setAcknowledgement($acknowledgement);
// Call the API and handle any network failures.
try {
/** @var AcknowledgeUserDataCollectionResponse $response */
$response = $analyticsAdminServiceClient->acknowledgeUserDataCollection($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
{
$formattedProperty = AnalyticsAdminServiceClient::propertyName('[PROPERTY]');
$acknowledgement = '[ACKNOWLEDGEMENT]';
acknowledge_user_data_collection_sample($formattedProperty, $acknowledgement);
}
archiveCustomDimension
Archives a CustomDimension on a property.
Parameters | |
---|---|
Name | Description |
name |
string
Required. The name of the CustomDimension to archive. Example format: properties/1234/customDimensions/5678 |
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. |
use Google\Analytics\Admin\V1beta\ArchiveCustomDimensionRequest;
use Google\Analytics\Admin\V1beta\Client\AnalyticsAdminServiceClient;
use Google\ApiCore\ApiException;
/**
* @param string $formattedName The name of the CustomDimension to archive.
* Example format: properties/1234/customDimensions/5678
* Please see {@see AnalyticsAdminServiceClient::customDimensionName()} for help formatting this field.
*/
function archive_custom_dimension_sample(string $formattedName): void
{
// Create a client.
$analyticsAdminServiceClient = new AnalyticsAdminServiceClient();
// Prepare the request message.
$request = (new ArchiveCustomDimensionRequest())
->setName($formattedName);
// Call the API and handle any network failures.
try {
$analyticsAdminServiceClient->archiveCustomDimension($request);
printf('Call completed successfully.' . PHP_EOL);
} 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 = AnalyticsAdminServiceClient::customDimensionName(
'[PROPERTY]',
'[CUSTOM_DIMENSION]'
);
archive_custom_dimension_sample($formattedName);
}
archiveCustomMetric
Archives a CustomMetric on a property.
Parameters | |
---|---|
Name | Description |
name |
string
Required. The name of the CustomMetric to archive. Example format: properties/1234/customMetrics/5678 |
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. |
use Google\Analytics\Admin\V1beta\ArchiveCustomMetricRequest;
use Google\Analytics\Admin\V1beta\Client\AnalyticsAdminServiceClient;
use Google\ApiCore\ApiException;
/**
* @param string $formattedName The name of the CustomMetric to archive.
* Example format: properties/1234/customMetrics/5678
* Please see {@see AnalyticsAdminServiceClient::customMetricName()} for help formatting this field.
*/
function archive_custom_metric_sample(string $formattedName): void
{
// Create a client.
$analyticsAdminServiceClient = new AnalyticsAdminServiceClient();
// Prepare the request message.
$request = (new ArchiveCustomMetricRequest())
->setName($formattedName);
// Call the API and handle any network failures.
try {
$analyticsAdminServiceClient->archiveCustomMetric($request);
printf('Call completed successfully.' . PHP_EOL);
} 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 = AnalyticsAdminServiceClient::customMetricName('[PROPERTY]', '[CUSTOM_METRIC]');
archive_custom_metric_sample($formattedName);
}
createConversionEvent
Creates a conversion event with the specified attributes.
Parameters | |
---|---|
Name | Description |
conversionEvent |
Google\Analytics\Admin\V1beta\ConversionEvent
Required. The conversion event to create. |
parent |
string
Required. The resource name of the parent property where this conversion event will be created. Format: properties/123 |
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 | |
---|---|
Type | Description |
Google\Analytics\Admin\V1beta\ConversionEvent |
use Google\Analytics\Admin\V1beta\Client\AnalyticsAdminServiceClient;
use Google\Analytics\Admin\V1beta\ConversionEvent;
use Google\Analytics\Admin\V1beta\CreateConversionEventRequest;
use Google\ApiCore\ApiException;
/**
* @param string $formattedParent The resource name of the parent property where this conversion
* event will be created. Format: properties/123
* Please see {@see AnalyticsAdminServiceClient::propertyName()} for help formatting this field.
*/
function create_conversion_event_sample(string $formattedParent): void
{
// Create a client.
$analyticsAdminServiceClient = new AnalyticsAdminServiceClient();
// Prepare the request message.
$conversionEvent = new ConversionEvent();
$request = (new CreateConversionEventRequest())
->setConversionEvent($conversionEvent)
->setParent($formattedParent);
// Call the API and handle any network failures.
try {
/** @var ConversionEvent $response */
$response = $analyticsAdminServiceClient->createConversionEvent($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 = AnalyticsAdminServiceClient::propertyName('[PROPERTY]');
create_conversion_event_sample($formattedParent);
}
createCustomDimension
Creates a CustomDimension.
Parameters | |
---|---|
Name | Description |
parent |
string
Required. Example format: properties/1234 |
customDimension |
Google\Analytics\Admin\V1beta\CustomDimension
Required. The CustomDimension 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 | |
---|---|
Type | Description |
Google\Analytics\Admin\V1beta\CustomDimension |
use Google\Analytics\Admin\V1beta\Client\AnalyticsAdminServiceClient;
use Google\Analytics\Admin\V1beta\CreateCustomDimensionRequest;
use Google\Analytics\Admin\V1beta\CustomDimension;
use Google\Analytics\Admin\V1beta\CustomDimension\DimensionScope;
use Google\ApiCore\ApiException;
/**
* @param string $formattedParent Example format: properties/1234
* Please see {@see AnalyticsAdminServiceClient::propertyName()} for help formatting this field.
* @param string $customDimensionParameterName Immutable. Tagging parameter name for this custom dimension.
*
* If this is a user-scoped dimension, then this is the user property name.
* If this is an event-scoped dimension, then this is the event parameter
* name.
*
* If this is an item-scoped dimension, then this is the parameter
* name found in the eCommerce items array.
*
* May only contain alphanumeric and underscore characters, starting with a
* letter. Max length of 24 characters for user-scoped dimensions, 40
* characters for event-scoped dimensions.
* @param string $customDimensionDisplayName Display name for this custom dimension as shown in the Analytics
* UI. Max length of 82 characters, alphanumeric plus space and underscore
* starting with a letter. Legacy system-generated display names may contain
* square brackets, but updates to this field will never permit square
* brackets.
* @param int $customDimensionScope Immutable. The scope of this dimension.
*/
function create_custom_dimension_sample(
string $formattedParent,
string $customDimensionParameterName,
string $customDimensionDisplayName,
int $customDimensionScope
): void {
// Create a client.
$analyticsAdminServiceClient = new AnalyticsAdminServiceClient();
// Prepare the request message.
$customDimension = (new CustomDimension())
->setParameterName($customDimensionParameterName)
->setDisplayName($customDimensionDisplayName)
->setScope($customDimensionScope);
$request = (new CreateCustomDimensionRequest())
->setParent($formattedParent)
->setCustomDimension($customDimension);
// Call the API and handle any network failures.
try {
/** @var CustomDimension $response */
$response = $analyticsAdminServiceClient->createCustomDimension($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 = AnalyticsAdminServiceClient::propertyName('[PROPERTY]');
$customDimensionParameterName = '[PARAMETER_NAME]';
$customDimensionDisplayName = '[DISPLAY_NAME]';
$customDimensionScope = DimensionScope::DIMENSION_SCOPE_UNSPECIFIED;
create_custom_dimension_sample(
$formattedParent,
$customDimensionParameterName,
$customDimensionDisplayName,
$customDimensionScope
);
}
createCustomMetric
Creates a CustomMetric.
Parameters | |
---|---|
Name | Description |
parent |
string
Required. Example format: properties/1234 |
customMetric |
Google\Analytics\Admin\V1beta\CustomMetric
Required. The CustomMetric 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 | |
---|---|
Type | Description |
Google\Analytics\Admin\V1beta\CustomMetric |
use Google\Analytics\Admin\V1beta\Client\AnalyticsAdminServiceClient;
use Google\Analytics\Admin\V1beta\CreateCustomMetricRequest;
use Google\Analytics\Admin\V1beta\CustomMetric;
use Google\Analytics\Admin\V1beta\CustomMetric\MeasurementUnit;
use Google\Analytics\Admin\V1beta\CustomMetric\MetricScope;
use Google\ApiCore\ApiException;
/**
* @param string $formattedParent Example format: properties/1234
* Please see {@see AnalyticsAdminServiceClient::propertyName()} for help formatting this field.
* @param string $customMetricParameterName Immutable. Tagging name for this custom metric.
*
* If this is an event-scoped metric, then this is the event parameter
* name.
*
* May only contain alphanumeric and underscore charactes, starting with a
* letter. Max length of 40 characters for event-scoped metrics.
* @param string $customMetricDisplayName Display name for this custom metric as shown in the Analytics UI.
* Max length of 82 characters, alphanumeric plus space and underscore
* starting with a letter. Legacy system-generated display names may contain
* square brackets, but updates to this field will never permit square
* brackets.
* @param int $customMetricMeasurementUnit The type for the custom metric's value.
* @param int $customMetricScope Immutable. The scope of this custom metric.
*/
function create_custom_metric_sample(
string $formattedParent,
string $customMetricParameterName,
string $customMetricDisplayName,
int $customMetricMeasurementUnit,
int $customMetricScope
): void {
// Create a client.
$analyticsAdminServiceClient = new AnalyticsAdminServiceClient();
// Prepare the request message.
$customMetric = (new CustomMetric())
->setParameterName($customMetricParameterName)
->setDisplayName($customMetricDisplayName)
->setMeasurementUnit($customMetricMeasurementUnit)
->setScope($customMetricScope);
$request = (new CreateCustomMetricRequest())
->setParent($formattedParent)
->setCustomMetric($customMetric);
// Call the API and handle any network failures.
try {
/** @var CustomMetric $response */
$response = $analyticsAdminServiceClient->createCustomMetric($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 = AnalyticsAdminServiceClient::propertyName('[PROPERTY]');
$customMetricParameterName = '[PARAMETER_NAME]';
$customMetricDisplayName = '[DISPLAY_NAME]';
$customMetricMeasurementUnit = MeasurementUnit::MEASUREMENT_UNIT_UNSPECIFIED;
$customMetricScope = MetricScope::METRIC_SCOPE_UNSPECIFIED;
create_custom_metric_sample(
$formattedParent,
$customMetricParameterName,
$customMetricDisplayName,
$customMetricMeasurementUnit,
$customMetricScope
);
}
createDataStream
Creates a DataStream.
Parameters | |
---|---|
Name | Description |
parent |
string
Required. Example format: properties/1234 |
dataStream |
Google\Analytics\Admin\V1beta\DataStream
Required. The DataStream 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 | |
---|---|
Type | Description |
Google\Analytics\Admin\V1beta\DataStream |
use Google\Analytics\Admin\V1beta\Client\AnalyticsAdminServiceClient;
use Google\Analytics\Admin\V1beta\CreateDataStreamRequest;
use Google\Analytics\Admin\V1beta\DataStream;
use Google\Analytics\Admin\V1beta\DataStream\DataStreamType;
use Google\ApiCore\ApiException;
/**
* @param string $formattedParent Example format: properties/1234
* Please see {@see AnalyticsAdminServiceClient::propertyName()} for help formatting this field.
* @param int $dataStreamType Immutable. The type of this DataStream resource.
*/
function create_data_stream_sample(string $formattedParent, int $dataStreamType): void
{
// Create a client.
$analyticsAdminServiceClient = new AnalyticsAdminServiceClient();
// Prepare the request message.
$dataStream = (new DataStream())
->setType($dataStreamType);
$request = (new CreateDataStreamRequest())
->setParent($formattedParent)
->setDataStream($dataStream);
// Call the API and handle any network failures.
try {
/** @var DataStream $response */
$response = $analyticsAdminServiceClient->createDataStream($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 = AnalyticsAdminServiceClient::propertyName('[PROPERTY]');
$dataStreamType = DataStreamType::DATA_STREAM_TYPE_UNSPECIFIED;
create_data_stream_sample($formattedParent, $dataStreamType);
}
createFirebaseLink
Creates a FirebaseLink.
Properties can have at most one FirebaseLink.
Parameters | |
---|---|
Name | Description |
parent |
string
Required. Format: properties/{property_id} Example: properties/1234 |
firebaseLink |
Google\Analytics\Admin\V1beta\FirebaseLink
Required. The Firebase link 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 | |
---|---|
Type | Description |
Google\Analytics\Admin\V1beta\FirebaseLink |
use Google\Analytics\Admin\V1beta\Client\AnalyticsAdminServiceClient;
use Google\Analytics\Admin\V1beta\CreateFirebaseLinkRequest;
use Google\Analytics\Admin\V1beta\FirebaseLink;
use Google\ApiCore\ApiException;
/**
* @param string $formattedParent Format: properties/{property_id}
* Example: properties/1234
* Please see {@see AnalyticsAdminServiceClient::propertyName()} for help formatting this field.
*/
function create_firebase_link_sample(string $formattedParent): void
{
// Create a client.
$analyticsAdminServiceClient = new AnalyticsAdminServiceClient();
// Prepare the request message.
$firebaseLink = new FirebaseLink();
$request = (new CreateFirebaseLinkRequest())
->setParent($formattedParent)
->setFirebaseLink($firebaseLink);
// Call the API and handle any network failures.
try {
/** @var FirebaseLink $response */
$response = $analyticsAdminServiceClient->createFirebaseLink($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 = AnalyticsAdminServiceClient::propertyName('[PROPERTY]');
create_firebase_link_sample($formattedParent);
}
createGoogleAdsLink
Creates a GoogleAdsLink.
Parameters | |
---|---|
Name | Description |
parent |
string
Required. Example format: properties/1234 |
googleAdsLink |
Google\Analytics\Admin\V1beta\GoogleAdsLink
Required. The GoogleAdsLink 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 | |
---|---|
Type | Description |
Google\Analytics\Admin\V1beta\GoogleAdsLink |
use Google\Analytics\Admin\V1beta\Client\AnalyticsAdminServiceClient;
use Google\Analytics\Admin\V1beta\CreateGoogleAdsLinkRequest;
use Google\Analytics\Admin\V1beta\GoogleAdsLink;
use Google\ApiCore\ApiException;
/**
* @param string $formattedParent Example format: properties/1234
* Please see {@see AnalyticsAdminServiceClient::propertyName()} for help formatting this field.
*/
function create_google_ads_link_sample(string $formattedParent): void
{
// Create a client.
$analyticsAdminServiceClient = new AnalyticsAdminServiceClient();
// Prepare the request message.
$googleAdsLink = new GoogleAdsLink();
$request = (new CreateGoogleAdsLinkRequest())
->setParent($formattedParent)
->setGoogleAdsLink($googleAdsLink);
// Call the API and handle any network failures.
try {
/** @var GoogleAdsLink $response */
$response = $analyticsAdminServiceClient->createGoogleAdsLink($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 = AnalyticsAdminServiceClient::propertyName('[PROPERTY]');
create_google_ads_link_sample($formattedParent);
}
createMeasurementProtocolSecret
Creates a measurement protocol secret.
Parameters | |
---|---|
Name | Description |
parent |
string
Required. The parent resource where this secret will be created. Format: properties/{property}/dataStreams/{dataStream} |
measurementProtocolSecret |
Google\Analytics\Admin\V1beta\MeasurementProtocolSecret
Required. The measurement protocol secret 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 | |
---|---|
Type | Description |
Google\Analytics\Admin\V1beta\MeasurementProtocolSecret |
use Google\Analytics\Admin\V1beta\Client\AnalyticsAdminServiceClient;
use Google\Analytics\Admin\V1beta\CreateMeasurementProtocolSecretRequest;
use Google\Analytics\Admin\V1beta\MeasurementProtocolSecret;
use Google\ApiCore\ApiException;
/**
* @param string $formattedParent The parent resource where this secret will be created.
* Format: properties/{property}/dataStreams/{dataStream}
* Please see {@see AnalyticsAdminServiceClient::dataStreamName()} for help formatting this field.
* @param string $measurementProtocolSecretDisplayName Human-readable display name for this secret.
*/
function create_measurement_protocol_secret_sample(
string $formattedParent,
string $measurementProtocolSecretDisplayName
): void {
// Create a client.
$analyticsAdminServiceClient = new AnalyticsAdminServiceClient();
// Prepare the request message.
$measurementProtocolSecret = (new MeasurementProtocolSecret())
->setDisplayName($measurementProtocolSecretDisplayName);
$request = (new CreateMeasurementProtocolSecretRequest())
->setParent($formattedParent)
->setMeasurementProtocolSecret($measurementProtocolSecret);
// Call the API and handle any network failures.
try {
/** @var MeasurementProtocolSecret $response */
$response = $analyticsAdminServiceClient->createMeasurementProtocolSecret($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 = AnalyticsAdminServiceClient::dataStreamName('[PROPERTY]', '[DATA_STREAM]');
$measurementProtocolSecretDisplayName = '[DISPLAY_NAME]';
create_measurement_protocol_secret_sample($formattedParent, $measurementProtocolSecretDisplayName);
}
createProperty
Creates an "GA4" property with the specified location and attributes.
Parameters | |
---|---|
Name | Description |
property |
Google\Analytics\Admin\V1beta\Property
Required. The property to create. Note: the supplied property must specify its parent. |
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 | |
---|---|
Type | Description |
Google\Analytics\Admin\V1beta\Property |
use Google\Analytics\Admin\V1beta\Client\AnalyticsAdminServiceClient;
use Google\Analytics\Admin\V1beta\CreatePropertyRequest;
use Google\Analytics\Admin\V1beta\Property;
use Google\ApiCore\ApiException;
/**
* @param string $propertyDisplayName Human-readable display name for this property.
*
* The max allowed display name length is 100 UTF-16 code units.
* @param string $propertyTimeZone Reporting Time Zone, used as the day boundary for reports,
* regardless of where the data originates. If the time zone honors DST,
* Analytics will automatically adjust for the changes.
*
* NOTE: Changing the time zone only affects data going forward, and is not
* applied retroactively.
*
* Format: https://www.iana.org/time-zones
* Example: "America/Los_Angeles"
*/
function create_property_sample(string $propertyDisplayName, string $propertyTimeZone): void
{
// Create a client.
$analyticsAdminServiceClient = new AnalyticsAdminServiceClient();
// Prepare the request message.
$property = (new Property())
->setDisplayName($propertyDisplayName)
->setTimeZone($propertyTimeZone);
$request = (new CreatePropertyRequest())
->setProperty($property);
// Call the API and handle any network failures.
try {
/** @var Property $response */
$response = $analyticsAdminServiceClient->createProperty($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
{
$propertyDisplayName = '[DISPLAY_NAME]';
$propertyTimeZone = '[TIME_ZONE]';
create_property_sample($propertyDisplayName, $propertyTimeZone);
}
deleteAccount
Marks target Account as soft-deleted (ie: "trashed") and returns it.
This API does not have a method to restore soft-deleted accounts. However, they can be restored using the Trash Can UI.
If the accounts are not restored before the expiration time, the account and all child resources (eg: Properties, GoogleAdsLinks, Streams, UserLinks) will be permanently purged. https://support.google.com/analytics/answer/6154772
Returns an error if the target is not found.
Parameters | |
---|---|
Name | Description |
name |
string
Required. The name of the Account to soft-delete. Format: accounts/{account} Example: "accounts/100" |
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. |
use Google\Analytics\Admin\V1beta\Client\AnalyticsAdminServiceClient;
use Google\Analytics\Admin\V1beta\DeleteAccountRequest;
use Google\ApiCore\ApiException;
/**
* @param string $formattedName The name of the Account to soft-delete.
* Format: accounts/{account}
* Example: "accounts/100"
* Please see {@see AnalyticsAdminServiceClient::accountName()} for help formatting this field.
*/
function delete_account_sample(string $formattedName): void
{
// Create a client.
$analyticsAdminServiceClient = new AnalyticsAdminServiceClient();
// Prepare the request message.
$request = (new DeleteAccountRequest())
->setName($formattedName);
// Call the API and handle any network failures.
try {
$analyticsAdminServiceClient->deleteAccount($request);
printf('Call completed successfully.' . PHP_EOL);
} 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 = AnalyticsAdminServiceClient::accountName('[ACCOUNT]');
delete_account_sample($formattedName);
}
deleteConversionEvent
Deletes a conversion event in a property.
Parameters | |
---|---|
Name | Description |
name |
string
Required. The resource name of the conversion event to delete. Format: properties/{property}/conversionEvents/{conversion_event} Example: "properties/123/conversionEvents/456" |
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. |
use Google\Analytics\Admin\V1beta\Client\AnalyticsAdminServiceClient;
use Google\Analytics\Admin\V1beta\DeleteConversionEventRequest;
use Google\ApiCore\ApiException;
/**
* @param string $formattedName The resource name of the conversion event to delete.
* Format: properties/{property}/conversionEvents/{conversion_event}
* Example: "properties/123/conversionEvents/456"
* Please see {@see AnalyticsAdminServiceClient::conversionEventName()} for help formatting this field.
*/
function delete_conversion_event_sample(string $formattedName): void
{
// Create a client.
$analyticsAdminServiceClient = new AnalyticsAdminServiceClient();
// Prepare the request message.
$request = (new DeleteConversionEventRequest())
->setName($formattedName);
// Call the API and handle any network failures.
try {
$analyticsAdminServiceClient->deleteConversionEvent($request);
printf('Call completed successfully.' . PHP_EOL);
} 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 = AnalyticsAdminServiceClient::conversionEventName(
'[PROPERTY]',
'[CONVERSION_EVENT]'
);
delete_conversion_event_sample($formattedName);
}
deleteDataStream
Deletes a DataStream on a property.
Parameters | |
---|---|
Name | Description |
name |
string
Required. The name of the DataStream to delete. Example format: properties/1234/dataStreams/5678 |
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. |
use Google\Analytics\Admin\V1beta\Client\AnalyticsAdminServiceClient;
use Google\Analytics\Admin\V1beta\DeleteDataStreamRequest;
use Google\ApiCore\ApiException;
/**
* @param string $formattedName The name of the DataStream to delete.
* Example format: properties/1234/dataStreams/5678
* Please see {@see AnalyticsAdminServiceClient::dataStreamName()} for help formatting this field.
*/
function delete_data_stream_sample(string $formattedName): void
{
// Create a client.
$analyticsAdminServiceClient = new AnalyticsAdminServiceClient();
// Prepare the request message.
$request = (new DeleteDataStreamRequest())
->setName($formattedName);
// Call the API and handle any network failures.
try {
$analyticsAdminServiceClient->deleteDataStream($request);
printf('Call completed successfully.' . PHP_EOL);
} 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 = AnalyticsAdminServiceClient::dataStreamName('[PROPERTY]', '[DATA_STREAM]');
delete_data_stream_sample($formattedName);
}
deleteFirebaseLink
Deletes a FirebaseLink on a property
Parameters | |
---|---|
Name | Description |
name |
string
Required. Format: properties/{property_id}/firebaseLinks/{firebase_link_id} Example: properties/1234/firebaseLinks/5678 |
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. |
use Google\Analytics\Admin\V1beta\Client\AnalyticsAdminServiceClient;
use Google\Analytics\Admin\V1beta\DeleteFirebaseLinkRequest;
use Google\ApiCore\ApiException;
/**
* @param string $formattedName Format: properties/{property_id}/firebaseLinks/{firebase_link_id}
* Example: properties/1234/firebaseLinks/5678
* Please see {@see AnalyticsAdminServiceClient::firebaseLinkName()} for help formatting this field.
*/
function delete_firebase_link_sample(string $formattedName): void
{
// Create a client.
$analyticsAdminServiceClient = new AnalyticsAdminServiceClient();
// Prepare the request message.
$request = (new DeleteFirebaseLinkRequest())
->setName($formattedName);
// Call the API and handle any network failures.
try {
$analyticsAdminServiceClient->deleteFirebaseLink($request);
printf('Call completed successfully.' . PHP_EOL);
} 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 = AnalyticsAdminServiceClient::firebaseLinkName('[PROPERTY]', '[FIREBASE_LINK]');
delete_firebase_link_sample($formattedName);
}
deleteGoogleAdsLink
Deletes a GoogleAdsLink on a property
Parameters | |
---|---|
Name | Description |
name |
string
Required. Example format: properties/1234/googleAdsLinks/5678 |
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. |
use Google\Analytics\Admin\V1beta\Client\AnalyticsAdminServiceClient;
use Google\Analytics\Admin\V1beta\DeleteGoogleAdsLinkRequest;
use Google\ApiCore\ApiException;
/**
* @param string $formattedName Example format: properties/1234/googleAdsLinks/5678
* Please see {@see AnalyticsAdminServiceClient::googleAdsLinkName()} for help formatting this field.
*/
function delete_google_ads_link_sample(string $formattedName): void
{
// Create a client.
$analyticsAdminServiceClient = new AnalyticsAdminServiceClient();
// Prepare the request message.
$request = (new DeleteGoogleAdsLinkRequest())
->setName($formattedName);
// Call the API and handle any network failures.
try {
$analyticsAdminServiceClient->deleteGoogleAdsLink($request);
printf('Call completed successfully.' . PHP_EOL);
} 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 = AnalyticsAdminServiceClient::googleAdsLinkName('[PROPERTY]', '[GOOGLE_ADS_LINK]');
delete_google_ads_link_sample($formattedName);
}
deleteMeasurementProtocolSecret
Deletes target MeasurementProtocolSecret.
Parameters | |
---|---|
Name | Description |
name |
string
Required. The name of the MeasurementProtocolSecret to delete. Format: properties/{property}/dataStreams/{dataStream}/measurementProtocolSecrets/{measurementProtocolSecret} |
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. |
use Google\Analytics\Admin\V1beta\Client\AnalyticsAdminServiceClient;
use Google\Analytics\Admin\V1beta\DeleteMeasurementProtocolSecretRequest;
use Google\ApiCore\ApiException;
/**
* @param string $formattedName The name of the MeasurementProtocolSecret to delete.
* Format:
* properties/{property}/dataStreams/{dataStream}/measurementProtocolSecrets/{measurementProtocolSecret}
* Please see {@see AnalyticsAdminServiceClient::measurementProtocolSecretName()} for help formatting this field.
*/
function delete_measurement_protocol_secret_sample(string $formattedName): void
{
// Create a client.
$analyticsAdminServiceClient = new AnalyticsAdminServiceClient();
// Prepare the request message.
$request = (new DeleteMeasurementProtocolSecretRequest())
->setName($formattedName);
// Call the API and handle any network failures.
try {
$analyticsAdminServiceClient->deleteMeasurementProtocolSecret($request);
printf('Call completed successfully.' . PHP_EOL);
} 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 = AnalyticsAdminServiceClient::measurementProtocolSecretName(
'[PROPERTY]',
'[DATA_STREAM]',
'[MEASUREMENT_PROTOCOL_SECRET]'
);
delete_measurement_protocol_secret_sample($formattedName);
}
deleteProperty
Marks target Property as soft-deleted (ie: "trashed") and returns it.
This API does not have a method to restore soft-deleted properties. However, they can be restored using the Trash Can UI.
If the properties are not restored before the expiration time, the Property and all child resources (eg: GoogleAdsLinks, Streams, UserLinks) will be permanently purged. https://support.google.com/analytics/answer/6154772
Returns an error if the target is not found, or is not a GA4 Property.
Parameters | |
---|---|
Name | Description |
name |
string
Required. The name of the Property to soft-delete. Format: properties/{property_id} Example: "properties/1000" |
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 | |
---|---|
Type | Description |
Google\Analytics\Admin\V1beta\Property |
use Google\Analytics\Admin\V1beta\Client\AnalyticsAdminServiceClient;
use Google\Analytics\Admin\V1beta\DeletePropertyRequest;
use Google\Analytics\Admin\V1beta\Property;
use Google\ApiCore\ApiException;
/**
* @param string $formattedName The name of the Property to soft-delete.
* Format: properties/{property_id}
* Example: "properties/1000"
* Please see {@see AnalyticsAdminServiceClient::propertyName()} for help formatting this field.
*/
function delete_property_sample(string $formattedName): void
{
// Create a client.
$analyticsAdminServiceClient = new AnalyticsAdminServiceClient();
// Prepare the request message.
$request = (new DeletePropertyRequest())
->setName($formattedName);
// Call the API and handle any network failures.
try {
/** @var Property $response */
$response = $analyticsAdminServiceClient->deleteProperty($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 = AnalyticsAdminServiceClient::propertyName('[PROPERTY]');
delete_property_sample($formattedName);
}
getAccount
Lookup for a single Account.
Parameters | |
---|---|
Name | Description |
name |
string
Required. The name of the account to lookup. Format: accounts/{account} Example: "accounts/100" |
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 | |
---|---|
Type | Description |
Google\Analytics\Admin\V1beta\Account |
use Google\Analytics\Admin\V1beta\Account;
use Google\Analytics\Admin\V1beta\Client\AnalyticsAdminServiceClient;
use Google\Analytics\Admin\V1beta\GetAccountRequest;
use Google\ApiCore\ApiException;
/**
* @param string $formattedName The name of the account to lookup.
* Format: accounts/{account}
* Example: "accounts/100"
* Please see {@see AnalyticsAdminServiceClient::accountName()} for help formatting this field.
*/
function get_account_sample(string $formattedName): void
{
// Create a client.
$analyticsAdminServiceClient = new AnalyticsAdminServiceClient();
// Prepare the request message.
$request = (new GetAccountRequest())
->setName($formattedName);
// Call the API and handle any network failures.
try {
/** @var Account $response */
$response = $analyticsAdminServiceClient->getAccount($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 = AnalyticsAdminServiceClient::accountName('[ACCOUNT]');
get_account_sample($formattedName);
}
getConversionEvent
Retrieve a single conversion event.
Parameters | |
---|---|
Name | Description |
name |
string
Required. The resource name of the conversion event to retrieve. Format: properties/{property}/conversionEvents/{conversion_event} Example: "properties/123/conversionEvents/456" |
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 | |
---|---|
Type | Description |
Google\Analytics\Admin\V1beta\ConversionEvent |
use Google\Analytics\Admin\V1beta\Client\AnalyticsAdminServiceClient;
use Google\Analytics\Admin\V1beta\ConversionEvent;
use Google\Analytics\Admin\V1beta\GetConversionEventRequest;
use Google\ApiCore\ApiException;
/**
* @param string $formattedName The resource name of the conversion event to retrieve.
* Format: properties/{property}/conversionEvents/{conversion_event}
* Example: "properties/123/conversionEvents/456"
* Please see {@see AnalyticsAdminServiceClient::conversionEventName()} for help formatting this field.
*/
function get_conversion_event_sample(string $formattedName): void
{
// Create a client.
$analyticsAdminServiceClient = new AnalyticsAdminServiceClient();
// Prepare the request message.
$request = (new GetConversionEventRequest())
->setName($formattedName);
// Call the API and handle any network failures.
try {
/** @var ConversionEvent $response */
$response = $analyticsAdminServiceClient->getConversionEvent($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 = AnalyticsAdminServiceClient::conversionEventName(
'[PROPERTY]',
'[CONVERSION_EVENT]'
);
get_conversion_event_sample($formattedName);
}
getCustomDimension
Lookup for a single CustomDimension.
Parameters | |
---|---|
Name | Description |
name |
string
Required. The name of the CustomDimension to get. Example format: properties/1234/customDimensions/5678 |
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 | |
---|---|
Type | Description |
Google\Analytics\Admin\V1beta\CustomDimension |
use Google\Analytics\Admin\V1beta\Client\AnalyticsAdminServiceClient;
use Google\Analytics\Admin\V1beta\CustomDimension;
use Google\Analytics\Admin\V1beta\GetCustomDimensionRequest;
use Google\ApiCore\ApiException;
/**
* @param string $formattedName The name of the CustomDimension to get.
* Example format: properties/1234/customDimensions/5678
* Please see {@see AnalyticsAdminServiceClient::customDimensionName()} for help formatting this field.
*/
function get_custom_dimension_sample(string $formattedName): void
{
// Create a client.
$analyticsAdminServiceClient = new AnalyticsAdminServiceClient();
// Prepare the request message.
$request = (new GetCustomDimensionRequest())
->setName($formattedName);
// Call the API and handle any network failures.
try {
/** @var CustomDimension $response */
$response = $analyticsAdminServiceClient->getCustomDimension($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 = AnalyticsAdminServiceClient::customDimensionName(
'[PROPERTY]',
'[CUSTOM_DIMENSION]'
);
get_custom_dimension_sample($formattedName);
}
getCustomMetric
Lookup for a single CustomMetric.
Parameters | |
---|---|
Name | Description |
name |
string
Required. The name of the CustomMetric to get. Example format: properties/1234/customMetrics/5678 |
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 | |
---|---|
Type | Description |
Google\Analytics\Admin\V1beta\CustomMetric |
use Google\Analytics\Admin\V1beta\Client\AnalyticsAdminServiceClient;
use Google\Analytics\Admin\V1beta\CustomMetric;
use Google\Analytics\Admin\V1beta\GetCustomMetricRequest;
use Google\ApiCore\ApiException;
/**
* @param string $formattedName The name of the CustomMetric to get.
* Example format: properties/1234/customMetrics/5678
* Please see {@see AnalyticsAdminServiceClient::customMetricName()} for help formatting this field.
*/
function get_custom_metric_sample(string $formattedName): void
{
// Create a client.
$analyticsAdminServiceClient = new AnalyticsAdminServiceClient();
// Prepare the request message.
$request = (new GetCustomMetricRequest())
->setName($formattedName);
// Call the API and handle any network failures.
try {
/** @var CustomMetric $response */
$response = $analyticsAdminServiceClient->getCustomMetric($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 = AnalyticsAdminServiceClient::customMetricName('[PROPERTY]', '[CUSTOM_METRIC]');
get_custom_metric_sample($formattedName);
}
getDataRetentionSettings
Returns the singleton data retention settings for this property.
Parameters | |
---|---|
Name | Description |
name |
string
Required. The name of the settings to lookup. Format: properties/{property}/dataRetentionSettings Example: "properties/1000/dataRetentionSettings" |
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 | |
---|---|
Type | Description |
Google\Analytics\Admin\V1beta\DataRetentionSettings |
use Google\Analytics\Admin\V1beta\Client\AnalyticsAdminServiceClient;
use Google\Analytics\Admin\V1beta\DataRetentionSettings;
use Google\Analytics\Admin\V1beta\GetDataRetentionSettingsRequest;
use Google\ApiCore\ApiException;
/**
* @param string $formattedName The name of the settings to lookup.
* Format:
* properties/{property}/dataRetentionSettings
* Example: "properties/1000/dataRetentionSettings"
* Please see {@see AnalyticsAdminServiceClient::dataRetentionSettingsName()} for help formatting this field.
*/
function get_data_retention_settings_sample(string $formattedName): void
{
// Create a client.
$analyticsAdminServiceClient = new AnalyticsAdminServiceClient();
// Prepare the request message.
$request = (new GetDataRetentionSettingsRequest())
->setName($formattedName);
// Call the API and handle any network failures.
try {
/** @var DataRetentionSettings $response */
$response = $analyticsAdminServiceClient->getDataRetentionSettings($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 = AnalyticsAdminServiceClient::dataRetentionSettingsName('[PROPERTY]');
get_data_retention_settings_sample($formattedName);
}
getDataSharingSettings
Get data sharing settings on an account.
Data sharing settings are singletons.
Parameters | |
---|---|
Name | Description |
name |
string
Required. The name of the settings to lookup. Format: accounts/{account}/dataSharingSettings Example: "accounts/1000/dataSharingSettings" |
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 | |
---|---|
Type | Description |
Google\Analytics\Admin\V1beta\DataSharingSettings |
use Google\Analytics\Admin\V1beta\Client\AnalyticsAdminServiceClient;
use Google\Analytics\Admin\V1beta\DataSharingSettings;
use Google\Analytics\Admin\V1beta\GetDataSharingSettingsRequest;
use Google\ApiCore\ApiException;
/**
* @param string $formattedName The name of the settings to lookup.
* Format: accounts/{account}/dataSharingSettings
* Example: "accounts/1000/dataSharingSettings"
* Please see {@see AnalyticsAdminServiceClient::dataSharingSettingsName()} for help formatting this field.
*/
function get_data_sharing_settings_sample(string $formattedName): void
{
// Create a client.
$analyticsAdminServiceClient = new AnalyticsAdminServiceClient();
// Prepare the request message.
$request = (new GetDataSharingSettingsRequest())
->setName($formattedName);
// Call the API and handle any network failures.
try {
/** @var DataSharingSettings $response */
$response = $analyticsAdminServiceClient->getDataSharingSettings($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 = AnalyticsAdminServiceClient::dataSharingSettingsName('[ACCOUNT]');
get_data_sharing_settings_sample($formattedName);
}
getDataStream
Lookup for a single DataStream.
Parameters | |
---|---|
Name | Description |
name |
string
Required. The name of the DataStream to get. Example format: properties/1234/dataStreams/5678 |
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 | |
---|---|
Type | Description |
Google\Analytics\Admin\V1beta\DataStream |
use Google\Analytics\Admin\V1beta\Client\AnalyticsAdminServiceClient;
use Google\Analytics\Admin\V1beta\DataStream;
use Google\Analytics\Admin\V1beta\GetDataStreamRequest;
use Google\ApiCore\ApiException;
/**
* @param string $formattedName The name of the DataStream to get.
* Example format: properties/1234/dataStreams/5678
* Please see {@see AnalyticsAdminServiceClient::dataStreamName()} for help formatting this field.
*/
function get_data_stream_sample(string $formattedName): void
{
// Create a client.
$analyticsAdminServiceClient = new AnalyticsAdminServiceClient();
// Prepare the request message.
$request = (new GetDataStreamRequest())
->setName($formattedName);
// Call the API and handle any network failures.
try {
/** @var DataStream $response */
$response = $analyticsAdminServiceClient->getDataStream($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 = AnalyticsAdminServiceClient::dataStreamName('[PROPERTY]', '[DATA_STREAM]');
get_data_stream_sample($formattedName);
}
getMeasurementProtocolSecret
Lookup for a single "GA4" MeasurementProtocolSecret.
Parameters | |
---|---|
Name | Description |
name |
string
Required. The name of the measurement protocol secret to lookup. Format: properties/{property}/dataStreams/{dataStream}/measurementProtocolSecrets/{measurementProtocolSecret} |
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 | |
---|---|
Type | Description |
Google\Analytics\Admin\V1beta\MeasurementProtocolSecret |
use Google\Analytics\Admin\V1beta\Client\AnalyticsAdminServiceClient;
use Google\Analytics\Admin\V1beta\GetMeasurementProtocolSecretRequest;
use Google\Analytics\Admin\V1beta\MeasurementProtocolSecret;
use Google\ApiCore\ApiException;
/**
* @param string $formattedName The name of the measurement protocol secret to lookup.
* Format:
* properties/{property}/dataStreams/{dataStream}/measurementProtocolSecrets/{measurementProtocolSecret}
* Please see {@see AnalyticsAdminServiceClient::measurementProtocolSecretName()} for help formatting this field.
*/
function get_measurement_protocol_secret_sample(string $formattedName): void
{
// Create a client.
$analyticsAdminServiceClient = new AnalyticsAdminServiceClient();
// Prepare the request message.
$request = (new GetMeasurementProtocolSecretRequest())
->setName($formattedName);
// Call the API and handle any network failures.
try {
/** @var MeasurementProtocolSecret $response */
$response = $analyticsAdminServiceClient->getMeasurementProtocolSecret($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 = AnalyticsAdminServiceClient::measurementProtocolSecretName(
'[PROPERTY]',
'[DATA_STREAM]',
'[MEASUREMENT_PROTOCOL_SECRET]'
);
get_measurement_protocol_secret_sample($formattedName);
}
getProperty
Lookup for a single "GA4" Property.
Parameters | |
---|---|
Name | Description |
name |
string
Required. The name of the property to lookup. Format: properties/{property_id} Example: "properties/1000" |
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 | |
---|---|
Type | Description |
Google\Analytics\Admin\V1beta\Property |
use Google\Analytics\Admin\V1beta\Client\AnalyticsAdminServiceClient;
use Google\Analytics\Admin\V1beta\GetPropertyRequest;
use Google\Analytics\Admin\V1beta\Property;
use Google\ApiCore\ApiException;
/**
* @param string $formattedName The name of the property to lookup.
* Format: properties/{property_id}
* Example: "properties/1000"
* Please see {@see AnalyticsAdminServiceClient::propertyName()} for help formatting this field.
*/
function get_property_sample(string $formattedName): void
{
// Create a client.
$analyticsAdminServiceClient = new AnalyticsAdminServiceClient();
// Prepare the request message.
$request = (new GetPropertyRequest())
->setName($formattedName);
// Call the API and handle any network failures.
try {
/** @var Property $response */
$response = $analyticsAdminServiceClient->getProperty($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 = AnalyticsAdminServiceClient::propertyName('[PROPERTY]');
get_property_sample($formattedName);
}
listAccountSummaries
Returns summaries of all accounts accessible by the caller.
Parameters | |
---|---|
Name | Description |
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 | |
---|---|
Type | Description |
Google\ApiCore\PagedListResponse |
use Google\Analytics\Admin\V1beta\AccountSummary;
use Google\Analytics\Admin\V1beta\Client\AnalyticsAdminServiceClient;
use Google\Analytics\Admin\V1beta\ListAccountSummariesRequest;
use Google\ApiCore\ApiException;
use Google\ApiCore\PagedListResponse;
/**
* 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 list_account_summaries_sample(): void
{
// Create a client.
$analyticsAdminServiceClient = new AnalyticsAdminServiceClient();
// Prepare the request message.
$request = new ListAccountSummariesRequest();
// Call the API and handle any network failures.
try {
/** @var PagedListResponse $response */
$response = $analyticsAdminServiceClient->listAccountSummaries($request);
/** @var AccountSummary $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());
}
}
listAccounts
Returns all accounts accessible by the caller.
Note that these accounts might not currently have GA4 properties. Soft-deleted (ie: "trashed") accounts are excluded by default. Returns an empty list if no relevant accounts are found.
Parameters | |
---|---|
Name | Description |
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. |
↳ showDeleted |
bool
Whether to include soft-deleted (ie: "trashed") Accounts in the results. Accounts can be inspected to determine whether they are deleted or not. |
↳ 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\Admin\V1beta\Account;
use Google\Analytics\Admin\V1beta\Client\AnalyticsAdminServiceClient;
use Google\Analytics\Admin\V1beta\ListAccountsRequest;
use Google\ApiCore\ApiException;
use Google\ApiCore\PagedListResponse;
/**
* 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 list_accounts_sample(): void
{
// Create a client.
$analyticsAdminServiceClient = new AnalyticsAdminServiceClient();
// Prepare the request message.
$request = new ListAccountsRequest();
// Call the API and handle any network failures.
try {
/** @var PagedListResponse $response */
$response = $analyticsAdminServiceClient->listAccounts($request);
/** @var Account $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());
}
}
listConversionEvents
Returns a list of conversion events in the specified parent property.
Returns an empty list if no conversion events are found.
Parameters | |
---|---|
Name | Description |
parent |
string
Required. The resource name of the parent property. Example: 'properties/123' |
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 | |
---|---|
Type | Description |
Google\ApiCore\PagedListResponse |
use Google\Analytics\Admin\V1beta\Client\AnalyticsAdminServiceClient;
use Google\Analytics\Admin\V1beta\ConversionEvent;
use Google\Analytics\Admin\V1beta\ListConversionEventsRequest;
use Google\ApiCore\ApiException;
use Google\ApiCore\PagedListResponse;
/**
* @param string $formattedParent The resource name of the parent property.
* Example: 'properties/123'
* Please see {@see AnalyticsAdminServiceClient::propertyName()} for help formatting this field.
*/
function list_conversion_events_sample(string $formattedParent): void
{
// Create a client.
$analyticsAdminServiceClient = new AnalyticsAdminServiceClient();
// Prepare the request message.
$request = (new ListConversionEventsRequest())
->setParent($formattedParent);
// Call the API and handle any network failures.
try {
/** @var PagedListResponse $response */
$response = $analyticsAdminServiceClient->listConversionEvents($request);
/** @var ConversionEvent $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 = AnalyticsAdminServiceClient::propertyName('[PROPERTY]');
list_conversion_events_sample($formattedParent);
}
listCustomDimensions
Lists CustomDimensions on a property.
Parameters | |
---|---|
Name | Description |
parent |
string
Required. Example format: properties/1234 |
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 | |
---|---|
Type | Description |
Google\ApiCore\PagedListResponse |
use Google\Analytics\Admin\V1beta\Client\AnalyticsAdminServiceClient;
use Google\Analytics\Admin\V1beta\CustomDimension;
use Google\Analytics\Admin\V1beta\ListCustomDimensionsRequest;
use Google\ApiCore\ApiException;
use Google\ApiCore\PagedListResponse;
/**
* @param string $formattedParent Example format: properties/1234
* Please see {@see AnalyticsAdminServiceClient::propertyName()} for help formatting this field.
*/
function list_custom_dimensions_sample(string $formattedParent): void
{
// Create a client.
$analyticsAdminServiceClient = new AnalyticsAdminServiceClient();
// Prepare the request message.
$request = (new ListCustomDimensionsRequest())
->setParent($formattedParent);
// Call the API and handle any network failures.
try {
/** @var PagedListResponse $response */
$response = $analyticsAdminServiceClient->listCustomDimensions($request);
/** @var CustomDimension $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 = AnalyticsAdminServiceClient::propertyName('[PROPERTY]');
list_custom_dimensions_sample($formattedParent);
}
listCustomMetrics
Lists CustomMetrics on a property.
Parameters | |
---|---|
Name | Description |
parent |
string
Required. Example format: properties/1234 |
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 | |
---|---|
Type | Description |
Google\ApiCore\PagedListResponse |
use Google\Analytics\Admin\V1beta\Client\AnalyticsAdminServiceClient;
use Google\Analytics\Admin\V1beta\CustomMetric;
use Google\Analytics\Admin\V1beta\ListCustomMetricsRequest;
use Google\ApiCore\ApiException;
use Google\ApiCore\PagedListResponse;
/**
* @param string $formattedParent Example format: properties/1234
* Please see {@see AnalyticsAdminServiceClient::propertyName()} for help formatting this field.
*/
function list_custom_metrics_sample(string $formattedParent): void
{
// Create a client.
$analyticsAdminServiceClient = new AnalyticsAdminServiceClient();
// Prepare the request message.
$request = (new ListCustomMetricsRequest())
->setParent($formattedParent);
// Call the API and handle any network failures.
try {
/** @var PagedListResponse $response */
$response = $analyticsAdminServiceClient->listCustomMetrics($request);
/** @var CustomMetric $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 = AnalyticsAdminServiceClient::propertyName('[PROPERTY]');
list_custom_metrics_sample($formattedParent);
}
listDataStreams
Lists DataStreams on a property.
Parameters | |
---|---|
Name | Description |
parent |
string
Required. Example format: properties/1234 |
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 | |
---|---|
Type | Description |
Google\ApiCore\PagedListResponse |
use Google\Analytics\Admin\V1beta\Client\AnalyticsAdminServiceClient;
use Google\Analytics\Admin\V1beta\DataStream;
use Google\Analytics\Admin\V1beta\ListDataStreamsRequest;
use Google\ApiCore\ApiException;
use Google\ApiCore\PagedListResponse;
/**
* @param string $formattedParent Example format: properties/1234
* Please see {@see AnalyticsAdminServiceClient::propertyName()} for help formatting this field.
*/
function list_data_streams_sample(string $formattedParent): void
{
// Create a client.
$analyticsAdminServiceClient = new AnalyticsAdminServiceClient();
// Prepare the request message.
$request = (new ListDataStreamsRequest())
->setParent($formattedParent);
// Call the API and handle any network failures.
try {
/** @var PagedListResponse $response */
$response = $analyticsAdminServiceClient->listDataStreams($request);
/** @var DataStream $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 = AnalyticsAdminServiceClient::propertyName('[PROPERTY]');
list_data_streams_sample($formattedParent);
}
listFirebaseLinks
Lists FirebaseLinks on a property.
Properties can have at most one FirebaseLink.
Parameters | |
---|---|
Name | Description |
parent |
string
Required. Format: properties/{property_id} Example: properties/1234 |
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 | |
---|---|
Type | Description |
Google\ApiCore\PagedListResponse |
use Google\Analytics\Admin\V1beta\Client\AnalyticsAdminServiceClient;
use Google\Analytics\Admin\V1beta\FirebaseLink;
use Google\Analytics\Admin\V1beta\ListFirebaseLinksRequest;
use Google\ApiCore\ApiException;
use Google\ApiCore\PagedListResponse;
/**
* @param string $formattedParent Format: properties/{property_id}
* Example: properties/1234
* Please see {@see AnalyticsAdminServiceClient::propertyName()} for help formatting this field.
*/
function list_firebase_links_sample(string $formattedParent): void
{
// Create a client.
$analyticsAdminServiceClient = new AnalyticsAdminServiceClient();
// Prepare the request message.
$request = (new ListFirebaseLinksRequest())
->setParent($formattedParent);
// Call the API and handle any network failures.
try {
/** @var PagedListResponse $response */
$response = $analyticsAdminServiceClient->listFirebaseLinks($request);
/** @var FirebaseLink $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 = AnalyticsAdminServiceClient::propertyName('[PROPERTY]');
list_firebase_links_sample($formattedParent);
}
listGoogleAdsLinks
Lists GoogleAdsLinks on a property.
Parameters | |
---|---|
Name | Description |
parent |
string
Required. Example format: properties/1234 |
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 | |
---|---|
Type | Description |
Google\ApiCore\PagedListResponse |
use Google\Analytics\Admin\V1beta\Client\AnalyticsAdminServiceClient;
use Google\Analytics\Admin\V1beta\GoogleAdsLink;
use Google\Analytics\Admin\V1beta\ListGoogleAdsLinksRequest;
use Google\ApiCore\ApiException;
use Google\ApiCore\PagedListResponse;
/**
* @param string $formattedParent Example format: properties/1234
* Please see {@see AnalyticsAdminServiceClient::propertyName()} for help formatting this field.
*/
function list_google_ads_links_sample(string $formattedParent): void
{
// Create a client.
$analyticsAdminServiceClient = new AnalyticsAdminServiceClient();
// Prepare the request message.
$request = (new ListGoogleAdsLinksRequest())
->setParent($formattedParent);
// Call the API and handle any network failures.
try {
/** @var PagedListResponse $response */
$response = $analyticsAdminServiceClient->listGoogleAdsLinks($request);
/** @var GoogleAdsLink $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 = AnalyticsAdminServiceClient::propertyName('[PROPERTY]');
list_google_ads_links_sample($formattedParent);
}
listMeasurementProtocolSecrets
Returns child MeasurementProtocolSecrets under the specified parent Property.
Parameters | |
---|---|
Name | Description |
parent |
string
Required. The resource name of the parent stream. Format: properties/{property}/dataStreams/{dataStream}/measurementProtocolSecrets |
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 | |
---|---|
Type | Description |
Google\ApiCore\PagedListResponse |
use Google\Analytics\Admin\V1beta\Client\AnalyticsAdminServiceClient;
use Google\Analytics\Admin\V1beta\ListMeasurementProtocolSecretsRequest;
use Google\Analytics\Admin\V1beta\MeasurementProtocolSecret;
use Google\ApiCore\ApiException;
use Google\ApiCore\PagedListResponse;
/**
* @param string $formattedParent The resource name of the parent stream.
* Format:
* properties/{property}/dataStreams/{dataStream}/measurementProtocolSecrets
* Please see {@see AnalyticsAdminServiceClient::dataStreamName()} for help formatting this field.
*/
function list_measurement_protocol_secrets_sample(string $formattedParent): void
{
// Create a client.
$analyticsAdminServiceClient = new AnalyticsAdminServiceClient();
// Prepare the request message.
$request = (new ListMeasurementProtocolSecretsRequest())
->setParent($formattedParent);
// Call the API and handle any network failures.
try {
/** @var PagedListResponse $response */
$response = $analyticsAdminServiceClient->listMeasurementProtocolSecrets($request);
/** @var MeasurementProtocolSecret $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 = AnalyticsAdminServiceClient::dataStreamName('[PROPERTY]', '[DATA_STREAM]');
list_measurement_protocol_secrets_sample($formattedParent);
}
listProperties
Returns child Properties under the specified parent Account.
Only "GA4" properties will be returned. Properties will be excluded if the caller does not have access. Soft-deleted (ie: "trashed") properties are excluded by default. Returns an empty list if no relevant properties are found.
Parameters | |
---|---|
Name | Description |
filter |
string
Required. An expression for filtering the results of the request.
Fields eligible for filtering are:
|
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. |
↳ showDeleted |
bool
Whether to include soft-deleted (ie: "trashed") Properties in the results. Properties can be inspected to determine whether they are deleted or not. |
↳ 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\Admin\V1beta\Client\AnalyticsAdminServiceClient;
use Google\Analytics\Admin\V1beta\ListPropertiesRequest;
use Google\Analytics\Admin\V1beta\Property;
use Google\ApiCore\ApiException;
use Google\ApiCore\PagedListResponse;
/**
* @param string $filter An expression for filtering the results of the request.
* Fields eligible for filtering are:
* `parent:`(The resource name of the parent account/property) or
* `ancestor:`(The resource name of the parent account) or
* `firebase_project:`(The id or number of the linked firebase project).
* Some examples of filters:
*
* ```
* | Filter | Description |
* |-----------------------------|-------------------------------------------|
* | parent:accounts/123 | The account with account id: 123. |
* | parent:properties/123 | The property with property id: 123. |
* | ancestor:accounts/123 | The account with account id: 123. |
* | firebase_project:project-id | The firebase project with id: project-id. |
* | firebase_project:123 | The firebase project with number: 123. |
* ```
*/
function list_properties_sample(string $filter): void
{
// Create a client.
$analyticsAdminServiceClient = new AnalyticsAdminServiceClient();
// Prepare the request message.
$request = (new ListPropertiesRequest())
->setFilter($filter);
// Call the API and handle any network failures.
try {
/** @var PagedListResponse $response */
$response = $analyticsAdminServiceClient->listProperties($request);
/** @var Property $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
{
$filter = '[FILTER]';
list_properties_sample($filter);
}
provisionAccountTicket
Requests a ticket for creating an account.
Parameters | |
---|---|
Name | Description |
optionalArgs |
array
Optional. |
↳ account |
Account
The account to create. |
↳ redirectUri |
string
Redirect URI where the user will be sent after accepting Terms of Service. Must be configured in Cloud Console as a Redirect URI. |
↳ 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\Admin\V1beta\ProvisionAccountTicketResponse |
use Google\Analytics\Admin\V1beta\Client\AnalyticsAdminServiceClient;
use Google\Analytics\Admin\V1beta\ProvisionAccountTicketRequest;
use Google\Analytics\Admin\V1beta\ProvisionAccountTicketResponse;
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 provision_account_ticket_sample(): void
{
// Create a client.
$analyticsAdminServiceClient = new AnalyticsAdminServiceClient();
// Prepare the request message.
$request = new ProvisionAccountTicketRequest();
// Call the API and handle any network failures.
try {
/** @var ProvisionAccountTicketResponse $response */
$response = $analyticsAdminServiceClient->provisionAccountTicket($request);
printf('Response data: %s' . PHP_EOL, $response->serializeToJsonString());
} catch (ApiException $ex) {
printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage());
}
}
runAccessReport
Returns a customized report of data access records. The report provides records of each time a user reads Google Analytics reporting data. Access records are retained for up to 2 years.
Data Access Reports can be requested for a property. The property must be in Google Analytics 360. This method is only available to Administrators.
These data access records include GA4 UI Reporting, GA4 UI Explorations, GA4 Data API, and other products like Firebase & Admob that can retrieve data from Google Analytics through a linkage. These records don't include property configuration changes like adding a stream or changing a property's time zone. For configuration change history, see searchChangeHistoryEvents.
Parameters | |
---|---|
Name | Description |
optionalArgs |
array
Optional. |
↳ entity |
string
The Data Access Report supports requesting at the property level or account level. If requested at the account level, Data Access Reports include all access for all properties under that account. To request at the property level, entity should be for example 'properties/123' if "123" is your GA4 property ID. To request at the account level, entity should be for example 'accounts/1234' if "1234" is your GA4 Account ID. |
↳ dimensions |
AccessDimension[]
The dimensions requested and displayed in the response. Requests are allowed up to 9 dimensions. |
↳ metrics |
AccessMetric[]
The metrics requested and displayed in the response. Requests are allowed up to 10 metrics. |
↳ dateRanges |
AccessDateRange[]
Date ranges of access records 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 access records for the overlapping days is included in the response rows for both date ranges. Requests are allowed up to 2 date ranges. |
↳ dimensionFilter |
AccessFilterExpression
Dimension filters let you restrict report response to specific dimension values which match the filter. For example, filtering on access records of a single user. To learn more, see Fundamentals of Dimension Filters for examples. Metrics cannot be used in this filter. |
↳ metricFilter |
AccessFilterExpression
Metric filters allow you to restrict report response to specific metric values which match the filter. Metric filters are applied after aggregating the report's rows, similar to SQL having-clause. Dimensions cannot be used in this filter. |
↳ offset |
int
The row count of the start row. The first row is counted as row 0. If offset is unspecified, it is treated as 0. If offset is zero, then this method will return the first page of results with |
↳ limit |
int
The number of rows to return. If unspecified, 10,000 rows are returned. The API returns a maximum of 100,000 rows per request, no matter how many you ask for. |
↳ timeZone |
string
This request's time zone if specified. If unspecified, the property's time zone is used. The request's time zone is used to interpret the start & end dates of the report. Formatted as strings from the IANA Time Zone database (https://www.iana.org/time-zones); for example "America/New_York" or "Asia/Tokyo". |
↳ orderBys |
AccessOrderBy[]
Specifies how rows are ordered in the response. |
↳ returnEntityQuota |
bool
Toggles whether to return the current state of this Analytics Property's quota. Quota is returned in AccessQuota. For account-level requests, this field must be false. |
↳ 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\Admin\V1beta\RunAccessReportResponse |
use Google\Analytics\Admin\V1beta\Client\AnalyticsAdminServiceClient;
use Google\Analytics\Admin\V1beta\RunAccessReportRequest;
use Google\Analytics\Admin\V1beta\RunAccessReportResponse;
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_access_report_sample(): void
{
// Create a client.
$analyticsAdminServiceClient = new AnalyticsAdminServiceClient();
// Prepare the request message.
$request = new RunAccessReportRequest();
// Call the API and handle any network failures.
try {
/** @var RunAccessReportResponse $response */
$response = $analyticsAdminServiceClient->runAccessReport($request);
printf('Response data: %s' . PHP_EOL, $response->serializeToJsonString());
} catch (ApiException $ex) {
printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage());
}
}
searchChangeHistoryEvents
Searches through all changes to an account or its children given the specified set of filters.
Parameters | |
---|---|
Name | Description |
account |
string
Required. The account resource for which to return change history resources. |
optionalArgs |
array
Optional. |
↳ property |
string
Optional. Resource name for a child property. If set, only return changes made to this property or its child resources. |
↳ resourceType |
int[]
Optional. If set, only return changes if they are for a resource that matches at least one of these types. For allowed values, use constants defined on Google\Analytics\Admin\V1beta\ChangeHistoryResourceType |
↳ action |
int[]
Optional. If set, only return changes that match one or more of these types of actions. For allowed values, use constants defined on Google\Analytics\Admin\V1beta\ActionType |
↳ actorEmail |
string[]
Optional. If set, only return changes if they are made by a user in this list. |
↳ earliestChangeTime |
Timestamp
Optional. If set, only return changes made after this time (inclusive). |
↳ latestChangeTime |
Timestamp
Optional. If set, only return changes made before this time (inclusive). |
↳ 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 | |
---|---|
Type | Description |
Google\ApiCore\PagedListResponse |
use Google\Analytics\Admin\V1beta\ChangeHistoryEvent;
use Google\Analytics\Admin\V1beta\Client\AnalyticsAdminServiceClient;
use Google\Analytics\Admin\V1beta\SearchChangeHistoryEventsRequest;
use Google\ApiCore\ApiException;
use Google\ApiCore\PagedListResponse;
/**
* @param string $formattedAccount The account resource for which to return change history
* resources. Please see
* {@see AnalyticsAdminServiceClient::accountName()} for help formatting this field.
*/
function search_change_history_events_sample(string $formattedAccount): void
{
// Create a client.
$analyticsAdminServiceClient = new AnalyticsAdminServiceClient();
// Prepare the request message.
$request = (new SearchChangeHistoryEventsRequest())
->setAccount($formattedAccount);
// Call the API and handle any network failures.
try {
/** @var PagedListResponse $response */
$response = $analyticsAdminServiceClient->searchChangeHistoryEvents($request);
/** @var ChangeHistoryEvent $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
{
$formattedAccount = AnalyticsAdminServiceClient::accountName('[ACCOUNT]');
search_change_history_events_sample($formattedAccount);
}
updateAccount
Updates an account.
Parameters | |
---|---|
Name | Description |
account |
Google\Analytics\Admin\V1beta\Account
Required. The account to update.
The account's |
updateMask |
Google\Protobuf\FieldMask
Required. The list of fields to be updated. Field names must be in snake case (for example, "field_to_update"). Omitted fields will not be updated. To replace the entire entity, use one path with the string "*" to match all fields. |
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 | |
---|---|
Type | Description |
Google\Analytics\Admin\V1beta\Account |
use Google\Analytics\Admin\V1beta\Account;
use Google\Analytics\Admin\V1beta\Client\AnalyticsAdminServiceClient;
use Google\Analytics\Admin\V1beta\UpdateAccountRequest;
use Google\ApiCore\ApiException;
use Google\Protobuf\FieldMask;
/**
* @param string $accountDisplayName Human-readable display name for this account.
*/
function update_account_sample(string $accountDisplayName): void
{
// Create a client.
$analyticsAdminServiceClient = new AnalyticsAdminServiceClient();
// Prepare the request message.
$account = (new Account())
->setDisplayName($accountDisplayName);
$updateMask = new FieldMask();
$request = (new UpdateAccountRequest())
->setAccount($account)
->setUpdateMask($updateMask);
// Call the API and handle any network failures.
try {
/** @var Account $response */
$response = $analyticsAdminServiceClient->updateAccount($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
{
$accountDisplayName = '[DISPLAY_NAME]';
update_account_sample($accountDisplayName);
}
updateConversionEvent
Updates a conversion event with the specified attributes.
Parameters | |
---|---|
Name | Description |
conversionEvent |
Google\Analytics\Admin\V1beta\ConversionEvent
Required. The conversion event to update.
The |
updateMask |
Google\Protobuf\FieldMask
Required. The list of fields to be updated. Field names must be in snake case (e.g., "field_to_update"). Omitted fields will not be updated. To replace the entire entity, use one path with the string "*" to match all fields. |
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 | |
---|---|
Type | Description |
Google\Analytics\Admin\V1beta\ConversionEvent |
use Google\Analytics\Admin\V1beta\Client\AnalyticsAdminServiceClient;
use Google\Analytics\Admin\V1beta\ConversionEvent;
use Google\Analytics\Admin\V1beta\UpdateConversionEventRequest;
use Google\ApiCore\ApiException;
use Google\Protobuf\FieldMask;
/**
* 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 update_conversion_event_sample(): void
{
// Create a client.
$analyticsAdminServiceClient = new AnalyticsAdminServiceClient();
// Prepare the request message.
$conversionEvent = new ConversionEvent();
$updateMask = new FieldMask();
$request = (new UpdateConversionEventRequest())
->setConversionEvent($conversionEvent)
->setUpdateMask($updateMask);
// Call the API and handle any network failures.
try {
/** @var ConversionEvent $response */
$response = $analyticsAdminServiceClient->updateConversionEvent($request);
printf('Response data: %s' . PHP_EOL, $response->serializeToJsonString());
} catch (ApiException $ex) {
printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage());
}
}
updateCustomDimension
Updates a CustomDimension on a property.
Parameters | |
---|---|
Name | Description |
updateMask |
Google\Protobuf\FieldMask
Required. The list of fields to be updated. Omitted fields will not be updated. To replace the entire entity, use one path with the string "*" to match all fields. |
optionalArgs |
array
Optional. |
↳ customDimension |
CustomDimension
The CustomDimension to update |
↳ 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\Admin\V1beta\CustomDimension |
use Google\Analytics\Admin\V1beta\Client\AnalyticsAdminServiceClient;
use Google\Analytics\Admin\V1beta\CustomDimension;
use Google\Analytics\Admin\V1beta\UpdateCustomDimensionRequest;
use Google\ApiCore\ApiException;
use Google\Protobuf\FieldMask;
/**
* 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 update_custom_dimension_sample(): void
{
// Create a client.
$analyticsAdminServiceClient = new AnalyticsAdminServiceClient();
// Prepare the request message.
$updateMask = new FieldMask();
$request = (new UpdateCustomDimensionRequest())
->setUpdateMask($updateMask);
// Call the API and handle any network failures.
try {
/** @var CustomDimension $response */
$response = $analyticsAdminServiceClient->updateCustomDimension($request);
printf('Response data: %s' . PHP_EOL, $response->serializeToJsonString());
} catch (ApiException $ex) {
printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage());
}
}
updateCustomMetric
Updates a CustomMetric on a property.
Parameters | |
---|---|
Name | Description |
updateMask |
Google\Protobuf\FieldMask
Required. The list of fields to be updated. Omitted fields will not be updated. To replace the entire entity, use one path with the string "*" to match all fields. |
optionalArgs |
array
Optional. |
↳ customMetric |
CustomMetric
The CustomMetric to update |
↳ 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\Admin\V1beta\CustomMetric |
use Google\Analytics\Admin\V1beta\Client\AnalyticsAdminServiceClient;
use Google\Analytics\Admin\V1beta\CustomMetric;
use Google\Analytics\Admin\V1beta\UpdateCustomMetricRequest;
use Google\ApiCore\ApiException;
use Google\Protobuf\FieldMask;
/**
* 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 update_custom_metric_sample(): void
{
// Create a client.
$analyticsAdminServiceClient = new AnalyticsAdminServiceClient();
// Prepare the request message.
$updateMask = new FieldMask();
$request = (new UpdateCustomMetricRequest())
->setUpdateMask($updateMask);
// Call the API and handle any network failures.
try {
/** @var CustomMetric $response */
$response = $analyticsAdminServiceClient->updateCustomMetric($request);
printf('Response data: %s' . PHP_EOL, $response->serializeToJsonString());
} catch (ApiException $ex) {
printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage());
}
}
updateDataRetentionSettings
Updates the singleton data retention settings for this property.
Parameters | |
---|---|
Name | Description |
dataRetentionSettings |
Google\Analytics\Admin\V1beta\DataRetentionSettings
Required. The settings to update.
The |
updateMask |
Google\Protobuf\FieldMask
Required. The list of fields to be updated. Field names must be in snake case (e.g., "field_to_update"). Omitted fields will not be updated. To replace the entire entity, use one path with the string "*" to match all fields. |
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 | |
---|---|
Type | Description |
Google\Analytics\Admin\V1beta\DataRetentionSettings |
use Google\Analytics\Admin\V1beta\Client\AnalyticsAdminServiceClient;
use Google\Analytics\Admin\V1beta\DataRetentionSettings;
use Google\Analytics\Admin\V1beta\UpdateDataRetentionSettingsRequest;
use Google\ApiCore\ApiException;
use Google\Protobuf\FieldMask;
/**
* 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 update_data_retention_settings_sample(): void
{
// Create a client.
$analyticsAdminServiceClient = new AnalyticsAdminServiceClient();
// Prepare the request message.
$dataRetentionSettings = new DataRetentionSettings();
$updateMask = new FieldMask();
$request = (new UpdateDataRetentionSettingsRequest())
->setDataRetentionSettings($dataRetentionSettings)
->setUpdateMask($updateMask);
// Call the API and handle any network failures.
try {
/** @var DataRetentionSettings $response */
$response = $analyticsAdminServiceClient->updateDataRetentionSettings($request);
printf('Response data: %s' . PHP_EOL, $response->serializeToJsonString());
} catch (ApiException $ex) {
printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage());
}
}
updateDataStream
Updates a DataStream on a property.
Parameters | |
---|---|
Name | Description |
updateMask |
Google\Protobuf\FieldMask
Required. The list of fields to be updated. Omitted fields will not be updated. To replace the entire entity, use one path with the string "*" to match all fields. |
optionalArgs |
array
Optional. |
↳ dataStream |
DataStream
The DataStream to update |
↳ 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\Admin\V1beta\DataStream |
use Google\Analytics\Admin\V1beta\Client\AnalyticsAdminServiceClient;
use Google\Analytics\Admin\V1beta\DataStream;
use Google\Analytics\Admin\V1beta\UpdateDataStreamRequest;
use Google\ApiCore\ApiException;
use Google\Protobuf\FieldMask;
/**
* 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 update_data_stream_sample(): void
{
// Create a client.
$analyticsAdminServiceClient = new AnalyticsAdminServiceClient();
// Prepare the request message.
$updateMask = new FieldMask();
$request = (new UpdateDataStreamRequest())
->setUpdateMask($updateMask);
// Call the API and handle any network failures.
try {
/** @var DataStream $response */
$response = $analyticsAdminServiceClient->updateDataStream($request);
printf('Response data: %s' . PHP_EOL, $response->serializeToJsonString());
} catch (ApiException $ex) {
printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage());
}
}
updateGoogleAdsLink
Updates a GoogleAdsLink on a property
Parameters | |
---|---|
Name | Description |
updateMask |
Google\Protobuf\FieldMask
Required. The list of fields to be updated. Field names must be in snake case (e.g., "field_to_update"). Omitted fields will not be updated. To replace the entire entity, use one path with the string "*" to match all fields. |
optionalArgs |
array
Optional. |
↳ googleAdsLink |
GoogleAdsLink
The GoogleAdsLink to update |
↳ 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\Admin\V1beta\GoogleAdsLink |
use Google\Analytics\Admin\V1beta\Client\AnalyticsAdminServiceClient;
use Google\Analytics\Admin\V1beta\GoogleAdsLink;
use Google\Analytics\Admin\V1beta\UpdateGoogleAdsLinkRequest;
use Google\ApiCore\ApiException;
use Google\Protobuf\FieldMask;
/**
* 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 update_google_ads_link_sample(): void
{
// Create a client.
$analyticsAdminServiceClient = new AnalyticsAdminServiceClient();
// Prepare the request message.
$updateMask = new FieldMask();
$request = (new UpdateGoogleAdsLinkRequest())
->setUpdateMask($updateMask);
// Call the API and handle any network failures.
try {
/** @var GoogleAdsLink $response */
$response = $analyticsAdminServiceClient->updateGoogleAdsLink($request);
printf('Response data: %s' . PHP_EOL, $response->serializeToJsonString());
} catch (ApiException $ex) {
printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage());
}
}
updateMeasurementProtocolSecret
Updates a measurement protocol secret.
Parameters | |
---|---|
Name | Description |
measurementProtocolSecret |
Google\Analytics\Admin\V1beta\MeasurementProtocolSecret
Required. The measurement protocol secret to update. |
updateMask |
Google\Protobuf\FieldMask
Required. The list of fields to be updated. Omitted fields will not be updated. |
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 | |
---|---|
Type | Description |
Google\Analytics\Admin\V1beta\MeasurementProtocolSecret |
use Google\Analytics\Admin\V1beta\Client\AnalyticsAdminServiceClient;
use Google\Analytics\Admin\V1beta\MeasurementProtocolSecret;
use Google\Analytics\Admin\V1beta\UpdateMeasurementProtocolSecretRequest;
use Google\ApiCore\ApiException;
use Google\Protobuf\FieldMask;
/**
* @param string $measurementProtocolSecretDisplayName Human-readable display name for this secret.
*/
function update_measurement_protocol_secret_sample(
string $measurementProtocolSecretDisplayName
): void {
// Create a client.
$analyticsAdminServiceClient = new AnalyticsAdminServiceClient();
// Prepare the request message.
$measurementProtocolSecret = (new MeasurementProtocolSecret())
->setDisplayName($measurementProtocolSecretDisplayName);
$updateMask = new FieldMask();
$request = (new UpdateMeasurementProtocolSecretRequest())
->setMeasurementProtocolSecret($measurementProtocolSecret)
->setUpdateMask($updateMask);
// Call the API and handle any network failures.
try {
/** @var MeasurementProtocolSecret $response */
$response = $analyticsAdminServiceClient->updateMeasurementProtocolSecret($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
{
$measurementProtocolSecretDisplayName = '[DISPLAY_NAME]';
update_measurement_protocol_secret_sample($measurementProtocolSecretDisplayName);
}
updateProperty
Updates a property.
Parameters | |
---|---|
Name | Description |
property |
Google\Analytics\Admin\V1beta\Property
Required. The property to update.
The property's |
updateMask |
Google\Protobuf\FieldMask
Required. The list of fields to be updated. Field names must be in snake case (e.g., "field_to_update"). Omitted fields will not be updated. To replace the entire entity, use one path with the string "*" to match all fields. |
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 | |
---|---|
Type | Description |
Google\Analytics\Admin\V1beta\Property |
use Google\Analytics\Admin\V1beta\Client\AnalyticsAdminServiceClient;
use Google\Analytics\Admin\V1beta\Property;
use Google\Analytics\Admin\V1beta\UpdatePropertyRequest;
use Google\ApiCore\ApiException;
use Google\Protobuf\FieldMask;
/**
* @param string $propertyDisplayName Human-readable display name for this property.
*
* The max allowed display name length is 100 UTF-16 code units.
* @param string $propertyTimeZone Reporting Time Zone, used as the day boundary for reports,
* regardless of where the data originates. If the time zone honors DST,
* Analytics will automatically adjust for the changes.
*
* NOTE: Changing the time zone only affects data going forward, and is not
* applied retroactively.
*
* Format: https://www.iana.org/time-zones
* Example: "America/Los_Angeles"
*/
function update_property_sample(string $propertyDisplayName, string $propertyTimeZone): void
{
// Create a client.
$analyticsAdminServiceClient = new AnalyticsAdminServiceClient();
// Prepare the request message.
$property = (new Property())
->setDisplayName($propertyDisplayName)
->setTimeZone($propertyTimeZone);
$updateMask = new FieldMask();
$request = (new UpdatePropertyRequest())
->setProperty($property)
->setUpdateMask($updateMask);
// Call the API and handle any network failures.
try {
/** @var Property $response */
$response = $analyticsAdminServiceClient->updateProperty($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
{
$propertyDisplayName = '[DISPLAY_NAME]';
$propertyTimeZone = '[TIME_ZONE]';
update_property_sample($propertyDisplayName, $propertyTimeZone);
}
static::accountName
Formats a string containing the fully-qualified path to represent a account resource.
Parameter | |
---|---|
Name | Description |
account |
string
|
Returns | |
---|---|
Type | Description |
string | The formatted account resource. |
static::conversionEventName
Formats a string containing the fully-qualified path to represent a conversion_event resource.
Parameters | |
---|---|
Name | Description |
property |
string
|
conversionEvent |
string
|
Returns | |
---|---|
Type | Description |
string | The formatted conversion_event resource. |
static::customDimensionName
Formats a string containing the fully-qualified path to represent a custom_dimension resource.
Parameters | |
---|---|
Name | Description |
property |
string
|
customDimension |
string
|
Returns | |
---|---|
Type | Description |
string | The formatted custom_dimension resource. |
static::customMetricName
Formats a string containing the fully-qualified path to represent a custom_metric resource.
Parameters | |
---|---|
Name | Description |
property |
string
|
customMetric |
string
|
Returns | |
---|---|
Type | Description |
string | The formatted custom_metric resource. |
static::dataRetentionSettingsName
Formats a string containing the fully-qualified path to represent a data_retention_settings resource.
Parameter | |
---|---|
Name | Description |
property |
string
|
Returns | |
---|---|
Type | Description |
string | The formatted data_retention_settings resource. |
static::dataSharingSettingsName
Formats a string containing the fully-qualified path to represent a data_sharing_settings resource.
Parameter | |
---|---|
Name | Description |
account |
string
|
Returns | |
---|---|
Type | Description |
string | The formatted data_sharing_settings resource. |
static::dataStreamName
Formats a string containing the fully-qualified path to represent a data_stream resource.
Parameters | |
---|---|
Name | Description |
property |
string
|
dataStream |
string
|
Returns | |
---|---|
Type | Description |
string | The formatted data_stream resource. |
static::firebaseLinkName
Formats a string containing the fully-qualified path to represent a firebase_link resource.
Parameters | |
---|---|
Name | Description |
property |
string
|
firebaseLink |
string
|
Returns | |
---|---|
Type | Description |
string | The formatted firebase_link resource. |
static::googleAdsLinkName
Formats a string containing the fully-qualified path to represent a google_ads_link resource.
Parameters | |
---|---|
Name | Description |
property |
string
|
googleAdsLink |
string
|
Returns | |
---|---|
Type | Description |
string | The formatted google_ads_link resource. |
static::measurementProtocolSecretName
Formats a string containing the fully-qualified path to represent a measurement_protocol_secret resource.
Parameters | |
---|---|
Name | Description |
property |
string
|
dataStream |
string
|
measurementProtocolSecret |
string
|
Returns | |
---|---|
Type | Description |
string | The formatted measurement_protocol_secret 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::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
- account: accounts/{account}
- conversionEvent: properties/{property}/conversionEvents/{conversion_event}
- customDimension: properties/{property}/customDimensions/{custom_dimension}
- customMetric: properties/{property}/customMetrics/{custom_metric}
- dataRetentionSettings: properties/{property}/dataRetentionSettings
- dataSharingSettings: accounts/{account}/dataSharingSettings
- dataStream: properties/{property}/dataStreams/{data_stream}
- firebaseLink: properties/{property}/firebaseLinks/{firebase_link}
- googleAdsLink: properties/{property}/googleAdsLinks/{google_ads_link}
- measurementProtocolSecret: properties/{property}/dataStreams/{data_stream}/measurementProtocolSecrets/{measurement_protocol_secret}
- property: properties/{property}
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. |
Constants
SERVICE_NAME
Value: 'google.analytics.admin.v1beta.AnalyticsAdminService'
The name of the service.
SERVICE_ADDRESS
Value: 'analyticsadmin.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.