Creating a Hotel Ad Group Ad

Creating a Hotel ad involves two steps:

  1. Creating an Ad and setting its hotel_ad to an instance of HotelAdInfo.

  2. Creating an AdGroupAd and associating the previously created Ad to it.


private static function addHotelAdGroupAd(
    GoogleAdsClient $googleAdsClient,
) {
    // Creates a new hotel ad.
    $ad = new Ad();
    $ad->setHotelAd(new HotelAdInfo());

    // Creates a new ad group ad and sets the hotel ad to it.
    $adGroupAd = new AdGroupAd();

    // Sets the ad group.
    $wrappedAdGroupResourceName = new StringValue();

    // Creates an ad group ad operation.
    $adGroupAdOperation = new AdGroupAdOperation();

    // Issues a mutate request to add an ad group ad.
    $adGroupAdServiceClient = $googleAdsClient->getAdGroupAdServiceClient();
    $response = $adGroupAdServiceClient->mutateAdGroupAds($customerId, [$adGroupAdOperation]);

    /** @var AdGroupAd $addedAdGroupAd */
    $addedAdGroupAd = $response->getResults()[0];
        "Added a hotel ad group ad with resource name '%s'.%s",

Send feedback about...

Google Ads API Beta
Google Ads API Beta
Need help? Visit our support page.