defadd_ad_group_ad(client:GoogleAdsClient,customer_id:str,ad_group_resource_name:str)->None:"""Creates a new ad group ad in the specified ad group.Args:client: an initialized GoogleAdsClient instance.customer_id: a client customer ID.ad_group_resource_name: the resource name of ad group that a new adgroup ad will belong to."""# Creates an ad group ad operation.operation:AdGroupAdOperation=client.get_type("AdGroupAdOperation")# Creates a new ad group ad and sets a travel ad info.ad_group_ad:AdGroupAd=operation.create# Sets the ad group ad to enabled. Setting this to paused will cause an error# for Things to do campaigns. Pausing should happen at either the ad group# or campaign level.ad_group_ad.status=client.enums.AdGroupAdStatusEnum.ENABLEDad_group_ad.ad.travel_ad=client.get_type("TravelAdInfo")# Sets the ad group.ad_group_ad.ad_group=ad_group_resource_name# Issues a mutate request to add an ad group ad.ad_group_ad_service:AdGroupAdServiceClient=client.get_service("AdGroupAdService")response:MutateAdGroupAdsResponse=(ad_group_ad_service.mutate_ad_group_ads(customer_id=customer_id,operations=[operation]))resource_name:str=response.results[0].resource_nameprint(f"Added an ad group ad with resource name: '{resource_name}'.")
defadd_ad_group_ad(client,customer_id,ad_group_resource)# Creates a new ad group ad and sets a travel ad info.ad_group_ad_operation=client.operation.create_resource.ad_group_addo|aga|aga.ad=client.resource.addo|ad|ad.travel_ad=client.resource.travel_ad_infoend# Set the ad group ad to enabled. Setting this to paused will cause an error# for Things to Do campaigns. Pausing should happen at either the ad group# or campaign level.aga.status=:ENABLED# Set the ad group.aga.ad_group=ad_group_resourceend# Issue a mutate request to add the ad group ad.ad_group_ad_service=client.service.ad_group_adresponse=ad_group_ad_service.mutate_ad_group_ads(customer_id:customer_id,operations:[ad_group_ad_operation],)# Fetch the new ad group ad's resource name.ad_group_ad_resource=response.results.first.resource_nameputs"Added an ad group ad with resource name '#{ad_group_ad_resource}'."end
subadd_ad_group_ad{my($api_client,$customer_id,$ad_group_resource_name)=@_;# Create an ad group ad and set a travel ad info.my$ad_group_ad=Google::Ads::GoogleAds::V22::Resources::AdGroupAd->new({# Set the ad group.adGroup=>$ad_group_resource_name,ad=>Google::Ads::GoogleAds::V22::Resources::Ad->new({travelAd=>Google::Ads::GoogleAds::V22::Common::TravelAdInfo->new()}),# Set the ad group to enabled. Setting this to paused will cause an error# for Things to do campaigns. Pausing should happen at either the ad group# or campaign level.status=>Google::Ads::GoogleAds::V22::Enums::AdGroupAdStatusEnum::ENABLED});# Create an ad group ad operation.my$ad_group_ad_operation=Google::Ads::GoogleAds::V22::Services::AdGroupAdService::AdGroupAdOperation->new({create=>$ad_group_ad});# Add the ad group ad.my$ad_group_ad_resource_name=$api_client->AdGroupAdService()->mutate({customerId=>$customer_id,operations=>[$ad_group_ad_operation]})->{results}[0]{resourceName};printf"Added an ad group ad with resource name: '%s'.\n",$ad_group_ad_resource_name;return$ad_group_ad_resource_name;}
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-12-03 UTC."],[],[]]