Register for one of our Google Ads API workshops (March 6, 2019 - April 23, 2019).

Creating a Hotel Ad Group

In order to serve ads for your Hotel campaign, you must create an AdGroup with at least one ad in the ad group. As shown later, a Hotel campaign supports only an ad group of the HOTEL_ADS type, which you can set in type. The code example also sets a Percent CPC bid since the campaign's bidding strategy is PercentCpc.


private static function addHotelAdGroup(
    GoogleAdsClient $googleAdsClient,
) {
    // Creates an ad group.
    $adGroup = new AdGroup();

    $wrappedName = new StringValue();
    $wrappedName->setValue('Earth to Mars Cruise #' . uniqid());

    // Sets the campaign.
    $wrappedCampaignResourceName = new StringValue();

    // Sets the ad group type to HOTEL_ADS.
    // This cannot be set to other types.

    $wrappedCpcBidMicros = new Int64Value();


    // Creates an ad group operation.
    $adGroupOperation = new AdGroupOperation();

    // Issues a mutate request to add an ad group.
    $adGroupServiceClient = $googleAdsClient->getAdGroupServiceClient();
    $response = $adGroupServiceClient->mutateAdGroups($customerId, [$adGroupOperation]);

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

    return $addedAdGroup->getResourceName();

Send feedback about...

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