Stay organized with collectionsSave and categorize content based on your preferences.
Most asset types must be created using theAssetServicebefore they can be used in an ad.
TheTextAssettype is the exception as it is
created inline during ad creation. All other types must first be uploaded to an
advertiser's account before they can be used.
Create an asset
Unique names are required when creating image and media bundle assets. If you
supply an existing name, a new name will be created by appending a unique
string to the existing name. We strongly recommend that you use unique names
that are descriptive to make it easier to manage and identify individual assets
as your collection grows.
The following example shows how to create a new image asset from a URL of raw
image data.
defmain(client:GoogleAdsClient,customer_id:str)->None:"""Main method, to run this code example as a standalone application."""# Download image from URLurl:str="https://gaagl.page.link/Eit5"image_content:bytes=get_image_bytes_from_url(url)asset_service:AssetServiceClient=client.get_service("AssetService")asset_operation:AssetOperation=client.get_type("AssetOperation")asset:Asset=asset_operation.createasset.type_=client.enums.AssetTypeEnum.IMAGEasset.image_asset.data=image_contentasset.image_asset.file_size=len(image_content)asset.image_asset.mime_type=client.enums.MimeTypeEnum.IMAGE_JPEG# Use your favorite image library to determine dimensionsasset.image_asset.full_size.height_pixels=315asset.image_asset.full_size.width_pixels=600asset.image_asset.full_size.url=url# Provide a unique friendly name to identify your asset.# When there is an existing image asset with the same content but a different# name, the new name will be dropped silently.asset.name="Marketing Image"mutate_asset_response:MutateAssetsResponse=asset_service.mutate_assets(customer_id=customer_id,operations=[asset_operation])print("Uploaded file(s):")row:MutateAssetResultforrowinmutate_asset_response.results:print(f"\tResource name:{row.resource_name}")
defupload_image_asset(customer_id)# GoogleAdsClient will read a config file from# ENV['HOME']/google_ads_config.rb when called without parametersclient=Google::Ads::GoogleAds::GoogleAdsClient.newurl='https://gaagl.page.link/Eit5'image_data=open(url){|f|f.read}# Create the operation for uploading the image asset.asset_operation=client.operation.create_resource.assetdo|asset|asset.type=:IMAGEasset.image_asset=client.resource.image_assetdo|image_asset|image_asset.data=image_dataimage_asset.file_size=image_data.length()image_asset.mime_type=:IMAGE_JPEGimage_asset.full_size=client.resource.image_dimensiondo|dimension|dimension.height_pixels=315dimension.width_pixels=600dimension.url=urlendend# Provide a unique friendly name to identify your asset.# When there is an existing image asset with the same content but a different# name, the new name will be dropped silently.asset.name="Marketing Image"end# Upload the image asset.response=client.service.asset.mutate_assets(customer_id:customer_id,operations:[asset_operation],)puts"Uploaded image asset#{response.results.first.resource_name}."end
subupload_image_asset{my($api_client,$customer_id)=@_;# Create an image content.my$image_content=get_base64_data_from_url(IMAGE_URL);# Create an asset.my$asset=Google::Ads::GoogleAds::V21::Resources::Asset->new({# Provide a unique friendly name to identify your asset.# When there is an existing image asset with the same content but a different# name, the new name will be dropped silently.name=>"Marketing Image",type=>IMAGE,imageAsset=>Google::Ads::GoogleAds::V21::Common::ImageAsset->new({data=>$image_content})});# Create an asset operation.my$asset_operation=Google::Ads::GoogleAds::V21::Services::AssetService::AssetOperation->new({create=>$asset});# Issue a mutate request to add the asset.my$assets_response=$api_client->AssetService()->mutate({customerId=>$customer_id,operations=>[$asset_operation]});printf"The image asset with resource name '%s' was created.\n",$assets_response->{results}[0]{resourceName};return1;}
After the asset has been created, the API returns aMutateAssetResultobject that contains the
resource name of the newImageAsset. This resource
name is used to reference theImageAssetwhen creating an asset-based ad.
Each of these ad types has fields for setting the various asset types that
it supports. ForTextAsset, a new string asset is
created inline within the ad. For all other asset types, existing assets are
added to the ad by referencing their resource names.
defcreate_ad(client:GoogleAdsClient,customer_id:str,ad_group_resource_name:str)->None:"""Creates the responsive display ad.Args:client: An initialized GoogleAds client.customer_id: The Google Ads customer ID.ad_group_resource_name: The resource name of the target ad group."""# Get the AdGroupAdService client.ad_group_ad_service:AdGroupAdServiceClient=client.get_service("AdGroupAdService")# Upload image assets for the ad.marketing_image_resource_name:str=upload_image_asset(client,customer_id,"https://gaagl.page.link/Eit5","Marketing Image")square_marketing_image_resource_name:str=upload_image_asset(client,customer_id,"https://gaagl.page.link/bjYi","Square Marketing Image",)# Create the relevant asset objects for the ad.marketing_image:AdImageAsset=client.get_type("AdImageAsset")marketing_image.asset=marketing_image_resource_namesquare_marketing_image:AdImageAsset=client.get_type("AdImageAsset")square_marketing_image.asset=square_marketing_image_resource_nameheadline:AdTextAsset=client.get_type("AdTextAsset")headline.text="Travel"description:AdTextAsset=client.get_type("AdTextAsset")description.text="Take to the air!"# Create an ad group ad operation and set the ad group ad values.ad_group_ad_operation:AdGroupAdOperation=client.get_type("AdGroupAdOperation")ad_group_ad:AdGroupAd=ad_group_ad_operation.createad_group_ad.ad_group=ad_group_resource_namead_group_ad.ad.final_urls.append("http://www.example.com/")# Configure the responsive display ad info object.responsive_display_ad_info:ResponsiveDisplayAdInfo=(ad_group_ad.ad.responsive_display_ad)responsive_display_ad_info.marketing_images.append(marketing_image)responsive_display_ad_info.square_marketing_images.append(square_marketing_image)responsive_display_ad_info.headlines.append(headline)responsive_display_ad_info.long_headline.text="Travel the World"responsive_display_ad_info.descriptions.append(description)responsive_display_ad_info.business_name="Interplanetary Cruises"# Optional: Call to action text.# Valid texts: https://support.google.com/google-ads/answer/7005917responsive_display_ad_info.call_to_action_text="Apply Now"# Optional: Set the ad colors.responsive_display_ad_info.main_color="#0000ff"responsive_display_ad_info.accent_color="#ffff00"# Optional: Set to false to strictly render the ad using the colors.responsive_display_ad_info.allow_flexible_color=False# Optional: Set the format setting that the ad will be served in.responsive_display_ad_info.format_setting=(client.enums.DisplayAdFormatSettingEnum.NON_NATIVE)# Optional: Create a logo image and set it to the ad.# logo_image = client.get_type("AdImageAsset")# logo_image.asset = "INSERT_LOGO_IMAGE_RESOURCE_NAME_HERE"# responsive_display_ad_info.logo_images.append(logo_image)# Optional: Create a square logo image and set it to the ad.# square_logo_image = client.get_type("AdImageAsset")# square_logo_image.asset = "INSERT_SQUARE_LOGO_IMAGE_RESOURCE_NAME_HERE"# responsive_display_ad_info.square_logo_images.append(square_logo_image)# Issue a mutate request to add the ad group ad.ad_group_ad_response:MutateAdGroupAdsResponse=(ad_group_ad_service.mutate_ad_group_ads(customer_id=customer_id,operations=[ad_group_ad_operation]))print("Created ad group ad with resource name "f"'{ad_group_ad_response.results[0].resource_name}'.")
defcreate_ad(client,customer_id,ad_group_resource_name)marketing_image_url="https://gaagl.page.link/Eit5"square_marketing_image_url="https://gaagl.page.link/bjYi"marketing_image_asset_resource_name=upload_asset(client,customer_id,marketing_image_url,"Marketing Image")square_marketing_image_asset_resource_name=upload_asset(client,customer_id,square_marketing_image_url,"Square Marketing Image")# Creates an ad group ad operation.operation=client.operation.create_resource.ad_group_addo|aga|aga.ad_group=ad_group_resource_nameaga.status=:PAUSEDaga.ad=client.resource.addo|a|a.final_urls<<"https://www.example.com"# Creates the responsive display ad info object.a.responsive_display_ad=client.resource.responsive_display_ad_infodo|rda|rda.headlines<<client.resource.ad_text_assetdo|ata|ata.text="Travel"endrda.long_headline=client.resource.ad_text_assetdo|ata|ata.text="Travel the World"endrda.descriptions<<client.resource.ad_text_assetdo|ata|ata.text="Take to the air!"endrda.business_name="Interplanetary Cruises"rda.marketing_images<<client.resource.ad_image_assetdo|aia|aia.asset=marketing_image_asset_resource_nameendrda.square_marketing_images<<client.resource.ad_image_assetdo|aia|aia.asset=square_marketing_image_asset_resource_nameend# Optional: Call to action text.# Valid texts: https://support.google.com/google-ads/answer/7005917rda.call_to_action_text="Apply Now"# Optional: Sets the ad colors.rda.main_color="#0000ff"rda.accent_color="#ffff00"# Optional: Sets to false to strictly render the ad using the colors.rda.allow_flexible_color=false# Optional: Sets the format setting that the ad will be served in.rda.format_setting=:NON_NATIVE# Optional: Creates a logo image and sets it to the ad.# rda.logo_images << client.resource.ad_image_asset do |aia|# aia.asset = "INSERT_LOGO_IMAGE_RESOURCE_NAME_HERE"# end# Optional: Creates a square logo image and sets it to the ad.# rda.square_logo_images << client.resource.ad_image_asset do |aia|# aia.asset = "INSERT_SQUARE_LOGO_IMAGE_RESOURCE_NAME_HERE"# endendendend# Issues a mutate request to add the ad group ad.response=client.service.ad_group_ad.mutate_ad_group_ads(customer_id:customer_id,operations:[operation])# Prints out some information about the newly created ad.resource_name=response.results.first.resource_nameputs"Created ad group ad:#{resource_name}"resource_nameend
subcreate_ad{my($api_client,$customer_id,$ad_group_resource_name)=@_;my$marketing_image_resource_name=upload_asset($api_client,$customer_id,"https://gaagl.page.link/Eit5","Marketing Image");my$square_marketing_image_resource_name=upload_asset($api_client,$customer_id,"https://gaagl.page.link/bjYi","Square Marketing Image");# Create the responsive display ad info object.my$responsive_display_ad_info=Google::Ads::GoogleAds::V21::Common::ResponsiveDisplayAdInfo->new({marketingImages=>[Google::Ads::GoogleAds::V21::Common::AdImageAsset->new({asset=>$marketing_image_resource_name})],squareMarketingImages=>[Google::Ads::GoogleAds::V21::Common::AdImageAsset->new({asset=>$square_marketing_image_resource_name})],headlines=>[Google::Ads::GoogleAds::V21::Common::AdTextAsset->new({text=>"Travel"})],longHeadline=>Google::Ads::GoogleAds::V21::Common::AdTextAsset->new({text=>"Travel the World"}),descriptions=>[Google::Ads::GoogleAds::V21::Common::AdTextAsset->new({text=>"Take to the air!"})],businessName=>"Interplanetary Cruises",# Optional: Call to action text.# Valid texts: https://support.google.com/google-ads/answer/7005917callToActionText=>"Apply Now",# Optional: Set the ad colors.mainColor=>"#0000ff",accentColor=>"#ffff00",# Optional: Set to false to strictly render the ad using the colors.allowFlexibleColor=>"false",# Optional: Set the format setting that the ad will be served in.formatSetting=>NON_NATIVE,# Optional: Create a logo image and set it to the ad.# logoImages => [# Google::Ads::GoogleAds::V21::Common::AdImageAsset->new({# asset => "INSERT_LOGO_IMAGE_RESOURCE_NAME_HERE"# })# ],# Optional: Create a square logo image and set it to the ad.# squareLogoImages => [# Google::Ads::GoogleAds::V21::Common::AdImageAsset->new({# asset => "INSERT_SQUARE_LOGO_IMAGE_RESOURCE_NAME_HERE"# })# ]});# Create an ad group ad.my$ad_group_ad=Google::Ads::GoogleAds::V21::Resources::AdGroupAd->new({adGroup=>$ad_group_resource_name,ad=>Google::Ads::GoogleAds::V21::Resources::Ad->new({responsiveDisplayAd=>$responsive_display_ad_info,finalUrls=>["http://www.example.com/"]})});# Create an ad group ad operation.my$ad_group_ad_operation=Google::Ads::GoogleAds::V21::Services::AdGroupAdService::AdGroupAdOperation->new({create=>$ad_group_ad});# Issue a mutate request to add the ad group ad.my$ad_group_ads_response=$api_client->AdGroupAdService()->mutate({customerId=>$customer_id,operations=>[$ad_group_ad_operation]});printf"Created ad group ad with resource name '%s'.\n",$ad_group_ads_response->{results}[0]{resourceName};}
They can suggest assets for you, which you can add to your campaign by
callingRecommendationService.ApplyRecommendation.
For example, you can retrieveCALLOUT_ASSET,SITELINK_ASSET,CALL_ASSET,LEAD_FORM_ASSETandRESPONSIVE_SEARCH_AD_ASSETrecommendations, and then apply them to attach the recommended assets to the
relevant campaign, ad group, or ad.
They can help you identify areas where you can update your assets to
improve the overall strength of your responsive search ads or your
Performance Max campaigns. For example, you can retrieveIMPROVE_PERFORMANCE_MAX_AD_STRENGTHrecommendations to see which asset groups should be updated to improve their
strength.
[[["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-09-03 UTC."],[[["\u003cp\u003eGoogle Ads uses assets like images and text to build ads; most asset types require creation and upload before use within ads.\u003c/p\u003e\n"],["\u003cp\u003e\u003ccode\u003eTextAsset\u003c/code\u003e is an exception and is directly embedded within ads, while other assets are referenced by their unique resource names after upload.\u003c/p\u003e\n"],["\u003cp\u003eUploaded assets are immutable, requiring recreation for any changes, and cannot be deleted.\u003c/p\u003e\n"],["\u003cp\u003eResponsive Display Ads utilize assets for their visual and textual elements, and the provided code snippets guide the creation process using various client libraries.\u003c/p\u003e\n"],["\u003cp\u003eAsset recommendations offered by Google Ads can be applied to improve ad performance and address areas needing enhancements for better campaign results.\u003c/p\u003e\n"]]],[],null,[]]