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 the type field. The code example also sets a Percent CPC bid since the campaign's bidding strategy is PercentCpc.


private static function addHotelAdGroup(
    GoogleAdsClient $googleAdsClient,
    int $customerId,
    string $campaignResourceName
) {
    // Creates an ad group.
    $adGroup = new AdGroup([
        'name' => 'Earth to Mars Cruise #' . uniqid(),
        // Sets the campaign.
        'campaign' => $campaignResourceName,
        // Sets the ad group type to HOTEL_ADS.
        // This cannot be set to other types.
        'type' => AdGroupType::HOTEL_ADS,
        'cpc_bid_micros' => 10000000,
        'status' => AdGroupStatus::ENABLED,

    // 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();