Google Ads Data Manager V1 Client - Class IngestionServiceClient (0.6.0)

Reference documentation and code samples for the Google Ads Data Manager V1 Client class IngestionServiceClient.

Service Description: Service for sending audience data to supported destinations.

This class provides the ability to make remote calls to the backing service through method calls that map to API methods.

Namespace

Google \ Ads \ DataManager \ V1 \ Client

Methods

__construct

Constructor.

Parameters
Name Description
options array|Google\ApiCore\Options\ClientOptions

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 Google\Auth\FetchAuthTokenInterface|Google\ApiCore\CredentialsWrapper

This option should only be used with a pre-constructed Google\Auth\FetchAuthTokenInterface or Google\ApiCore\CredentialsWrapper object. Note that when one of these objects are provided, any settings in $credentialsConfig will be ignored. Important: If you are providing a path to a credentials file, or a decoded credentials file as a PHP array, this usage is now DEPRECATED. Providing an unvalidated credential configuration to Google APIs can compromise the security of your systems and data. It is recommended to create the credentials explicitly use Google\Auth\Credentials\ServiceAccountCredentials; use Google\Ads\DataManager\V1\IngestionServiceClient; $creds = new ServiceAccountCredentials($scopes, $json); $options = new IngestionServiceClient(['credentials' => $creds]); https://cloud.google.com/docs/authentication/external/externally-sourced-credentials

↳ credentialsConfig array

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

↳ disableRetries bool

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

↳ clientConfig string|array

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

↳ transport string|Google\ApiCore\Transport\TransportInterface

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

↳ transportConfig array

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

↳ clientCertSource callable

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

↳ logger false|Psr\Log\LoggerInterface

A PSR-3 compliant logger. If set to false, logging is disabled, ignoring the 'GOOGLE_SDK_PHP_LOGGING' environment flag

↳ universeDomain string

The service domain for the client. Defaults to 'googleapis.com'.

ingestAdEvents

Uploads a list of AdEvent resources to Google Analytics.

This feature is only available to accounts on an allowlist.

The async variant is IngestionServiceClient::ingestAdEventsAsync() .

Parameters
Name Description
request Google\Ads\DataManager\V1\IngestAdEventsRequest

A request to house fields associated with the call.

callOptions array

Optional.

↳ retrySettings Google\ApiCore\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\Ads\DataManager\V1\IngestAdEventsResponse
Example
use Google\Ads\DataManager\V1\AdEvent;
use Google\Ads\DataManager\V1\AdEvent\EventType;
use Google\Ads\DataManager\V1\Client\IngestionServiceClient;
use Google\Ads\DataManager\V1\IngestAdEventsRequest;
use Google\Ads\DataManager\V1\IngestAdEventsResponse;
use Google\Ads\DataManager\V1\ViewType;
use Google\Ads\DataManager\V1\ViewabilityInfo;
use Google\ApiCore\ApiException;
use Google\Protobuf\Timestamp;

/**
 * @param string $adEventsAdvertiserId            The ID of the advertiser for the ad event.
 *
 *                                                This must match the ID sent in the linking flow.
 * @param int    $adEventsEventType               The type of the event.
 * @param string $adEventsCampaignId              The ID of the associated campaign.
 * @param string $adEventsCampaignName            The name of the associated campaign.
 * @param string $adEventsRegionCode              The ISO 3166-2 country plus subdivision.
 * @param string $adEventsSource                  The platform source of the ad, akin to the Google Analytics
 *                                                source.
 * @param string $adEventsMedium                  The medium of the ad, akin to the Google Analytics medium.
 * @param int    $adEventsViewabilityInfoViewType The type of the event.
 */
function ingest_ad_events_sample(
    string $adEventsAdvertiserId,
    int $adEventsEventType,
    string $adEventsCampaignId,
    string $adEventsCampaignName,
    string $adEventsRegionCode,
    string $adEventsSource,
    string $adEventsMedium,
    int $adEventsViewabilityInfoViewType
): void {
    // Create a client.
    $ingestionServiceClient = new IngestionServiceClient();

    // Prepare the request message.
    $adEventsTimestamp = new Timestamp();
    $adEventsViewabilityInfo = (new ViewabilityInfo())
        ->setViewType($adEventsViewabilityInfoViewType);
    $adEvent = (new AdEvent())
        ->setAdvertiserId($adEventsAdvertiserId)
        ->setEventType($adEventsEventType)
        ->setTimestamp($adEventsTimestamp)
        ->setCampaignId($adEventsCampaignId)
        ->setCampaignName($adEventsCampaignName)
        ->setRegionCode($adEventsRegionCode)
        ->setSource($adEventsSource)
        ->setMedium($adEventsMedium)
        ->setViewabilityInfo($adEventsViewabilityInfo);
    $adEvents = [$adEvent,];
    $request = (new IngestAdEventsRequest())
        ->setAdEvents($adEvents);

    // Call the API and handle any network failures.
    try {
        /** @var IngestAdEventsResponse $response */
        $response = $ingestionServiceClient->ingestAdEvents($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
{
    $adEventsAdvertiserId = '[ADVERTISER_ID]';
    $adEventsEventType = EventType::EVENT_TYPE_UNSPECIFIED;
    $adEventsCampaignId = '[CAMPAIGN_ID]';
    $adEventsCampaignName = '[CAMPAIGN_NAME]';
    $adEventsRegionCode = '[REGION_CODE]';
    $adEventsSource = '[SOURCE]';
    $adEventsMedium = '[MEDIUM]';
    $adEventsViewabilityInfoViewType = ViewType::VIEW_TYPE_UNSPECIFIED;

    ingest_ad_events_sample(
        $adEventsAdvertiserId,
        $adEventsEventType,
        $adEventsCampaignId,
        $adEventsCampaignName,
        $adEventsRegionCode,
        $adEventsSource,
        $adEventsMedium,
        $adEventsViewabilityInfoViewType
    );
}

ingestAudienceMembers

Uploads a list of AudienceMember resources to the provided Destination.

The async variant is IngestionServiceClient::ingestAudienceMembersAsync() .

Parameters
Name Description
request Google\Ads\DataManager\V1\IngestAudienceMembersRequest

A request to house fields associated with the call.

callOptions array

Optional.

↳ retrySettings Google\ApiCore\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\Ads\DataManager\V1\IngestAudienceMembersResponse
Example
use Google\Ads\DataManager\V1\AudienceMember;
use Google\Ads\DataManager\V1\Client\IngestionServiceClient;
use Google\Ads\DataManager\V1\Destination;
use Google\Ads\DataManager\V1\IngestAudienceMembersRequest;
use Google\Ads\DataManager\V1\IngestAudienceMembersResponse;
use Google\Ads\DataManager\V1\ProductAccount;
use Google\Ads\DataManager\V1\ProductAccount\AccountType;
use Google\ApiCore\ApiException;

/**
 * @param string $destinationsOperatingAccountAccountId   The ID of the account. For example, your Google Ads account ID.
 * @param int    $destinationsOperatingAccountAccountType The type of the account. For example, `GOOGLE_ADS`.
 *                                                        Either `account_type` or the deprecated `product` is required.
 *                                                        If both are set, the values must match.
 * @param string $destinationsProductDestinationId        The object within the product account to ingest into. For
 *                                                        example, a Google Ads audience ID, a Display & Video 360 audience ID or a
 *                                                        Google Ads conversion action ID.
 */
function ingest_audience_members_sample(
    string $destinationsOperatingAccountAccountId,
    int $destinationsOperatingAccountAccountType,
    string $destinationsProductDestinationId
): void {
    // Create a client.
    $ingestionServiceClient = new IngestionServiceClient();

    // Prepare the request message.
    $destinationsOperatingAccount = (new ProductAccount())
        ->setAccountId($destinationsOperatingAccountAccountId)
        ->setAccountType($destinationsOperatingAccountAccountType);
    $destination = (new Destination())
        ->setOperatingAccount($destinationsOperatingAccount)
        ->setProductDestinationId($destinationsProductDestinationId);
    $destinations = [$destination,];
    $audienceMembers = [new AudienceMember()];
    $request = (new IngestAudienceMembersRequest())
        ->setDestinations($destinations)
        ->setAudienceMembers($audienceMembers);

    // Call the API and handle any network failures.
    try {
        /** @var IngestAudienceMembersResponse $response */
        $response = $ingestionServiceClient->ingestAudienceMembers($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
{
    $destinationsOperatingAccountAccountId = '[ACCOUNT_ID]';
    $destinationsOperatingAccountAccountType = AccountType::ACCOUNT_TYPE_UNSPECIFIED;
    $destinationsProductDestinationId = '[PRODUCT_DESTINATION_ID]';

    ingest_audience_members_sample(
        $destinationsOperatingAccountAccountId,
        $destinationsOperatingAccountAccountType,
        $destinationsProductDestinationId
    );
}

ingestEvents

Uploads a list of Event resources from the provided Destination.

The async variant is IngestionServiceClient::ingestEventsAsync() .

Parameters
Name Description
request Google\Ads\DataManager\V1\IngestEventsRequest

A request to house fields associated with the call.

callOptions array

Optional.

↳ retrySettings Google\ApiCore\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\Ads\DataManager\V1\IngestEventsResponse
Example
use Google\Ads\DataManager\V1\Client\IngestionServiceClient;
use Google\Ads\DataManager\V1\Destination;
use Google\Ads\DataManager\V1\Event;
use Google\Ads\DataManager\V1\IngestEventsRequest;
use Google\Ads\DataManager\V1\IngestEventsResponse;
use Google\Ads\DataManager\V1\ProductAccount;
use Google\Ads\DataManager\V1\ProductAccount\AccountType;
use Google\ApiCore\ApiException;
use Google\Protobuf\Timestamp;

/**
 * @param string $destinationsOperatingAccountAccountId   The ID of the account. For example, your Google Ads account ID.
 * @param int    $destinationsOperatingAccountAccountType The type of the account. For example, `GOOGLE_ADS`.
 *                                                        Either `account_type` or the deprecated `product` is required.
 *                                                        If both are set, the values must match.
 * @param string $destinationsProductDestinationId        The object within the product account to ingest into. For
 *                                                        example, a Google Ads audience ID, a Display & Video 360 audience ID or a
 *                                                        Google Ads conversion action ID.
 */
function ingest_events_sample(
    string $destinationsOperatingAccountAccountId,
    int $destinationsOperatingAccountAccountType,
    string $destinationsProductDestinationId
): void {
    // Create a client.
    $ingestionServiceClient = new IngestionServiceClient();

    // Prepare the request message.
    $destinationsOperatingAccount = (new ProductAccount())
        ->setAccountId($destinationsOperatingAccountAccountId)
        ->setAccountType($destinationsOperatingAccountAccountType);
    $destination = (new Destination())
        ->setOperatingAccount($destinationsOperatingAccount)
        ->setProductDestinationId($destinationsProductDestinationId);
    $destinations = [$destination,];
    $eventsEventTimestamp = new Timestamp();
    $event = (new Event())
        ->setEventTimestamp($eventsEventTimestamp);
    $events = [$event,];
    $request = (new IngestEventsRequest())
        ->setDestinations($destinations)
        ->setEvents($events);

    // Call the API and handle any network failures.
    try {
        /** @var IngestEventsResponse $response */
        $response = $ingestionServiceClient->ingestEvents($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
{
    $destinationsOperatingAccountAccountId = '[ACCOUNT_ID]';
    $destinationsOperatingAccountAccountType = AccountType::ACCOUNT_TYPE_UNSPECIFIED;
    $destinationsProductDestinationId = '[PRODUCT_DESTINATION_ID]';

    ingest_events_sample(
        $destinationsOperatingAccountAccountId,
        $destinationsOperatingAccountAccountType,
        $destinationsProductDestinationId
    );
}

removeAudienceMembers

Removes a list of AudienceMember resources from the provided Destination.

The async variant is IngestionServiceClient::removeAudienceMembersAsync() .

Parameters
Name Description
request Google\Ads\DataManager\V1\RemoveAudienceMembersRequest

A request to house fields associated with the call.

callOptions array

Optional.

↳ retrySettings Google\ApiCore\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\Ads\DataManager\V1\RemoveAudienceMembersResponse
Example
use Google\Ads\DataManager\V1\AudienceMember;
use Google\Ads\DataManager\V1\Client\IngestionServiceClient;
use Google\Ads\DataManager\V1\Destination;
use Google\Ads\DataManager\V1\ProductAccount;
use Google\Ads\DataManager\V1\ProductAccount\AccountType;
use Google\Ads\DataManager\V1\RemoveAudienceMembersRequest;
use Google\Ads\DataManager\V1\RemoveAudienceMembersResponse;
use Google\ApiCore\ApiException;

/**
 * @param string $destinationsOperatingAccountAccountId   The ID of the account. For example, your Google Ads account ID.
 * @param int    $destinationsOperatingAccountAccountType The type of the account. For example, `GOOGLE_ADS`.
 *                                                        Either `account_type` or the deprecated `product` is required.
 *                                                        If both are set, the values must match.
 * @param string $destinationsProductDestinationId        The object within the product account to ingest into. For
 *                                                        example, a Google Ads audience ID, a Display & Video 360 audience ID or a
 *                                                        Google Ads conversion action ID.
 */
function remove_audience_members_sample(
    string $destinationsOperatingAccountAccountId,
    int $destinationsOperatingAccountAccountType,
    string $destinationsProductDestinationId
): void {
    // Create a client.
    $ingestionServiceClient = new IngestionServiceClient();

    // Prepare the request message.
    $destinationsOperatingAccount = (new ProductAccount())
        ->setAccountId($destinationsOperatingAccountAccountId)
        ->setAccountType($destinationsOperatingAccountAccountType);
    $destination = (new Destination())
        ->setOperatingAccount($destinationsOperatingAccount)
        ->setProductDestinationId($destinationsProductDestinationId);
    $destinations = [$destination,];
    $audienceMembers = [new AudienceMember()];
    $request = (new RemoveAudienceMembersRequest())
        ->setDestinations($destinations)
        ->setAudienceMembers($audienceMembers);

    // Call the API and handle any network failures.
    try {
        /** @var RemoveAudienceMembersResponse $response */
        $response = $ingestionServiceClient->removeAudienceMembers($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
{
    $destinationsOperatingAccountAccountId = '[ACCOUNT_ID]';
    $destinationsOperatingAccountAccountType = AccountType::ACCOUNT_TYPE_UNSPECIFIED;
    $destinationsProductDestinationId = '[PRODUCT_DESTINATION_ID]';

    remove_audience_members_sample(
        $destinationsOperatingAccountAccountId,
        $destinationsOperatingAccountAccountType,
        $destinationsProductDestinationId
    );
}

retrieveRequestStatus

Gets the status of a request given request id.

The async variant is IngestionServiceClient::retrieveRequestStatusAsync() .

Parameters
Name Description
request Google\Ads\DataManager\V1\RetrieveRequestStatusRequest

A request to house fields associated with the call.

callOptions array

Optional.

↳ retrySettings Google\ApiCore\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\Ads\DataManager\V1\RetrieveRequestStatusResponse
Example
use Google\Ads\DataManager\V1\Client\IngestionServiceClient;
use Google\Ads\DataManager\V1\RetrieveRequestStatusRequest;
use Google\Ads\DataManager\V1\RetrieveRequestStatusResponse;
use Google\ApiCore\ApiException;

/**
 * @param string $requestId Required. The request ID of the Data Manager API request.
 */
function retrieve_request_status_sample(string $requestId): void
{
    // Create a client.
    $ingestionServiceClient = new IngestionServiceClient();

    // Prepare the request message.
    $request = (new RetrieveRequestStatusRequest())
        ->setRequestId($requestId);

    // Call the API and handle any network failures.
    try {
        /** @var RetrieveRequestStatusResponse $response */
        $response = $ingestionServiceClient->retrieveRequestStatus($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
{
    $requestId = '[REQUEST_ID]';

    retrieve_request_status_sample($requestId);
}

ingestAdEventsAsync

Parameters
Name Description
request Google\Ads\DataManager\V1\IngestAdEventsRequest
optionalArgs array
Returns
Type Description
GuzzleHttp\Promise\PromiseInterface<Google\Ads\DataManager\V1\IngestAdEventsResponse>

ingestAudienceMembersAsync

Parameters
Name Description
request Google\Ads\DataManager\V1\IngestAudienceMembersRequest
optionalArgs array
Returns
Type Description
GuzzleHttp\Promise\PromiseInterface<Google\Ads\DataManager\V1\IngestAudienceMembersResponse>

ingestEventsAsync

Parameters
Name Description
request Google\Ads\DataManager\V1\IngestEventsRequest
optionalArgs array
Returns
Type Description
GuzzleHttp\Promise\PromiseInterface<Google\Ads\DataManager\V1\IngestEventsResponse>

removeAudienceMembersAsync

Parameters
Name Description
request Google\Ads\DataManager\V1\RemoveAudienceMembersRequest
optionalArgs array
Returns
Type Description
GuzzleHttp\Promise\PromiseInterface<Google\Ads\DataManager\V1\RemoveAudienceMembersResponse>

retrieveRequestStatusAsync

Parameters
Name Description
request Google\Ads\DataManager\V1\RetrieveRequestStatusRequest
optionalArgs array
Returns
Type Description
GuzzleHttp\Promise\PromiseInterface<Google\Ads\DataManager\V1\RetrieveRequestStatusResponse>