@@ -120,6 +120,9 @@ def main(client, customer_id, audience_id):
120120 headline_asset_resource_names ,
121121 description_asset_resource_names ,
122122 )
123+ asset_group_signal_operations = create_asset_group_signal_operations (
124+ client , customer_id , audience_id
125+ )
123126
124127 mutate_operations = [
125128 # It's important to create these entities in this order because
@@ -130,16 +133,9 @@ def main(client, customer_id, audience_id):
130133 # other mutate operations
131134 * campaign_criterion_operations ,
132135 * asset_group_operations ,
136+ * asset_group_signal_operations ,
133137 ]
134138
135- # Append an asset group signal operation is an audience ID is given.
136- if audience_id :
137- mutate_operations .append (
138- create_asset_group_signal_operation (
139- client , customer_id , audience_id
140- )
141- )
142-
143139 # Send the operations in a single Mutate request.
144140 response = googleads_service .mutate (
145141 customer_id = customer_id , mutate_operations = mutate_operations
@@ -632,8 +628,8 @@ def print_response_details(response):
632628 )
633629
634630
635- # [START add_performance_max_campaign_9]
636- def create_asset_group_signal_operation (client , customer_id , audience_id ):
631+
632+ def create_asset_group_signal_operations (client , customer_id , audience_id ):
637633 """Creates a list of MutateOperations that may create asset group signals.
638634
639635 Args:
@@ -644,25 +640,40 @@ def create_asset_group_signal_operation(client, customer_id, audience_id):
644640 Returns:
645641 MutateOperations that create new asset group signals.
646642 """
647- if not audience_id :
648- return None
649-
650643 googleads_service = client .get_service ("GoogleAdsService" )
651644 asset_group_resource_name = googleads_service .asset_group_path (
652645 customer_id , _ASSET_GROUP_TEMPORARY_ID
653646 )
654647
648+ operations = []
649+
650+ if audience_id :
651+ # Create an audience asset group signal.
652+ # To learn more about Audience Signals, see:
653+ # https://developers.google.com/google-ads/api/performance-max/asset-group-signals#audiences
654+ # [START add_performance_max_campaign_9]
655+ mutate_operation = client .get_type ("MutateOperation" )
656+ operation = mutate_operation .asset_group_signal_operation .create
657+ operation .asset_group = asset_group_resource_name
658+ operation .audience .audience = googleads_service .audience_path (
659+ customer_id , audience_id
660+ )
661+ operations .append (mutate_operation )
662+ # [END add_performance_max_campaign_9]
663+
664+ # Create a search theme asset group signal.
665+ # To learn more about Search Themes Signals, see:
666+ # https://developers.google.com/google-ads/api/performance-max/asset-group-signals#search_themes
667+ # [START add_performance_max_campaign_10]
655668 mutate_operation = client .get_type ("MutateOperation" )
656669 operation = mutate_operation .asset_group_signal_operation .create
657- # To learn more about Audience Signals, see:
658- # https://developers.google.com/google-ads/api/docs/performance-max/asset-groups#audience_signals
659670 operation .asset_group = asset_group_resource_name
660- operation .audience . audience = googleads_service . audience_path (
661- customer_id , audience_id
662- )
671+ operation .search_theme . text = "travel"
672+ operations . append ( mutate_operation )
673+ # [END add_performance_max_campaign_10]
663674
664- return mutate_operation
665- # [END add_performance_max_campaign_9]
675+ return operations
676+
666677
667678
668679# [END add_performance_max_campaign]
0 commit comments