대부분의 확장 소재 유형은 광고에 사용하기 전에 AssetService를 사용하여 만들어야 합니다.
TextAsset 유형은 광고 생성 중에 인라인으로 생성되므로 예외입니다. 다른 모든 유형은 먼저 Google Ads 계정에 업로드해야 사용할 수 있습니다.
확장 소재 연결 수준
애셋은 Google Ads 계정 계층 구조의 여러 항목에 연결하여 게재할 수 있습니다. 연결 수준은 확장 소재 유형과 캠페인 유형에 따라 다릅니다. 이러한 링크를 관리하는 일반적인 리소스는 다음과 같습니다.
CustomerAsset: 계정 수준에서 연결된 확장 소재입니다.CampaignAsset: 특정 캠페인에 연결된 애셋입니다.AdGroupAsset: 특정 광고 그룹에 연결된 애셋입니다.AssetGroupAsset: 실적 최대화 캠페인 내의 애셋 그룹에 연결된 애셋입니다.
사용할 특정 서비스와 리소스는 달성하려는 목표에 따라 달라집니다.
실적 최대화 캠페인 브랜드 애셋
실적 최대화 캠페인의 많은 애셋이 AssetGroupAsset를 사용하여 애셋 그룹에 연결되지만, 캠페인에 브랜드 가이드라인이 사용 설정된 경우 비즈니스 이름 및 비즈니스 로고 애셋은 예외입니다. 이 경우 각각 필드 유형 BUSINESS_NAME 및 LOGO과 함께 CampaignAsset를 사용하여 캠페인 수준에서 직접 연결됩니다. 캠페인에 브랜드 가이드라인이 사용 중지된 경우 이러한 확장 소재는 AssetGroupAsset를 사용하여 연결해야 합니다. 자세한 내용은 실적 최대화 캠페인의 애셋을 참고하세요.
애셋 만들기
이미지 및 미디어 번들 애셋을 만들 때는 고유한 이름이 필요합니다. 기존 이름을 제공하면 기존 이름에 고유한 문자열을 추가하여 새 이름이 생성됩니다. 컬렉션이 늘어남에 따라 개별 애셋을 더 쉽게 관리하고 식별할 수 있도록 설명이 포함된 고유한 이름을 사용하는 것이 좋습니다.
핵심사항: AssetService는 많은 확장 소재 유형 (예: 사이트링크, 콜아웃, 프로모션)에 대해 create 및 update 작업을 지원하지만, TextAsset 및 ImageAsset와 같은 변경 불가능한 확장 소재는 Google Ads 계정에 업로드된 후에는 수정할 수 없습니다. 개별 확장 소재와 광고 또는 캠페인 간의 연결을 관리하려면 광고 수준 또는 항목 수준 작업을 사용해야 합니다.
다음 예에서는 원시 이미지 데이터의 URL에서 새 이미지 확장 소재를 만드는 방법을 보여줍니다.
자바
private void runExample(GoogleAdsClient googleAdsClient, long customerId) throws IOException { byte[] imageData = ByteStreams.toByteArray(new URL(IMAGE_URL).openStream()); // Create the image asset. ImageAsset imageAsset = ImageAsset.newBuilder().setData(ByteString.copyFrom(imageData)).build(); // Creates an asset. Asset asset = Asset.newBuilder() // 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. .setName("Marketing Image") .setType(AssetType.IMAGE) .setImageAsset(imageAsset) .build(); // Creates the operation. AssetOperation operation = AssetOperation.newBuilder().setCreate(asset).build(); // Creates the service client. try (AssetServiceClient assetServiceClient = googleAdsClient.getLatestVersion().createAssetServiceClient()) { // Issues a mutate request to add the asset. MutateAssetsResponse response = assetServiceClient.mutateAssets(Long.toString(customerId), ImmutableList.of(operation)); // Prints the result. System.out.printf( "The image asset with resource name '%s' was created.%n", response.getResults(0).getResourceName()); } }
C#
public void Run(GoogleAdsClient client, long customerId) { // Get the AssetServiceClient. AssetServiceClient assetService = client.GetService(Services.V26.AssetService); // Creates an image content. byte[] imageContent = MediaUtilities.GetAssetDataFromUrl(IMAGE_URL, client.Config); // Creates an image asset. ImageAsset imageAsset = new ImageAsset() { Data = ByteString.CopyFrom(imageContent), FileSize = imageContent.Length, MimeType = MimeType.ImageJpeg, FullSize = new ImageDimension() { HeightPixels = 315, WidthPixels = 600, Url = IMAGE_URL } }; // Creates an asset. Asset asset = new Asset() { // Optional: Provide a unique friendly name to identify your asset. // If you specify the name field, then both the asset name and the image being // uploaded should be unique, and should not match another ACTIVE asset in this // customer account. // Name = 'Jupiter Trip #' + ExampleUtilities.GetRandomString(), Type = AssetType.Image, ImageAsset = imageAsset, // 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" }; // Creates an asset operation. AssetOperation operation = new AssetOperation() { Create = asset }; try { // Issues a mutate request to add the asset. MutateAssetsResponse response = assetService.MutateAssets(customerId.ToString(), new[] { operation }); // Displays the result. Console.WriteLine($"Image asset with resource name: " + $"'{response.Results.First().ResourceName}' is created."); } catch (GoogleAdsException e) { Console.WriteLine("Failure:"); Console.WriteLine($"Message: {e.Message}"); Console.WriteLine($"Failure: {e.Failure}"); Console.WriteLine($"Request ID: {e.RequestId}"); throw; } }
PHP
public static function runExample(GoogleAdsClient $googleAdsClient, int $customerId) { // Creates an image content. $imageContent = file_get_contents(self::IMAGE_URL); // Creates an asset. $asset = new Asset( [ // 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' => AssetType::IMAGE, 'image_asset' => new ImageAsset(['data' => $imageContent]) ] ); // Creates an asset operation. $assetOperation = new AssetOperation(); $assetOperation->setCreate($asset); // Issues a mutate request to add the asset. $assetServiceClient = $googleAdsClient->getAssetServiceClient(); $response = $assetServiceClient->mutateAssets( MutateAssetsRequest::build( $customerId, [$assetOperation] ) ); if (!empty($response->getResults())) { // Prints the resource name of the added image asset. /** * @var MutateAssetResult $addedImageAsset */ $addedImageAsset = $response->getResults()[0]; printf( "The image asset with resource name '%s' was created.%s", $addedImageAsset->getResourceName(), PHP_EOL ); } else { print 'No image asset was created.' . PHP_EOL; } }
Python
def main(client: GoogleAdsClient, customer_id: str) -> None: """Main method, to run this code example as a standalone application.""" # Download image from URL url: 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.create asset.type_ = client.enums.AssetTypeEnum.IMAGE asset.image_asset.data = image_content asset.image_asset.file_size = len(image_content) asset.image_asset.mime_type = client.enums.MimeTypeEnum.IMAGE_JPEG # Use your favorite image library to determine dimensions asset.image_asset.full_size.height_pixels = 315 asset.image_asset.full_size.width_pixels = 600 asset.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: MutateAssetResult for row in mutate_asset_response.results: print(f"\tResource name: {row.resource_name}")
Ruby
def upload_image_asset(customer_id) # GoogleAdsClient will read a config file from # ENV['HOME']/google_ads_config.rb when called without parameters client = Google::Ads::GoogleAds::GoogleAdsClient.new url = '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.asset do |asset| asset.type = :IMAGE asset.image_asset = client.resource.image_asset do |image_asset| image_asset.data = image_data image_asset.file_size = image_data.length() image_asset.mime_type = :IMAGE_JPEG image_asset.full_size = client.resource.image_dimension do |dimension| dimension.height_pixels = 315 dimension.width_pixels = 600 dimension.url = url end end # 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
Perl
sub upload_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::V26::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::V26::Common::ImageAsset->new({ data => $image_content })}); # Create an asset operation. my $asset_operation = Google::Ads::GoogleAds::V26::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}; return 1; }
curl
애셋이 생성되면 API는 새 ImageAsset의 리소스 이름이 포함된 MutateAssetResult 객체를 반환합니다. 이 리소스 이름은 애셋 기반 광고를 만들 때 ImageAsset를 참조하는 데 사용됩니다.
GoogleAdsService를 쿼리하여 기존 확장 소재 및 해당 리소스 이름의 목록을 가져올 수 있습니다. 자세한 내용은
확장 소재 속성 및 측정항목 가져오기를
참고하세요.
외부 프로모션 사용 추적
v26부터 PromotionAsset를 만들 때 ExternalRedeemInfo 유형의 변경 불가능한(CREATE_ONLY) promotion_asset.external_redeem_info 필드를 채워 파트너의 판매 시점 (POS) 시스템에서 오프라인 프로모션 사용을 추적할 수 있습니다. 계정에 프로모션 사용 통합이 있는 경우 해당 통합에 따라 API에서 허용하는 partner_promotion_id 변형이 결정됩니다. 이러한 필드는 변경할 수 없으므로 PromotionAsset를 만들 때만 설정할 수 있습니다.
update 작업에서 external_redeem_info 또는 하위 필드를 수정하거나 지우려고 하면 RequestError.IMMUTABLE_FIELD 오류가 반환됩니다.
ExternalRedeemInfo 메시지에는 다음과 같은 변경 불가능한(CREATE_ONLY) 필드가 포함됩니다.
code_type(필수): 프로모션 코드를 한 번(SINGLE_USE_PROMOTION_CODE) 또는 여러 번(MULTI_USE_PROMOTION_CODE) 사용할 수 있는지 지정하는OfflinePromotionCodeTypeenum 값입니다.code_source(필수): 프로모션 코드가 광고주에 의해 업로드되는지(CUSTOMER_UPLOADED) 아니면 Google에 의해 생성되는지 (GOOGLE_GENERATED)를 지정하는OfflinePromotionCodeSourceenum 값입니다. 이 필드를GOOGLE_GENERATED로 설정하면partner_promotion_id필드가 필요합니다 (그렇지 않으면 API가FieldError.REQUIRED오류를 반환함). 이 필드를CUSTOMER_UPLOADED로 설정하면partner_promotion_id필드는 선택사항입니다.partner_promotion_id: 파트너의 POS 시스템에서 프로모션을 식별하는ExternalPartnerId메시지입니다. POS 통합에서 사용하는 식별자 형식을 확인한 후 다음oneof변형 중 하나를 설정합니다.int_value(int64): 양의 정수 식별자 (1이상)입니다. 값이0이하이면RangeError.TOO_LOW오류가 반환됩니다.string: 1~50자의 인쇄 가능한 문자로 구성된 문자열 식별자입니다.string_valueAPI는 검증 전에 선행 및 후행 공백을 자르므로 비어 있거나 공백만 있는 문자열은StringLengthError.TOO_SHORT오류를 반환하고, 잘린 값이 50자(영문 기준)를 초과하면StringLengthError.TOO_LONG오류를 반환하며, 인쇄할 수 없는 문자가 있는 값은StringFormatError.ILLEGAL_CHARS오류를 반환합니다.
계정의 프로모션 통합에 특정
partner_promotion_id변형이 필요하고 다른 변형 (string_value대신int_value또는int_value대신string_value)을 설정하면 API에서AssetError.PARTNER_PROMOTION_ID_TYPE_INCOMPATIBLE오류를 반환합니다.
asset 보고서에서 네 개의 리프 필드를 모두 선택, 필터링 (WHERE), 정렬 (ORDER BY)할 수 있습니다. partner_promotion_id 필드는 oneof이므로 지정된 프로모션 확장 소재에 대해 int_value 또는 string_value 필드 중 최대 하나가 채워지고 설정되지 않은 변형은 null를 반환합니다.
SELECT
asset.resource_name,
asset.id,
asset.name,
asset.promotion_asset.promotion_target,
asset.promotion_asset.external_redeem_info.code_source,
asset.promotion_asset.external_redeem_info.code_type,
asset.promotion_asset.external_redeem_info.partner_promotion_id.int_value,
asset.promotion_asset.external_redeem_info.partner_promotion_id.string_value
FROM asset
WHERE asset.type = 'PROMOTION'
광고에서 확장 소재 사용
다음 표와 같이 광고 및 캠페인 유형에 따라 지원되는 확장 소재 유형이 다릅니다.
| 광고/캠페인 유형 및 지원되는 확장 소재 유형 | |
|---|---|
AppAd |
TextAssetImageAssetYoutubeVideoAssetMediaBundleAsset |
AppEngagementAd
|
TextAssetImageAssetYoutubeVideoAsset |
Demand Gen
|
TextAssetImageAssetYoutubeVideoAssetDemandGenCarouselCardAsset |
DisplayUploadAd
|
MediaBundleAsset |
| 실적 최대화 캠페인 |
TextAssetImageAssetMediaBundleAssetYoutubeVideoAssetCallToActionAsset
|
ResponsiveDisplayAd
|
TextAssetImageAssetYoutubeVideoAsset |
ResponsiveSearchAd
|
TextAsset (광고 소재의 광고 제목, 설명)다음 확장 소재 유형은 각각 CustomerAsset, CampaignAsset 또는 AdGroupAsset를 사용하여 고객, 캠페인 또는 광고 그룹 수준에서 연결하여 광고와 함께 광고 확장으로 게재할 수 있습니다.
참고: 위치 확장 소재와 제휴사 위치 확장 소재는 다르게 관리되며, 주로 CustomerAssetSet 또는
CampaignAssetSet를 통해 관리됩니다. 자세한 내용은
위치 확장 소재를
참고하세요.
|
이러한 각 광고 유형에는 지원하는 다양한 확장 소재 유형을 설정하는 필드가 있습니다. TextAsset의 경우 새 문자열 애셋이 광고 내에 인라인으로 생성됩니다. 다른 모든 확장 소재 유형의 경우 기존 확장 소재가 리소스 이름을 참조하여 광고에 추가됩니다.
다음 예에서는 TextAsset 및 ImageAsset를 ResponsiveDisplayAd에 추가하는 방법을 보여줍니다. TextAsset는 광고의 광고 제목 및 설명으로 인라인으로 생성됩니다. ImageAsset는 리소스 이름으로 지정됩니다.
자바
private void createAd( GoogleAdsClient googleAdsClient, long customerId, String adGroupResourceName) throws IOException { String marketingImageUrl = "https://gaagl.page.link/Eit5"; String marketingImageName = "Marketing Image"; String marketingImageResourceName = uploadAsset(googleAdsClient, customerId, marketingImageUrl, marketingImageName); String squareMarketingImageName = "Square Marketing Image"; String squareMarketingImageUrl = "https://gaagl.page.link/bjYi"; String squareMarketingImageResourceName = uploadAsset(googleAdsClient, customerId, squareMarketingImageUrl, squareMarketingImageName); // Creates the responsive display ad info object. ResponsiveDisplayAdInfo responsiveDisplayAdInfo = ResponsiveDisplayAdInfo.newBuilder() .addMarketingImages( AdImageAsset.newBuilder().setAsset(marketingImageResourceName).build()) .addSquareMarketingImages( AdImageAsset.newBuilder().setAsset(squareMarketingImageResourceName).build()) .addHeadlines(AdTextAsset.newBuilder().setText("Travel").build()) .setLongHeadline(AdTextAsset.newBuilder().setText("Travel the World").build()) .addDescriptions(AdTextAsset.newBuilder().setText("Take to the air!").build()) .setBusinessName("Interplanetary Cruises") // Optional: Call to action text. // Valid texts: https://support.google.com/adwords/answer/7005917 .setCallToActionText("Apply Now") // Optional: Sets the ad colors. .setMainColor("#0000ff") .setAccentColor("#ffff00") // Optional: Sets to false to strictly render the ad using the colors. .setAllowFlexibleColor(false) // Optional: Sets the format setting that the ad will be served in. .setFormatSetting(DisplayAdFormatSetting.NON_NATIVE) // Optional: Creates a logo image and sets it to the ad. /* .addLogoImages( AdImageAsset.newBuilder() .setAsset(StringValue.of("INSERT_LOGO_IMAGE_RESOURCE_NAME_HERE")) .build()) */ // Optional: Creates a square logo image and sets it to the ad. /* .addSquareLogoImages( AdImageAsset.newBuilder() .setAsset(StringValue.of("INSERT_SQUARE_LOGO_IMAGE_RESOURCE_NAME_HERE")) .build()) */ .build(); // Creates the ad. Ad ad = Ad.newBuilder() .setResponsiveDisplayAd(responsiveDisplayAdInfo) .addFinalUrls("http://www.example.com/") .build(); // Creates the ad group ad. AdGroupAd adGroupAd = AdGroupAd.newBuilder().setAdGroup(adGroupResourceName).setAd(ad).build(); // Creates the ad group ad operation. AdGroupAdOperation operation = AdGroupAdOperation.newBuilder().setCreate(adGroupAd).build(); // Creates the ad group ad service client. try (AdGroupAdServiceClient adGroupAdServiceClient = googleAdsClient.getLatestVersion().createAdGroupAdServiceClient()) { // Adds the ad group ad. MutateAdGroupAdsResponse response = adGroupAdServiceClient.mutateAdGroupAds( Long.toString(customerId), ImmutableList.of(operation)); System.out.printf( "Created ad group ad with resource name '%s'.%n", response.getResults(0).getResourceName()); } }
C#
private void CreateAd(GoogleAdsClient client, long customerId, string adGroupResourceName) { // Creates the ad group ad service client. AdGroupAdServiceClient adGroupAdServiceClient = client.GetService(Services.V26.AdGroupAdService); string marketingImageUrl = "https://gaagl.page.link/Eit5"; string marketingImageName = "Marketing Image"; string marketingImageResourceName = UploadAsset(client, customerId, marketingImageUrl, marketingImageName); string squareMarketingImageName = "Square Marketing Image"; string squareMarketingImageUrl = "https://gaagl.page.link/bjYi"; string squareMarketingImageResourceName = UploadAsset(client, customerId, squareMarketingImageUrl, squareMarketingImageName); // Creates the responsive display ad info object. ResponsiveDisplayAdInfo responsiveDisplayAdInfo = new ResponsiveDisplayAdInfo() { MarketingImages = { new AdImageAsset() { Asset = marketingImageResourceName } }, SquareMarketingImages = { new AdImageAsset() { Asset = squareMarketingImageResourceName } }, Headlines = { new AdTextAsset() { Text = "Travel" } }, LongHeadline = new AdTextAsset() { Text = "Travel the World" }, Descriptions = { new AdTextAsset() { Text = "Take to the air!" } }, BusinessName = "Interplanetary Cruises", // Optional: Call to action text. // Valid texts: https://support.google.com/adwords/answer/7005917 CallToActionText = "Apply Now", // Optional: Sets the ad colors. MainColor = "#0000ff", AccentColor = "#ffff00", // Optional: Sets to false to strictly render the ad using the colors. AllowFlexibleColor = false, // Optional: Sets the format setting that the ad will be served in. FormatSetting = DisplayAdFormatSetting.NonNative, // Optional: Creates a logo image and sets it to the ad. /* LogoImages = { new AdImageAsset() { Asset = "INSERT_LOGO_IMAGE_RESOURCE_NAME_HERE" }} */ // Optional: Creates a square logo image and sets it to the ad. /* SquareLogoImages = { new AdImageAsset() { Asset = "INSERT_SQUARE_LOGO_IMAGE_RESOURCE_NAME_HERE" }} */ }; // Creates the ad. Ad ad = new Ad() { ResponsiveDisplayAd = responsiveDisplayAdInfo, FinalUrls = { "http://www.example.com/" } }; // Creates the ad group ad. AdGroupAd adGroupAd = new AdGroupAd() { AdGroup = adGroupResourceName, Ad = ad }; // Creates the ad group ad operation. AdGroupAdOperation operation = new AdGroupAdOperation() { Create = adGroupAd }; // Adds the ad group ad. MutateAdGroupAdsResponse response = adGroupAdServiceClient.MutateAdGroupAds (customerId.ToString(), new[] { operation }); Console.WriteLine("Created ad group ad with resource name " + $"'{response.Results.First().ResourceName}'."); }
PHP
private static function createAd( GoogleAdsClient $googleAdsClient, int $customerId, string $adGroupResourceName ) { $marketingImageResourceName = self::uploadAsset( $googleAdsClient, $customerId, 'https://gaagl.page.link/Eit5', 'Marketing Image' ); $squareMarketingImageResourceName = self::uploadAsset( $googleAdsClient, $customerId, 'https://gaagl.page.link/bjYi', 'Square Marketing Image' ); // Creates the responsive display ad info object. $responsiveDisplayAdInfo = new ResponsiveDisplayAdInfo( [ 'marketing_images' => [new AdImageAsset(['asset' => $marketingImageResourceName])], 'square_marketing_images' => [new AdImageAsset( [ 'asset' => $squareMarketingImageResourceName ] )], 'headlines' => [new AdTextAsset(['text' => 'Travel'])], 'long_headline' => new AdTextAsset(['text' => 'Travel the World']), 'descriptions' => [new AdTextAsset(['text' => 'Take to the air!'])], 'business_name' => 'Interplanetary Cruises', // Optional: Call to action text. // Valid texts: https://support.google.com/google-ads/answer/7005917 'call_to_action_text' => 'Apply Now', // Optional: Sets the ad colors. 'main_color' => '#0000ff', 'accent_color' => '#ffff00', // Optional: Sets to false to strictly render the ad using the colors. 'allow_flexible_color' => false, // Optional: Sets the format setting that the ad will be served in. 'format_setting' => DisplayAdFormatSetting::NON_NATIVE // Optional: Creates a logo image and sets it to the ad. // 'logo_images' => [new AdImageAsset([ // 'asset' => 'INSERT_LOGO_IMAGE_RESOURCE_NAME_HERE' // ])], // Optional: Creates a square logo image and sets it to the ad. // 'square_logo_images' => [new AdImageAsset([ // 'asset' => 'INSERT_SQUARE_LOGO_IMAGE_RESOURCE_NAME_HERE' // ])] ] ); // Creates a new ad group ad. $adGroupAd = new AdGroupAd( [ 'ad' => new Ad( [ 'responsive_display_ad' => $responsiveDisplayAdInfo, 'final_urls' => ['http://www.example.com/'] ] ), 'ad_group' => $adGroupResourceName ] ); // Creates an ad group ad operation. $adGroupAdOperation = new AdGroupAdOperation(); $adGroupAdOperation->setCreate($adGroupAd); // Issues a mutate request to add the ad group ad. $adGroupAdServiceClient = $googleAdsClient->getAdGroupAdServiceClient(); $response = $adGroupAdServiceClient->mutateAdGroupAds( MutateAdGroupAdsRequest::build($customerId, [$adGroupAdOperation]) ); /** * @var AdGroupAd $addedAdGroupAd */ $addedAdGroupAd = $response->getResults()[0]; printf( "Created ad group ad with resource name '%s'.%s", $addedAdGroupAd->getResourceName(), PHP_EOL ); }
Python
def create_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_name square_marketing_image: AdImageAsset = client.get_type("AdImageAsset") square_marketing_image.asset = square_marketing_image_resource_name headline: 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.create ad_group_ad.ad_group = ad_group_resource_name ad_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/7005917 responsive_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}'." )
Ruby
def create_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_ad do |aga| aga.ad_group = ad_group_resource_name aga.status = :PAUSED aga.ad = client.resource.ad do |a| a.final_urls << "https://www.example.com" # Creates the responsive display ad info object. a.responsive_display_ad = client.resource.responsive_display_ad_info do |rda| rda.headlines << client.resource.ad_text_asset do |ata| ata.text = "Travel" end rda.long_headline = client.resource.ad_text_asset do |ata| ata.text = "Travel the World" end rda.descriptions << client.resource.ad_text_asset do |ata| ata.text = "Take to the air!" end rda.business_name = "Interplanetary Cruises" rda.marketing_images << client.resource.ad_image_asset do |aia| aia.asset = marketing_image_asset_resource_name end rda.square_marketing_images << client.resource.ad_image_asset do |aia| aia.asset = square_marketing_image_asset_resource_name end # Optional: Call to action text. # Valid texts: https://support.google.com/google-ads/answer/7005917 rda.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" # end end end end # 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_name puts "Created ad group ad: #{resource_name}" resource_name end
Perl
sub create_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::V26::Common::ResponsiveDisplayAdInfo->new({ marketingImages => [ Google::Ads::GoogleAds::V26::Common::AdImageAsset->new({ asset => $marketing_image_resource_name }) ], squareMarketingImages => [ Google::Ads::GoogleAds::V26::Common::AdImageAsset->new({ asset => $square_marketing_image_resource_name }) ], headlines => [ Google::Ads::GoogleAds::V26::Common::AdTextAsset->new({ text => "Travel" }) ], longHeadline => Google::Ads::GoogleAds::V26::Common::AdTextAsset->new({ text => "Travel the World" } ), descriptions => [ Google::Ads::GoogleAds::V26::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/7005917 callToActionText => "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::V26::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::V26::Common::AdImageAsset->new({ # asset => "INSERT_SQUARE_LOGO_IMAGE_RESOURCE_NAME_HERE" # }) # ] }); # Create an ad group ad. my $ad_group_ad = Google::Ads::GoogleAds::V26::Resources::AdGroupAd->new({ adGroup => $ad_group_resource_name, ad => Google::Ads::GoogleAds::V26::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::V26::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}; }
curl
애셋 추천
추천을 사용하면 다음과 같은 몇 가지 방법으로 확장 소재를 개선할 수 있습니다.
추천 확장 소재를 제안할 수 있으며,
RecommendationService.ApplyRecommendation를 호출하여 캠페인에 추가할 수 있습니다. 예를 들어CALLOUT_ASSET,SITELINK_ASSET,CALL_ASSET,LEAD_FORM_ASSET,RESPONSIVE_SEARCH_AD_ASSET추천을 가져온 다음 이를 적용하여 추천 확장 소재를 관련 캠페인, 광고 그룹 또는 광고에 연결할 수 있습니다.이를 통해 확장 소재를 업데이트하여 반응형 검색 광고 또는 실적 최대화 캠페인의 전반적인 광고 효력을 개선할 수 있는 영역을 파악할 수 있습니다. 예를 들어
IMPROVE_PERFORMANCE_MAX_AD_STRENGTH추천을 가져와서 광고 효력을 개선하기 위해 업데이트해야 하는 애셋 그룹을 확인할 수 있습니다.
자세한 내용은 최적화 점수 및 추천 가이드를 참고하세요.