Create a Things to do ad groupStay organized with collectionsSave and categorize content based on your preferences.
AI-generated Key Takeaways
To serve ads for your Things to do campaign, you must create an AdGroup with at least one ad in the ad group.
A campaign supports only an ad group of the TRAVEL_ADS type.
To serve ads for your Things to do campaign, you must create anAdGroupwith at least one ad in the ad group. As
shown later, a campaign supports only an ad group of theTRAVEL_ADStype,
which you can set in thetypefield.
defadd_ad_group(client:GoogleAdsClient,customer_id:str,campaign_resource_name:str)->str:"""Creates a new ad group in the specified Things to do campaign.Args:client: an initialized GoogleAdsClient instance.customer_id: a client customer ID.campaign_resource_name: the resource name of campaign that a new adgroup will belong to.Returns:The resource name of the newly created ad group."""# Creates an ad group operation.operation:AdGroupOperation=client.get_type("AdGroupOperation")# Creates an ad group.ad_group:AdGroup=operation.createad_group.name=f"Earth to Mars cruise #{get_printable_datetime()}"# Sets the campaign.ad_group.campaign=campaign_resource_name# Sets the ad group type to TRAVEL_ADS. This is the only value allowed# for this field on an ad group for a Things to do campaign.ad_group.type_=client.enums.AdGroupTypeEnum.TRAVEL_ADSad_group.status=client.enums.AdGroupStatusEnum.ENABLED# Issues a mutate request to add an ad group.ad_group_service:AdGroupServiceClient=client.get_service("AdGroupService")ad_group_response:MutateAdGroupsResponse=(ad_group_service.mutate_ad_groups(customer_id=customer_id,operations=[operation]))resource_name:str=ad_group_response.results[0].resource_nameprint(f"Added an ad group with resource name: '{resource_name}'.")returnresource_name
defadd_ad_group(client,customer_id,campaign_resource)# Create an ad group.ad_group_operation=client.operation.create_resource.ad_groupdo|ag|ag.name=generate_random_name_field("Earth to Mars Cruise")# Set the campaign.ag.campaign=campaign_resource# Set the ad group type to TRAVEL_ADS.# This cannot be set to other types.ag.type=:TRAVEL_ADSag.status=:ENABLEDend# Issue a mutate request to add the ad group.ad_group_service=client.service.ad_groupresponse=ad_group_service.mutate_ad_groups(customer_id:customer_id,operations:[ad_group_operation])# Fetch the new ad group's resource name.ad_group_resource=response.results.first.resource_nameputs"Added an ad group with resource name '#{ad_group_resource}'."ad_group_resourceend
subadd_ad_group{my($api_client,$customer_id,$campaign_resource_name)=@_;# Create an ad group.my$ad_group=Google::Ads::GoogleAds::V22::Resources::AdGroup->new({name=>"Earth to Mars Cruise #".uniqid(),# Set the campaign.campaign=>$campaign_resource_name,# Set the ad group type to TRAVEL_ADS.# This cannot be set to other types.type=>TRAVEL_ADS,status=>Google::Ads::GoogleAds::V22::Enums::AdGroupStatusEnum::ENABLED});# Create an ad group operation.my$ad_group_operation=Google::Ads::GoogleAds::V22::Services::AdGroupService::AdGroupOperation->new({create=>$ad_group});# Add the ad group.my$ad_group_resource_name=$api_client->AdGroupService()->mutate({customerId=>$customer_id,operations=>[$ad_group_operation]})->{results}[0]{resourceName};printf"Added an ad group with resource name: '%s'.\n",$ad_group_resource_name;return$ad_group_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-11-05 UTC."],[],[]]