@@ -87,7 +87,7 @@ def main(
8787 client , customer_id , business_location_id , business_name
8888 )
8989 campaign_criterion_operations = _create_campaign_criterion_operations (
90- client , customer_id , keyword_theme_infos
90+ client , customer_id , keyword_theme_infos , suggestion_info
9191 )
9292 ad_group_operation = _create_ad_group_operation (client , customer_id )
9393 ad_group_ad_operation = _create_ad_group_ad_operation (
@@ -516,28 +516,26 @@ def _create_campaign_criterion_operations(
516516 campaign_criterion .campaign = campaign_service .campaign_path (
517517 customer_id , _SMART_CAMPAIGN_TEMPORARY_ID
518518 )
519- # Set the criterion type to KEYWORD_THEME.
520- campaign_criterion .type_ = client .enums .CriterionTypeEnum .KEYWORD_THEME
521519 # Set the keyword theme to the given KeywordThemeInfo.
522520 campaign_criterion .keyword_theme = info
523521 # Add the mutate operation to the list of other operations.
524522 operations .append (mutate_operation )
525523
526- # Create location criterion to add location to target with the campaign
527- mutate_operation = client . get_type ( "MutateOperation" )
528- campaign_criterion = (
529- mutate_operation . campaign_criterion_operation . create
530- )
531- # Set the campaign ID to a temporary ID.
532- campaign_criterion . campaign = campaign_service . campaign_path (
533- customer_id , _SMART_CAMPAIGN_TEMPORARY_ID
534- )
535- # Set the criterion type to LOCATION.
536- campaign_criterion . type_ = client . enums . CriterionTypeEnum . LOCATION
537- # Set the location to the given location.
538- campaign_criterion .location = suggestion_info . location_list . locations
539- # Add the mutate operation to the list of other operations.
540- operations .append (mutate_operation )
524+ # Create a location criterion for each location in the suggestion info
525+ # object to add corresponding location targeting to the Smart campaign
526+ for location_info in suggestion_info . location_list . locations :
527+ mutate_operation = client . get_type ( "MutateOperation" )
528+ campaign_criterion = (
529+ mutate_operation . campaign_criterion_operation . create
530+ )
531+ # Set the campaign ID to a temporary ID.
532+ campaign_criterion . campaign = campaign_service . campaign_path (
533+ customer_id , _SMART_CAMPAIGN_TEMPORARY_ID
534+ )
535+ # Set the location to the given location.
536+ campaign_criterion .location = location_info
537+ # Add the mutate operation to the list of other operations.
538+ operations .append (mutate_operation )
541539
542540 return operations
543541 # [END add_smart_campaign_8]
0 commit comments