Learn more about migrating to the Google Ads API by watching our latest webinar

Get keyword theme and budget recommendations

The Google Ads API exposes two services that recommend configuration details when creating Smart campaigns. The KeywordThemeConstantService generates a set of keyword themes using a word or phrase, region code, and language code. The SmartCampaignSuggestService uses those keyword themes along with information about the business being advertised to suggest daily budget amounts.

Get keyword theme constants

A keyword theme is a single word or phrase that represents a group of related search terms. For example "bakery" is related to "bakery near me" and "local bakery." They are represented in the Google Ads API by the KeywordThemeConstant resource.

Given a word or phrase, the KeywordThemeConstantService can provide multiple KeywordThemeConstants, which can then be used to get daily budget suggestions, as well as to create Smart campaigns.

Java

private List<KeywordThemeConstant> getKeywordThemeConstants(
    GoogleAdsClient googleAdsClient, String keyword) {
  try (KeywordThemeConstantServiceClient client =
      googleAdsClient.getLatestVersion().createKeywordThemeConstantServiceClient()) {
    SuggestKeywordThemeConstantsRequest request =
        SuggestKeywordThemeConstantsRequest.newBuilder()
            .setQueryText(keyword)
            .setCountryCode(COUNTRY_CODE)
            .setLanguageCode(LANGUAGE_CODE)
            .build();
    SuggestKeywordThemeConstantsResponse response = client.suggestKeywordThemeConstants(request);
    return response.getKeywordThemeConstantsList();
  }
}
      

C#

/// <summary>
/// Retrieves keyword theme constants for the given criteria.
/// </summary>
/// <param name="client">The Google Ads client.</param>
/// <param name="keywordText">A keyword used for generating keyword themes.</param>
/// <returns>A list of KeywordThemeConstants.</returns>
private IEnumerable<KeywordThemeConstant> GetKeywordThemeConstants(GoogleAdsClient client,
    string keywordText)
{
    KeywordThemeConstantServiceClient keywordThemeConstantServiceClient =
        client.GetService(Services.V8.KeywordThemeConstantService);

    SuggestKeywordThemeConstantsRequest request = new SuggestKeywordThemeConstantsRequest
    {
        QueryText = keywordText,
        CountryCode = COUNTRY_CODE,
        LanguageCode = LANGUAGE_CODE
    };

    SuggestKeywordThemeConstantsResponse response =
        keywordThemeConstantServiceClient.SuggestKeywordThemeConstants(request);

    Console.WriteLine($"Retrieved {response.KeywordThemeConstants.Count} keyword theme " +
        $"constants using the keyword '{keywordText}'.");
    return response.KeywordThemeConstants.ToList();
}
      

PHP

private static function getKeywordThemeConstants(
    GoogleAdsClient $googleAdsClient,
    string $keywordText
): array {
    $keywordThemeConstantService = $googleAdsClient->getKeywordThemeConstantServiceClient();

    // Issues a request to retrieve the keyword theme constants.
    $response = $keywordThemeConstantService->suggestKeywordThemeConstants([
        'queryText' => $keywordText,
        'countryCode' => self::COUNTRY_CODE,
        'languageCode' => self::LANGUAGE_CODE
    ]);

    printf(
        "Retrieved %d keyword theme constants using the keyword: '%s'.%s",
        $response->getKeywordThemeConstants()->count(),
        $keywordText,
        PHP_EOL
    );
    return iterator_to_array($response->getKeywordThemeConstants()->getIterator());
}
      

Python

def _get_keyword_theme_constants(client, keyword_text):
    """Retrieves KeywordThemeConstants for the given criteria.

    Args:
        client: an initialized GoogleAdsClient instance.
        keyword_text: a keyword used for generating keyword themes.

    Returns:
        a list of KeywordThemeConstants.
    """
    keyword_theme_constant_service = client.get_service(
        "KeywordThemeConstantService"
    )
    request = client.get_type("SuggestKeywordThemeConstantsRequest")
    request.query_text = keyword_text
    request.country_code = _COUNTRY_CODE
    request.language_code = _LANGUAGE_CODE

    response = keyword_theme_constant_service.suggest_keyword_theme_constants(
        request=request
    )

    print(
        f"Retrieved {len(response.keyword_theme_constants)} keyword theme "
        f"constants using the keyword: '{keyword_text}'"
    )
    return response.keyword_theme_constants
      

Ruby

# Retrieves keyword_theme_constants for the given criteria.
def get_keyword_theme_constants(client, keyword_text)
  response = client.service.keyword_theme_constant.suggest_keyword_theme_constants(
    query_text: keyword_text,
    country_code: COUNTRY_CODE,
    language_code: LANGUAGE_CODE,
  )

  puts "Retrieved #{response.keyword_theme_constants.size} keyword theme" \
    "constants using the keyword: '#{keyword_text}'"

  response.keyword_theme_constants
end
      

Perl

# Retrieves keyword theme constants for the given criteria.
sub _get_keyword_theme_constants {
  my ($api_client, $keyword_text) = @_;

  my $response = $api_client->KeywordThemeConstantService()->suggest(
    Google::Ads::GoogleAds::V8::Services::KeywordThemeConstantService::SuggestKeywordThemeConstantsRequest
      ->new({
        queryText    => $keyword_text,
        countryCode  => COUNTRY_CODE,
        languageCode => LANGUAGE_CODE
      }));

  printf "Retrieved %d keyword theme constants using the keyword '%s'.\n",
    scalar(@{$response->{keywordThemeConstants}}), $keyword_text;

  return $response->{keywordThemeConstants};
}
      

Get suggested budget amount

The SmartCampaignSuggestService has a SuggestSmartCampaignBudgetOptions method that will suggest three tiers of daily budget options when given a set of keyword themes and business details. The tiers are low, high, and recommended, and each option also includes an estimated minimum and maximum number of daily clicks.

Java

private long getBudgetSuggestions(
    GoogleAdsClient googleAdsClient,
    long customerId,
    Long locationId,
    List<KeywordThemeInfo> keywordThemeInfos) {
  SuggestSmartCampaignBudgetOptionsRequest.Builder request =
      SuggestSmartCampaignBudgetOptionsRequest.newBuilder()
          .setCustomerId(String.valueOf(customerId));

  // You can retrieve suggestions for an existing campaign by setting the
  // "campaign" field of the request equal to the resource name of a campaign
  // and leaving the rest of the request fields below unset:
  // request.setCampaign("INSERT_CAMPAIGN_RESOURCE_NAME_HERE");

  // Uses the suggestion_info field instead, since these suggestions are for a new campaign.
  request
      .getSuggestionInfoBuilder()
      // Adds the URL of the campaign's landing page.
      .setFinalUrl(LANDING_PAGE_URL)
      // Appends keyword theme constants by mapping them to KeywordThemeInfos.
      .addAllKeywordThemes(keywordThemeInfos);

  // Constructs location information using the given geo target constant. It's
  // also possible to provide a geographic proximity using the "proximity"
  // field on suggestion_info, for example:
  // request
  //     .getSuggestionInfoBuilder()
  //     .getProximityBuilder()
  //     .getAddressBuilder()
  //     .setPostalCode("INSERT_POSTAL_CODE")
  //     .setProvinceCode("INSERT_PROVINCE_CODE")
  //     .setCountryCode("INSERT_COUNTRY_CODE")
  //     .setProvinceName("INSERT_PROVINCE_NAME")
  //     .setStreetAddress("INSERT_STREET_ADDRESS")
  //     .setStreetAddress2("INSERT_STREET_ADDRESS_2")
  //     .setCityName("INSERT_CITY_NAME");
  // request
  //     .getSuggestionInfoBuilder()
  //     .getProximityBuilder()
  //     .setRadius(INSERT_RADIUS)
  //     .setradiusunits(RADIUS_UNITS);
  //
  // For more information on proximities see:
  // https://developers.google.com/google-ads/api/reference/rpc/latest/ProximityInfo
  request
      .getSuggestionInfoBuilder()
      .getLocationListBuilder()
      .addLocations(
          LocationInfo.newBuilder()
              // Sets the location to the resource name of the given geo target constant.
              .setGeoTargetConstant(ResourceNames.geoTargetConstant(GEO_TARGET_CONSTANT))
              .build());

  // Adds a schedule detailing which days of the week the business is open.
  // The schedule below is for a business that is open on Mondays from 9am to 5pm.
  request
      .getSuggestionInfoBuilder()
      .addAdSchedulesBuilder()
      .setDayOfWeek(DayOfWeek.MONDAY)
      .setStartHour(9)
      .setEndHour(17)
      .setStartMinute(MinuteOfHour.ZERO)
      .setEndMinute(MinuteOfHour.ZERO);

  // Adds the GMB location ID, if provided.
  if (locationId != null) {
    request.getSuggestionInfoBuilder().setBusinessLocationId(locationId);
  }

  // Issues a request to retrieve a budget suggestion.
  try (SmartCampaignSuggestServiceClient client =
      googleAdsClient.getLatestVersion().createSmartCampaignSuggestServiceClient()) {
    SuggestSmartCampaignBudgetOptionsResponse response =
        client.suggestSmartCampaignBudgetOptions(request.build());
    BudgetOption recommendation = response.getRecommended();
    System.out.printf(
        "A daily budget amount of %d micros was suggested, garnering an estimated minimum of %d"
            + " clicks and an estimated maximum of %d per day.%n",
        recommendation.getDailyAmountMicros(),
        recommendation.getMetrics().getMinDailyClicks(),
        recommendation.getMetrics().getMaxDailyClicks());
    return recommendation.getDailyAmountMicros();
  }
}
      

C#

/// <summary>
/// Retrieves a suggested budget amount for a new budget.
/// Using the SmartCampaignSuggestService to determine a daily budget for new and existing
/// Smart campaigns is highly recommended because it helps the campaigns achieve optimal
/// performance.
/// </summary>
/// <param name="client">The Google Ads client.</param>
/// <param name="customerId">The Google Ads customer ID.</param>
/// <param name="businessLocationId">The ID of a Google My Business location.</param>
/// <param name="keywordThemeInfos">A list of KeywordThemeInfos.</param>
/// <returns>A daily budget amount in micros.</returns>
private long GetBudgetSuggestion(GoogleAdsClient client, long customerId, long?
    businessLocationId, IEnumerable<KeywordThemeInfo> keywordThemeInfos)
{
    SmartCampaignSuggestServiceClient smartCampaignSuggestServiceClient = client.GetService
        (Services.V8.SmartCampaignSuggestService);

    SuggestSmartCampaignBudgetOptionsRequest request =
        new SuggestSmartCampaignBudgetOptionsRequest
        {
            CustomerId = customerId.ToString(),
            // You can retrieve suggestions for an existing campaign by setting the
            // "Campaign" field of the request to the resource name of a campaign and
            // leaving the rest of the request fields below unset:
            // Campaign = "INSERT_CAMPAIGN_RESOURCE_NAME_HERE",

            // Since these suggestions are for a new campaign, we're going to use the
            // SuggestionInfo field instead.
            SuggestionInfo = new SmartCampaignSuggestionInfo
            {
                // Add the URL of the campaign's landing page.
                FinalUrl = LANDING_PAGE_URL,
                // Construct location information using the given geo target constant. It's
                // also possible to provide a geographic proximity using the "proximity"
                // field on suggestion_info, for example:
                // Proximity = new ProximityInfo
                // {
                //     Address = new AddressInfo
                //     {
                //         PostalCode = "INSERT_POSTAL_CODE",
                //         ProvinceCode = "INSERT_PROVINCE_CODE",
                //         CountryCode = "INSERT_COUNTRY_CODE",
                //         ProvinceName = "INSERT_PROVINCE_NAME",
                //         StreetAddress = "INSERT_STREET_ADDRESS",
                //         StreetAddress2 = "INSERT_STREET_ADDRESS_2",
                //         CityName = "INSERT_CITY_NAME"
                //     },
                //     Radius = Double.Parse("INSERT_RADIUS"),
                //     RadiusUnits = ProximityRadiusUnits.Kilometers
                // }
                // For more information on proximities see:
                // https://developers.google.com/google-ads/api/reference/rpc/latest/ProximityInfo
                LocationList = new SmartCampaignSuggestionInfo.Types.LocationList()
            }
        };

    LocationInfo locationInfo = new LocationInfo
    {
        // Set the location to the resource name of the given geo target constant.
        GeoTargetConstant = ResourceNames.GeoTargetConstant(GEO_TARGET_CONSTANT)
    };

    // Add the LocationInfo object to the list of locations on the SuggestionInfo object.
    // You have the option of providing multiple locations when using location-based
    // suggestions.
    request.SuggestionInfo.LocationList.Locations.Add(locationInfo);

    // Add the KeywordThemeInfo objects to the SuggestionInfo object.
    request.SuggestionInfo.KeywordThemes.Add(keywordThemeInfos);

    // Add the GMB location ID if provided.
    if (businessLocationId.HasValue)
    {
        request.SuggestionInfo.BusinessLocationId = businessLocationId.Value;
    }

    // Add a schedule detailing which days of the week the business is open. This schedule
    // describes a business that is open on Mondays from 9:00 AM to 5:00 PM.
    AdScheduleInfo adScheduleInfo = new AdScheduleInfo
    {
        // Set the day of this schedule as Monday.
        DayOfWeek = DayOfWeekEnum.Types.DayOfWeek.Monday,
        // Set the start hour to 9 AM.
        StartHour = 9,
        // Set the end hour to 5 PM.
        EndHour = 17,
        // Set the start and end minutes to zero.
        StartMinute = MinuteOfHourEnum.Types.MinuteOfHour.Zero,
        EndMinute = MinuteOfHourEnum.Types.MinuteOfHour.Zero
    };

    request.SuggestionInfo.AdSchedules.Add(adScheduleInfo);

    // Issue a request to retrieve a budget suggestion.
    SuggestSmartCampaignBudgetOptionsResponse response =
        smartCampaignSuggestServiceClient.SuggestSmartCampaignBudgetOptions(request);

    // Three tiers of options will be returned: "low", "high", and "recommended".
    // Here we will use the "recommended" option. The amount is specified in micros, where
    // one million is equivalent to one currency unit.
    Console.WriteLine($"A daily budget amount of {response.Recommended.DailyAmountMicros}" +
        $" was suggested, garnering an estimated minimum of " +
        $"{response.Recommended.Metrics.MinDailyClicks} clicks and an estimated maximum " +
        $"of {response.Recommended.Metrics.MaxDailyClicks} clicks per day.");

    return response.Recommended.DailyAmountMicros;
}
      

PHP

private static function getBudgetSuggestion(
    GoogleAdsClient $googleAdsClient,
    int $customerId,
    ?string $businessLocationId,
    array $keywordThemeInfos
): int {
    $suggestionData = [
        // You can retrieve suggestions for an existing campaign by setting the "campaign"
        // field equal to the resource name of a campaign and leaving the rest below unset:
        // 'campaign' => 'INSERT_CAMPAIGN_RESOURCE_NAME_HERE'

        // Since these suggestions are for a new campaign, we're going to use the
        // suggestion_info field instead.
        'suggestion_info' => new SmartCampaignSuggestionInfo([
            // Adds the URL of the campaign's landing page.
            'final_url' => self::LANDING_PAGE_URL,

            // Constructs location information using the given geo target constant. It's also
            // possible to provide a geographic proximity using the "proximity" field,
            // for example:
            //
            // 'proximity' => new ProximityInfo([
            //     'address' => mew AddressInfo([
            //         'post_code' => INSERT_POSTAL_CODE,
            //         'province_code' => INSERT_PROVINCE_CODE,
            //         'country_code' => INSERT_COUNTRY_CODE,
            //         'province_name' => INSERT_PROVINCE_NAME,
            //         'street_address' => INSERT_STREET_ADDRESS,
            //         'street_address2' => INSERT_STREET_ADDRESS_2,
            //         'city_name' => INSERT_CITY_NAME
            //     ]),
            //     'radius' => INSERT_RADIUS,
            //     'radius_units' => INSERT_RADIUS_UNITS
            // ])
            //
            // For more information on proximities see:
            // https://developers.google.com/google-ads/api/reference/rpc/latest/ProximityInfo

            // Adds LocationInfo objects to the list of locations. You have the option of
            // providing multiple locations when using location-based suggestions.
            'location_list' => new LocationList([
                // Sets one location to the resource name of the given geo target constant.
                'locations' => [new LocationInfo([
                    'geo_target_constant' => ResourceNames::forGeoTargetConstant(
                        self::GEO_TARGET_CONSTANT
                    )
                ])]
            ]),

            // Adds the KeywordThemeInfo objects.
            'keyword_themes' => $keywordThemeInfos,

            // Adds a schedule detailing which days of the week the business is open.
            // This schedule describes a schedule in which the business is open on
            // Mondays from 9am to 5pm.
            'ad_schedules' => [new AdScheduleInfo([
                // Sets the day of this schedule as Monday.
                'day_of_week' => DayOfWeek::MONDAY,
                // Sets the start hour to 9am.
                'start_hour' => 9,
                // Sets the end hour to 5pm.
                'end_hour' => 17,
                // Sets the start and end minute of zero, for example: 9:00 and 5:00.
                'start_minute' => MinuteOfHour::ZERO,
                'end_minute' => MinuteOfHour::ZERO
            ])]
        ])
    ];

    // Adds the GMB location ID if it is provided and if the "suggestion_info" field is set.
    if (array_key_exists('suggestion_info', $suggestionData) && $businessLocationId) {
        $suggestionData['suggestion_info']->setBusinessLocationId($businessLocationId);
    }

    // Issues a request to retrieve a budget suggestion.
    $smartCampaignSuggestService = $googleAdsClient->getSmartCampaignSuggestServiceClient();
    $response = $smartCampaignSuggestService->suggestSmartCampaignBudgetOptions(
        $customerId,
        $suggestionData
    );

    // Three tiers of options will be returned, a "low", "high" and "recommended". Here we will
    // use the "recommended" option. The amount is specified in micros, where one million is
    // equivalent to one currency unit.
    $recommendation = $response->getRecommended();
    printf(
        "A daily budget amount of %d micros was suggested, garnering an estimated minimum of "
        . "%d clicks and an estimated maximum of %d per day.%s",
        $recommendation->getDailyAmountMicros(),
        $recommendation->getMetrics()->getMinDailyClicks(),
        $recommendation->getMetrics()->getMaxDailyClicks(),
        PHP_EOL
    );

    return $recommendation->getDailyAmountMicros();
}
      

Python

def _get_budget_suggestion(
    client, customer_id, business_location_id, keyword_theme_infos,
):
    """Retrieves a suggested budget amount for a new budget.

    Using the SmartCampaignSuggestService to determine a daily budget for new
    and existing Smart campaigns is highly recommended because it helps the
    campaigns achieve optimal performance.

    Args:
        client: an initialized GoogleAdsClient instance.
        customer_id: a client customer ID.
        business_location_id: the ID of a Google My Business location.
        keyword_theme_infos: a list of KeywordThemeInfos.

    Returns:
        a daily budget amount in micros.
    """
    sc_suggest_service = client.get_service("SmartCampaignSuggestService")
    request = client.get_type("SuggestSmartCampaignBudgetOptionsRequest")
    request.customer_id = customer_id
    # You can retrieve suggestions for an existing campaign by setting the
    # "campaign" field of the request equal to the resource name of a campaign
    # and leaving the rest of the request fields below unset:
    # request.campaign = INSERT_CAMPAIGN_RESOURCE_NAME_HERE

    # Since these suggestions are for a new campaign, we're going to
    # use the suggestion_info field instead.
    suggestion_info = request.suggestion_info

    # Add the URL of the campaign's landing page.
    suggestion_info.final_url = _LANDING_PAGE_URL

    # Construct location information using the given geo target constant. It's
    # also possible to provide a geographic proximity using the "proximity"
    # field on suggestion_info, for example:
    #
    # suggestion_info.proximity.address.post_code = INSERT_POSTAL_CODE
    # suggestion_info.proximity.address.province_code = INSERT_PROVINCE_CODE
    # suggestion_info.proximity.address.country_code = INSERT_COUNTRY_CODE
    # suggestion_info.proximity.address.province_name = INSERT_PROVINCE_NAME
    # suggestion_info.proximity.address.street_address = INSERT_STREET_ADDRESS
    # suggestion_info.proximity.address.street_address2 = INSERT_STREET_ADDRESS_2
    # suggestion_info.proximity.address.city_name = INSERT_CITY_NAME
    # suggestion_info.proximity.radius = INSERT_RADIUS
    # suggestion_info.proximity.radius_units = RADIUS_UNITS
    #
    # For more information on proximities see:
    # https://developers.google.com/google-ads/api/reference/rpc/latest/ProximityInfo
    location = client.get_type("LocationInfo")
    # Set the location to the resource name of the given geo target constant.
    location.geo_target_constant = client.get_service(
        "GeoTargetConstantService"
    ).geo_target_constant_path(_GEO_TARGET_CONSTANT)
    # Add the LocationInfo object to the list of locations on the
    # suggestion_info object. You have the option of providing multiple
    # locations when using location-based suggestions.
    suggestion_info.location_list.locations.append(location)

    # Add the KeywordThemeInfo objects to the SuggestionInfo object.
    suggestion_info.keyword_themes.extend(keyword_theme_infos)

    # If provided, add the GMB location ID.
    if business_location_id:
        suggestion_info.business_location_id = business_location_id

    # Add a schedule detailing which days of the week the business is open.
    # This schedule describes a schedule in which the business is open on
    # Mondays from 9am to 5pm.
    ad_schedule_info = client.get_type("AdScheduleInfo")
    # Set the day of this schedule as Monday.
    ad_schedule_info.day_of_week = client.get_type(
        "DayOfWeekEnum"
    ).DayOfWeek.MONDAY
    # Set the start hour to 9am.
    ad_schedule_info.start_hour = 9
    # Set the end hour to 5pm.
    ad_schedule_info.end_hour = 17
    # Set the start and end minute of zero, for example: 9:00 and 5:00.
    zero_minute_of_hour = client.get_type("MinuteOfHourEnum").MinuteOfHour.ZERO
    ad_schedule_info.start_minute = zero_minute_of_hour
    ad_schedule_info.end_minute = zero_minute_of_hour
    suggestion_info.ad_schedules.append(ad_schedule_info)

    # Issue a request to retrieve a budget suggestion.
    response = sc_suggest_service.suggest_smart_campaign_budget_options(
        request=request
    )

    # Three tiers of options will be returned, a "low", "high" and
    # "recommended". Here we will use the "recommended" option. The amount is
    # specified in micros, where one million is equivalent to one currency unit.
    recommendation = response.recommended
    print(
        f"A daily budget amount of {recommendation.daily_amount_micros} micros "
        "was suggested, garnering an estimated minimum of "
        f"{recommendation.metrics.min_daily_clicks} clicks and an estimated "
        f"maximum of {recommendation.metrics.max_daily_clicks} per day."
    )

    return recommendation.daily_amount_micros
      

Ruby

# Retrieves a suggested budget amount for a new budget.
# Using the smart_campaign_suggest_service to determine a daily budget for new
# and existing Smart campaigns is highly recommended because it helps the
# campaigns achieve optimal performance.
def get_budget_suggestion(
  client,
  customer_id,
  business_location_id,
  keyword_theme_infos)

  # Since these suggestions are for a new campaign, we're going to
  # use the suggestion_info field instead.
  suggestion_info = client.resource.smart_campaign_suggestion_info do |si|
    # Adds the URL of the campaign's landing page.
    si.final_url = LANDING_PAGE_URL
    # Constructs location information using the given geo target constant. It's
    # also possible to provide a geographic proximity using the "proximity"
    # field on suggestion_info, for example:
    # si.proximity = client.resource.proximity_info do |proximity|
    #   proximity.address = client.resource.address_info do |address|
    #     address.post_code = INSERT_POSTAL_CODE
    #     address.province_code = INSERT_PROVINCE_CODE
    #     address.country_code = INSERT_COUNTRY_CODE
    #     address.province_name = INSERT_PROVINCE_NAME
    #     address.street_address = INSERT_STREET_ADDRESS
    #     address.street_address2 = INSERT_STREET_ADDRESS_2
    #     address.city_name = INSERT_CITY_NAME
    #   end
    #   proximity.radius = INSERT_RADIUS
    #   proximity.radius_units = :INSERT_RADIUS_UNIT_ENUM
    # end
    #
    # For more information on proximities see:
    # https://developers.google.com/google-ads/api/reference/rpc/latest/ProximityInfo
    si.location_list = client.resource.location_list do |loc_list|
      # Adds the location_info object to the list of locations on the
      # suggestion_info object. You have the option of providing multiple
      # locations when using location-based suggestions.
      loc_list.locations << client.resource.location_info do |li|
        li.geo_target_constant = client.path.geo_target_constant(GEO_TARGET_CONSTANT)
      end
    end
    # Adds the keyword_theme_info objects to the suggestion_info object.
    si.keyword_themes += keyword_theme_infos
    # If provided, add the GMB location ID.
    if business_location_id
      si.business_location_id = business_location_id.to_i
    end
    # Adds a schedule detailing which days of the week the business is open.
    # This schedule describes a schedule in which the business is open on
    # Mondays from 9am to 5pm.
    si.ad_schedules += [
      client.resource.ad_schedule_info do |as|
        # Sets the day of this schedule as Monday.
        as.day_of_week = :MONDAY
        # Sets the start hour to 9:00am.
        as.start_hour = 9
        as.start_minute = :ZERO
        # Sets the end hour to 5:00pm.
        as.end_hour = 17
        as.end_minute = :ZERO
      end
    ]
  end

  # Issues a request to retrieve a budget suggestion.
  response = client.service.smart_campaign_suggest.suggest_smart_campaign_budget_options(
    customer_id: customer_id,
    suggestion_info: suggestion_info,
  )

  # Three tiers of options will be returned, a "low", "high" and
  # "recommended". Here we will use the "recommended" option. The amount is
  # specified in micros, where one million is equivalent to one currency unit.
  recommendation = response.recommended
  puts "A daily budget amount of #{recommendation.daily_amount_micros} micros" \
    " was suggested, garnering an estimated minimum of" \
    " #{recommendation.metrics.min_daily_clicks} clicks and an estimated" \
    " maximum of #{recommendation.metrics.max_daily_clicks} per day."

  recommendation.daily_amount_micros
end
      

Perl

sub _get_budget_suggestion {
  my ($api_client, $customer_id, $business_location_id, $keyword_theme_infos) =
    @_;

  my $request =
    Google::Ads::GoogleAds::V8::Services::SmartCampaignSuggestService::SuggestSmartCampaignBudgetOptionsRequest
    ->new({
      customerId => $customer_id,
      # You can retrieve suggestions for an existing campaign by setting the
      # "Campaign" field of the request to the resource name of a campaign and
      # leaving the rest of the request fields below unset:
      # campaign   => "INSERT_CAMPAIGN_RESOURCE_NAME_HERE",
      suggestionInfo =>
        Google::Ads::GoogleAds::V8::Services::SmartCampaignSuggestService::SmartCampaignSuggestionInfo
        ->new({
          # Add the URL of the campaign's landing page.
          finalUrl => LANDING_PAGE_URL,
          # Construct location information using the given geo target constant.
          # It's also possible to provide a geographic proximity using the
          # "proximity" field on suggestion_info, for example:
          # proximity => Google::Ads::GoogleAds::V8::Common::ProximityInfo->new({
          #     address => Google::Ads::GoogleAds::V8::Common::AddressInfo->new({
          #         postalCode     => "INSERT_POSTAL_CODE",
          #         provinceCode   => "INSERT_PROVINCE_CODE",
          #         countryCode    => "INSERT_COUNTRY_CODE",
          #         provinceName   => "INSERT_PROVINCE_NAME",
          #         streetAddress  => "INSERT_STREET_ADDRESS",
          #         streetAddress2 => "INSERT_STREET_ADDRESS_2",
          #         cityName       => "INSERT_CITY_NAME"
          #       }
          #     ),
          #     radius      => "INSERT_RADIUS",
          #     radiusUnits => MILES
          #   }
          # ),
          # For more information on proximities see:
          # https://developers.google.com/google-ads/api/reference/rpc/latest/ProximityInfo
          locationList =>
            Google::Ads::GoogleAds::V8::Services::SmartCampaignSuggestService::LocationList
            ->new(
            ),
          # keywordThemes => Keywordtheme
        })});

  # Add the LocationInfo object to the list of locations on the SuggestionInfo
  # object. You have the option of providing multiple locations when using
  # location-based suggestions.
  push
    @{$request->{suggestionInfo}{locationList}{locations}},
    Google::Ads::GoogleAds::V8::Common::LocationInfo->new({
      # Set the location to the resource name of the given geo target constant.
      geoTargetConstant =>
        Google::Ads::GoogleAds::V8::Utils::ResourceNames::geo_target_constant(
        GEO_TARGET_CONSTANT)});

  # Add the KeywordThemeInfo objects to the SuggestionInfo object.
  push @{$request->{suggestionInfo}{keywordThemes}}, $keyword_theme_infos;

  # Add the GM location ID if provided.
  $request->{suggestionInfo}{businessLocationId} = $business_location_id
    if defined $business_location_id;

  # Add a schedule detailing which days of the week the business is open. This
  # example schedule describes a business that is open on Mondays from 9:00 AM
  # to 5:00 PM.
  push(
    @{$request->{suggestionInfo}{adSchedules}},
    Google::Ads::GoogleAds::V8::Common::AdScheduleInfo->new({
        # Set the day of this schedule as Monday.
        dayOfWeek => MONDAY,
        # Set the start hour to 9 AM.
        startHour => 9,
        # Set the end hour to 5 PM.
        endHour => 17,
        # Set the start and end minutes to zero.
        startMinute => ZERO,
        endMinute   => ZERO
      }));

  # Issue a request to retrieve a budget suggestion.
  my $response = $api_client->SmartCampaignSuggestService()
    ->suggest_smart_campaign_budget_options($request);

  # Three tiers of options will be returned: "low", "high", and "recommended".
  # Here we will use the "recommended" option. The amount is specified in
  # micros, where one million is equivalent to one currency unit.
  printf "A daily budget amount of %d was suggested, garnering an estimated " .
    "minimum of %d clicks and an estimated maximum of %d clicks per day.\n",
    $response->{recommended}{dailyAmountMicros},
    $response->{recommended}{metrics}{minDailyClicks},
    $response->{recommended}{metrics}{maxDailyClicks};

  return $response->{recommended}{dailyAmountMicros};
}