最高成效廣告活動在素材資源方面有幾項獨特的特性。
- 必須提供不同類型的素材資源最低數量。
- 素材資源會在稱為
AssetGroup
的集合中分組,這是最高成效廣告活動專有的集合。 - 部分素材資源可透過機器學習自動產生。
程式碼範例
以下程式碼片段說明如何在新的要求中建立必要的重複素材資源:
Java
/** Creates multiple text assets and returns the list of resource names. */ private List<String> createMultipleTextAssets( GoogleAdsClient googleAdsClient, long customerId, List<String> texts) { List<MutateOperation> mutateOperations = new ArrayList<>(); for (String text : texts) { Asset asset = Asset.newBuilder().setTextAsset(TextAsset.newBuilder().setText(text)).build(); AssetOperation assetOperation = AssetOperation.newBuilder().setCreate(asset).build(); mutateOperations.add(MutateOperation.newBuilder().setAssetOperation(assetOperation).build()); } List<String> assetResourceNames = new ArrayList<>(); // Creates the service client. try (GoogleAdsServiceClient googleAdsServiceClient = googleAdsClient.getLatestVersion().createGoogleAdsServiceClient()) { // Sends the operations in a single Mutate request. MutateGoogleAdsResponse response = googleAdsServiceClient.mutate(Long.toString(customerId), mutateOperations); for (MutateOperationResponse result : response.getMutateOperationResponsesList()) { if (result.hasAssetResult()) { assetResourceNames.add(result.getAssetResult().getResourceName()); } } printResponseDetails(response); } return assetResourceNames; }
C#
/// <summary> /// Creates multiple text assets and returns the list of resource names. /// </summary> /// <param name="client">The Google Ads Client.</param> /// <param name="customerId">The customer's ID.</param> /// <param name="texts">The texts to add.</param> /// <returns>A list of asset resource names.</returns> private List<string> CreateMultipleTextAssets( GoogleAdsClient client, long customerId, string[] texts) { // Get the GoogleAdsService. GoogleAdsServiceClient googleAdsServiceClient = client.GetService(Services.V19.GoogleAdsService); MutateGoogleAdsRequest request = new MutateGoogleAdsRequest() { CustomerId = customerId.ToString() }; foreach (string text in texts) { request.MutateOperations.Add( new MutateOperation() { AssetOperation = new AssetOperation() { Create = new Asset() { TextAsset = new TextAsset() { Text = text } } } } ); } // Send the operations in a single Mutate request. MutateGoogleAdsResponse response = googleAdsServiceClient.Mutate(request); List<string> assetResourceNames = new List<string>(); foreach (MutateOperationResponse operationResponse in response.MutateOperationResponses) { MutateAssetResult assetResult = operationResponse.AssetResult; assetResourceNames.Add(assetResult.ResourceName); } PrintResponseDetails(response); return assetResourceNames; }
PHP
private static function createMultipleTextAssets( GoogleAdsClient $googleAdsClient, int $customerId, array $texts ): array { // Here again, we use the GoogleAdService to create multiple text assets in a single // request. $operations = []; foreach ($texts as $text) { // Creates a mutate operation for a text asset. $operations[] = new MutateOperation([ 'asset_operation' => new AssetOperation([ 'create' => new Asset(['text_asset' => new TextAsset(['text' => $text])]) ]) ]); } // Issues a mutate request to add all assets. $googleAdsService = $googleAdsClient->getGoogleAdsServiceClient(); /** @var MutateGoogleAdsResponse $mutateGoogleAdsResponse */ $mutateGoogleAdsResponse = $googleAdsService->mutate(MutateGoogleAdsRequest::build($customerId, $operations)); $assetResourceNames = []; foreach ($mutateGoogleAdsResponse->getMutateOperationResponses() as $response) { /** @var MutateOperationResponse $response */ $assetResourceNames[] = $response->getAssetResult()->getResourceName(); } self::printResponseDetails($mutateGoogleAdsResponse); return $assetResourceNames; }
Python
def create_multiple_text_assets(client, customer_id, texts): """Creates multiple text assets and returns the list of resource names. Args: client: an initialized GoogleAdsClient instance. customer_id: a client customer ID. texts: a list of strings, each of which will be used to create a text asset. Returns: asset_resource_names: a list of asset resource names. """ # Here again we use the GoogleAdService to create multiple text # assets in a single request. googleads_service = client.get_service("GoogleAdsService") operations = [] for text in texts: mutate_operation = client.get_type("MutateOperation") asset = mutate_operation.asset_operation.create asset.text_asset.text = text operations.append(mutate_operation) # Send the operations in a single Mutate request. response = googleads_service.mutate( customer_id=customer_id, mutate_operations=operations, ) asset_resource_names = [] for result in response.mutate_operation_responses: if result._pb.HasField("asset_result"): asset_resource_names.append(result.asset_result.resource_name) print_response_details(response) return asset_resource_names
小茹
# Creates multiple text assets and returns the list of resource names. def create_multiple_text_assets(client, customer_id, texts) operations = texts.map do |text| client.operation.mutate do |m| m.asset_operation = client.operation.create_resource.asset do |asset| asset.text_asset = client.resource.text_asset do |text_asset| text_asset.text = text end end end end # Send the operations in a single Mutate request. response = client.service.google_ads.mutate( customer_id: customer_id, mutate_operations: operations, ) asset_resource_names = [] response.mutate_operation_responses.each do |result| if result.asset_result asset_resource_names.append(result.asset_result.resource_name) end end print_response_details(response) asset_resource_names end
Perl
sub create_multiple_text_assets { my ($api_client, $customer_id, $texts) = @_; # Here again we use the GoogleAdService to create multiple text assets in a # single request. my $operations = []; foreach my $text (@$texts) { # Create a mutate operation for a text asset. push @$operations, Google::Ads::GoogleAds::V19::Services::GoogleAdsService::MutateOperation ->new({ assetOperation => Google::Ads::GoogleAds::V19::Services::AssetService::AssetOperation-> new({ create => Google::Ads::GoogleAds::V19::Resources::Asset->new({ textAsset => Google::Ads::GoogleAds::V19::Common::TextAsset->new({ text => $text })})})}); } # Issue a mutate request to add all assets. my $mutate_google_ads_response = $api_client->GoogleAdsService()->mutate({ customerId => $customer_id, mutateOperations => $operations }); my $asset_resource_names = []; foreach my $response (@{$mutate_google_ads_response->{mutateOperationResponses}}) { push @$asset_resource_names, $response->{assetResult}{resourceName}; } print_response_details($mutate_google_ads_response); return $asset_resource_names; }
自動建立的素材資源
Google 自動化工具會運用機器學習技術,視需要產生額外的素材資源,涵蓋所有相關管道。系統會根據放送廣告的 Google Ads 管道 (例如 YouTube、Gmail 或 Google 搜尋),自動混搭這些素材資源。
文字素材資源
您可以將帳戶中的網頁動態饋給與最高成效廣告活動建立關聯,以便自動產生素材資源。
如要將網頁動態饋給連結至廣告活動,請按照動態搜尋廣告的程序操作:
關聯網頁動態饋給後,請確認 TEXT_ASSET_AUTOMATION
類型的 AssetAutomationSetting
已設為 OPTED_IN
。如果您在建立廣告活動時未設定 AssetAutomationSetting
,系統會採用預設設定。
採用這項設定後,如果系統預測能夠提升成效,您的廣告活動可以使用到達網頁、網域和已提供的素材資源中的內容自訂廣告。建議將此值保留為 OPTED-IN
。
影片素材資源
如果您沒有在最高成效素材資源群組中加入影片,系統可能會根據素材資源群組中的素材資源產生一或多部影片素材資源。如果您不希望繼續在最高成效廣告活動中顯示自動產生的影片,可以自行上傳自訂影片,這樣就不會再顯示自動產生的影片。
智慧自動化功能可調整影片方向並聰明地縮短影片,以便突顯重要時刻,強化 YouTube 影片資產。如果您想保留原始影片素材資源,請將 GENERATE_ENHANCED_YOUTUBE_VIDEOS
類型的 AssetAutomationSetting
設為 OPTED_OUT
。