Đề xuất có thể cải thiện chiến dịch của bạn theo một số cách:
- Giới thiệu các tính năng mới và phù hợp
- Khai thác ngân sách hiệu quả hơn nhờ giá thầu, từ khoá và quảng cáo được cải thiện
- Tăng hiệu suất và hiệu quả tổng thể của các chiến dịch
Để tăng điểm tối ưu hoá, bạn có thể sử dụng
RecommendationService để truy xuất
các đề xuất, sau đó áp dụng hoặc loại bỏ các đề xuất đó cho phù hợp. Bạn cũng có thể
đăng ký tự động áp dụng
các đề xuất bằng cách sử dụng RecommendationSubscriptionService.
Điểm tối ưu hóa
Điểm tối ưu hoá là điểm số ước tính mức độ hiệu quả của tài khoản Google Ads và có ở cấp Customer và Campaign.
Có các chỉ số liên quan đến việc tối ưu hoá cho báo cáo customer và campaign:
- Biểu tượng
metrics.optimization_score_urlcung cấp một đường liên kết sâu đến tài khoản để xem thông tin về các đề xuất liên quan trong giao diện người dùng Google Ads. metrics.optimization_score_upliftcho biết mức tăng của điểm tối ưu hoá nếu bạn áp dụng tất cả các đề xuất có liên quan. Đây là mức ước tính dựa trên tất cả các đề xuất hiện có, chứ không chỉ là tổng điểm tăng thêm của từng đề xuất.
Để nhóm và sắp xếp các đề xuất được trả về, bạn có thể phân đoạn cả hai chỉ số này theo loại đề xuất bằng cách sử dụng segments.recommendation_type trong truy vấn của mình.
Các loại đề xuất
Bảng sau đây liệt kê các loại đề xuất được hỗ trợ trong Google Ads API để truy xuất, áp dụng và loại bỏ đề xuất. Nếu một tài khoản có các loại đề xuất trong giao diện người dùng Google Ads không được hỗ trợ trong API, thì bạn có thể sử dụng metrics.optimization_score_url để liên kết người dùng trực tiếp đến trang Đề xuất trong giao diện người dùng Google Ads để xem xét và thực hiện các đề xuất đó.
Các loại đề xuất được hỗ trợ đầy đủ
| RecommendationType | Mô tả |
|---|---|
CAMPAIGN_BUDGET |
Khắc phục các chiến dịch bị giới hạn theo ngân sách |
KEYWORD |
Thêm từ khoá mới |
TEXT_AD |
Thêm đề xuất quảng cáo |
TARGET_CPA_OPT_IN |
Đặt giá thầu bằng CPA mục tiêu |
MAXIMIZE_CONVERSIONS_OPT_IN |
Đặt giá thầu bằng chiến lược Tối đa hoá lượt chuyển đổi |
MAXIMIZE_CONVERSION_VALUE_OPT_IN |
Đặt giá thầu bằng chiến lược Tối đa hoá giá trị lượt chuyển đổi |
ENHANCED_CPC_OPT_IN |
Đặt giá thầu bằng chiến lược CPC nâng cao |
MAXIMIZE_CLICKS_OPT_IN |
Đặt giá thầu bằng chiến lược Tối đa hoá số lượt nhấp |
OPTIMIZE_AD_ROTATION |
Sử dụng chế độ xoay vòng quảng cáo được tối ưu hoá |
MOVE_UNUSED_BUDGET |
Chuyển ngân sách chưa sử dụng sang ngân sách bị giới hạn |
TARGET_ROAS_OPT_IN |
Đặt giá thầu theo ROAS mục tiêu |
FORECASTING_CAMPAIGN_BUDGET |
Khắc phục những chiến dịch dự kiến sẽ bị giới hạn theo ngân sách trong tương lai |
RESPONSIVE_SEARCH_AD |
Thêm quảng cáo tìm kiếm thích ứng mới |
MARGINAL_ROI_CAMPAIGN_BUDGET |
Điều chỉnh ngân sách chiến dịch để tăng ROI |
USE_BROAD_MATCH_KEYWORD |
Sử dụng kiểu khớp mở rộng cho các chiến dịch dựa trên lượt chuyển đổi có tính năng đặt giá thầu tự động |
RESPONSIVE_SEARCH_AD_ASSET |
Thêm thành phần quảng cáo tìm kiếm thích ứng vào quảng cáo |
RESPONSIVE_SEARCH_AD_IMPROVE_AD_STRENGTH |
Cải thiện độ mạnh của quảng cáo tìm kiếm thích ứng |
DISPLAY_EXPANSION_OPT_IN |
Cập nhật chiến dịch để sử dụng tính năng Mở rộng hiển thị |
SEARCH_PARTNERS_OPT_IN |
Mở rộng phạm vi tiếp cận thông qua các đối tác tìm kiếm của Google |
CUSTOM_AUDIENCE_OPT_IN |
Tạo đối tượng tùy chỉnh |
IMPROVE_DEMAND_GEN_AD_STRENGTH |
Cải thiện độ mạnh của quảng cáo trong chiến dịch Tạo nhu cầu |
UPGRADE_SMART_SHOPPING_CAMPAIGN_TO_PERFORMANCE_MAX |
Nâng cấp chiến dịch Mua sắm thông minh lên chiến dịch Tối đa hoá hiệu suất |
UPGRADE_LOCAL_CAMPAIGN_TO_PERFORMANCE_MAX |
Nâng cấp chiến dịch địa phương cũ lên chiến dịch Tối đa hoá hiệu suất |
SHOPPING_MIGRATE_REGULAR_SHOPPING_CAMPAIGN_OFFERS_TO_PERFORMANCE_MAX
|
Di chuyển các sản phẩm/dịch vụ được nhắm mục tiêu bằng chiến dịch Mua sắm cơ bản sang chiến dịch Tối đa hoá hiệu suất hiện có |
MIGRATE_DYNAMIC_SEARCH_ADS_CAMPAIGN_TO_PERFORMANCE_MAX
|
Di chuyển Quảng cáo tìm kiếm động sang chiến dịch Tối đa hoá hiệu suất |
PERFORMANCE_MAX_OPT_IN |
Tạo chiến dịch Tối đa hoá hiệu suất trong tài khoản của bạn |
IMPROVE_PERFORMANCE_MAX_AD_STRENGTH |
Cải thiện độ mạnh của nhóm thành phần trong chiến dịch Tối đa hoá hiệu suất thành mức "Rất tốt" |
PERFORMANCE_MAX_FINAL_URL_OPT_IN |
Bật tính năng Mở rộng URL cuối cùng cho chiến dịch Tối đa hoá hiệu suất |
RAISE_TARGET_CPA_BID_TOO_LOW |
Tăng CPA mục tiêu khi mức này quá thấp và có rất ít hoặc không có lượt chuyển đổi |
FORECASTING_SET_TARGET_ROAS |
Tăng ngân sách trước một sự kiện theo mùa được dự đoán sẽ làm tăng lưu lượng truy cập, đồng thời thay đổi chiến lược đặt giá thầu từ tối đa hoá giá trị lượt chuyển đổi thành ROAS mục tiêu |
LEAD_FORM_ASSET |
Thêm thành phần biểu mẫu khách hàng tiềm năng vào chiến dịch |
CALLOUT_ASSET |
Thêm thành phần chú thích vào chiến dịch hoặc cấp khách hàng |
SITELINK_ASSET |
Thêm thành phần đường liên kết của trang web vào chiến dịch hoặc cấp khách hàng |
CALL_ASSET |
Thêm thành phần cuộc gọi vào cấp chiến dịch hoặc cấp khách hàng |
SHOPPING_ADD_AGE_GROUP |
Thêm thuộc tính nhóm tuổi vào những mặt hàng bị hạ cấp do thiếu nhóm tuổi |
SHOPPING_ADD_COLOR |
Thêm màu sắc vào những mặt hàng bị hạ cấp do thiếu màu sắc |
SHOPPING_ADD_GENDER |
Thêm giới tính vào những sản phẩm bị giảm hạng do thiếu giới tính |
SHOPPING_ADD_GTIN |
Thêm GTIN (Mã số sản phẩm thương mại toàn cầu) vào những mặt hàng bị hạ cấp do thiếu GTIN |
SHOPPING_ADD_MORE_IDENTIFIERS |
Thêm giá trị nhận dạng khác cho những mặt hàng bị giảm hạng do thiếu giá trị nhận dạng |
SHOPPING_ADD_SIZE |
Thêm kích thước vào những sản phẩm bị giảm hạng do thiếu kích thước |
SHOPPING_ADD_PRODUCTS_TO_CAMPAIGN |
Thêm sản phẩm để chiến dịch phân phát |
SHOPPING_FIX_DISAPPROVED_PRODUCTS |
Khắc phục sản phẩm bị từ chối |
SHOPPING_TARGET_ALL_OFFERS |
Tạo một chiến dịch toàn diện nhắm đến tất cả sản phẩm |
SHOPPING_FIX_SUSPENDED_MERCHANT_CENTER_ACCOUNT |
Khắc phục các vấn đề về tình trạng tạm ngưng tài khoản Merchant Center |
SHOPPING_FIX_MERCHANT_CENTER_ACCOUNT_SUSPENSION_WARNING
|
Khắc phục các vấn đề về cảnh báo tạm ngưng tài khoản Merchant Center |
DYNAMIC_IMAGE_EXTENSION_OPT_IN |
Bật phần mở rộng về hình ảnh linh hoạt trên tài khoản |
RAISE_TARGET_CPA |
Tăng CPA mục tiêu |
LOWER_TARGET_ROAS |
ROAS mục tiêu thấp hơn |
FORECASTING_SET_TARGET_CPA |
Đặt CPA mục tiêu cho những chiến dịch chưa có CPA mục tiêu, trước khi diễn ra một sự kiện theo mùa được dự báo là sẽ làm tăng lưu lượng truy cập |
SET_TARGET_CPA |
Đặt CPA mục tiêu cho những chiến dịch chưa được chỉ định CPA mục tiêu |
SET_TARGET_ROAS |
Đặt ROAS mục tiêu cho những chiến dịch chưa được chỉ định mục tiêu này |
REFRESH_CUSTOMER_MATCH_LIST |
Cập nhật danh sách khách hàng chưa được cập nhật trong 90 ngày qua |
IMPROVE_GOOGLE_TAG_COVERAGE |
Triển khai thẻ Google trên nhiều trang hơn |
CAMPAIGN_SPECIFIC_APP_GOAL |
Thêm mục tiêu lượt chuyển đổi đối với ứng dụng theo chiến dịch cụ thể |
RAISE_TARGET_CPA_PERFORMANCE_BID_TOO_LOW |
Tăng CPA mục tiêu khi CPA mục tiêu quá thấp đối với chiến dịch Tìm kiếm |
LOWER_TARGET_ROAS_PERFORMANCE_BID_TOO_LOW |
Giảm ROAS mục tiêu khi mức này quá thấp đối với chiến dịch Tìm kiếm |
RAISE_BUDGET_PERFORMANCE_TOO_LOW |
Tăng ngân sách khi ngân sách quá thấp đối với chiến dịch Tìm kiếm. Có sẵn từ v26. Thông tin chi tiết về đề xuất được trả về trong Recommendation.raise_budget_performance_too_low_recommendation và được áp dụng bằng ApplyRecommendationOperation.raise_budget_performance_too_low. |
KEYWORD_MATCH_TYPE (không dùng nữa) |
Không dùng nữa, hãy sử dụng USE_BROAD_MATCH_KEYWORD |
Truy xuất đề xuất
Giống như hầu hết các thực thể khác trong Google Ads API, các đối tượng Recommendation được tìm nạp bằng cách sử dụng GoogleAdsService.SearchStream với một truy vấn Ngôn ngữ truy vấn Google Ads.
Đối với mỗi loại đề xuất, thông tin chi tiết sẽ được cung cấp trong một trường dành riêng cho đề xuất. Ví dụ: thông tin chi tiết về đề xuất CAMPAIGN_BUDGET nằm trong trường campaign_budget_recommendation và được gói trong đối tượng CampaignBudgetRecommendation.
Tìm tất cả các trường dành riêng cho đề xuất trong trường hợp kết hợp recommendation.
Mức tác động của đề xuất
Một số loại đề xuất sẽ điền sẵn trường impact của đề xuất.
RecommendationImpact
chứa thông tin ước tính về mức tác động đến hiệu suất của tài khoản do việc áp dụng đề xuất mang lại. Các chỉ số đề xuất sau đây có trong các trường impact.base_metrics và impact.potential_metrics:
impressionsclickscost_microsconversionsall_conversionsvideo_views
Ngay cả khi trường impact được điền sẵn, khả năng cung cấp chỉ số sẽ khác nhau tuỳ thuộc vào loại đề xuất và loại chiến dịch, cùng với các yếu tố khác. Nhìn chung, hãy kiểm tra xem có từng chỉ số tác động hay không trước khi cố gắng sử dụng chỉ số đó.
Ví dụ về mã
Đoạn mã mẫu sau đây truy xuất tất cả các đề xuất hiện có và bị loại bỏ thuộc loại KEYWORD từ một tài khoản, đồng thời in một số thông tin chi tiết về các đề xuất đó:
Java
try (GoogleAdsServiceClient googleAdsServiceClient = googleAdsClient.getLatestVersion().createGoogleAdsServiceClient(); RecommendationServiceClient recommendationServiceClient = googleAdsClient.getLatestVersion().createRecommendationServiceClient()) { // Creates a query that retrieves keyword recommendations. String query = "SELECT recommendation.resource_name, " + " recommendation.campaign, " + " recommendation.keyword_recommendation " + "FROM recommendation " + "WHERE recommendation.type = KEYWORD"; // Constructs the SearchGoogleAdsStreamRequest. SearchGoogleAdsStreamRequest request = SearchGoogleAdsStreamRequest.newBuilder() .setCustomerId(Long.toString(customerId)) .setQuery(query) .build(); // Issues the search stream request to detect keyword recommendations that exist for the // customer account. ServerStream<SearchGoogleAdsStreamResponse> stream = googleAdsServiceClient.searchStreamCallable().call(request); // Creates apply operations for all the recommendations found. List<ApplyRecommendationOperation> applyRecommendationOperations = new ArrayList<>(); for (SearchGoogleAdsStreamResponse response : stream) { for (GoogleAdsRow googleAdsRow : response.getResultsList()) { Recommendation recommendation = googleAdsRow.getRecommendation(); System.out.printf( "Keyword recommendation '%s' was found for campaign '%s'%n", recommendation.getResourceName(), recommendation.getCampaign()); KeywordInfo keyword = recommendation.getKeywordRecommendation().getKeyword(); System.out.printf("\tKeyword = '%s'%n", keyword.getText()); System.out.printf("\tMatch type = '%s'%n", keyword.getMatchType()); // Creates an ApplyRecommendationOperation that will apply this recommendation, and adds // it to the list of operations. applyRecommendationOperations.add(buildRecommendationOperation(recommendation)); } }
C#
// Get the GoogleAdsServiceClient. GoogleAdsServiceClient googleAdsService = client.GetService( Services.V26.GoogleAdsService); // Creates a query that retrieves keyword recommendations. string query = "SELECT recommendation.resource_name, " + "recommendation.campaign, recommendation.keyword_recommendation " + "FROM recommendation WHERE " + $"recommendation.type = KEYWORD"; List<ApplyRecommendationOperation> operations = new List<ApplyRecommendationOperation>(); try { // Issue a search request. googleAdsService.SearchStream(customerId.ToString(), query, delegate (SearchGoogleAdsStreamResponse resp) { Console.WriteLine($"Found {resp.Results.Count} recommendations."); foreach (GoogleAdsRow googleAdsRow in resp.Results) { Recommendation recommendation = googleAdsRow.Recommendation; Console.WriteLine("Keyword recommendation " + $"{recommendation.ResourceName} was found for campaign " + $"{recommendation.Campaign}."); if (recommendation.KeywordRecommendation != null) { KeywordInfo keyword = recommendation.KeywordRecommendation.Keyword; Console.WriteLine($"Keyword = {keyword.Text}, type = " + "{keyword.MatchType}"); } operations.Add( BuildApplyRecommendationOperation(recommendation.ResourceName) ); } } ); } catch (GoogleAdsException e) { Console.WriteLine("Failure:"); Console.WriteLine($"Message: {e.Message}"); Console.WriteLine($"Failure: {e.Failure}"); Console.WriteLine($"Request ID: {e.RequestId}"); throw; }
PHP
$googleAdsServiceClient = $googleAdsClient->getGoogleAdsServiceClient(); // Creates a query that retrieves keyword recommendations. $query = 'SELECT recommendation.resource_name, recommendation.campaign, ' . 'recommendation.keyword_recommendation ' . 'FROM recommendation ' . 'WHERE recommendation.type = KEYWORD '; // Issues a search request to detect keyword recommendations that exist for the // customer account. $response = $googleAdsServiceClient->search(SearchGoogleAdsRequest::build($customerId, $query)); $operations = []; // Iterates over all rows in all pages and prints the requested field values for // the recommendation in each row. foreach ($response->iterateAllElements() as $googleAdsRow) { /** @var GoogleAdsRow $googleAdsRow */ $recommendation = $googleAdsRow->getRecommendation(); printf( "Keyword recommendation with resource name '%s' was found for campaign " . "with resource name '%s':%s", $recommendation->getResourceName(), $recommendation->getCampaign(), PHP_EOL ); if (!is_null($recommendation->getKeywordRecommendation())) { $keyword = $recommendation->getKeywordRecommendation()->getKeyword(); printf( "\tKeyword = '%s'%s\ttype = '%s'%s", $keyword->getText(), PHP_EOL, KeywordMatchType::name($keyword->getMatchType()), PHP_EOL ); } // Creates an ApplyRecommendationOperation that will be used to apply this // recommendation, and adds it to the list of operations. $operations[] = self::buildRecommendationOperation($recommendation->getResourceName()); }
Python
googleads_service = client.get_service("GoogleAdsService") query: str = """ SELECT recommendation.campaign, recommendation.keyword_recommendation FROM recommendation WHERE recommendation.type = KEYWORD""" # Detects keyword recommendations that exist for the customer account. response: Iterable[GoogleAdsRow] = googleads_service.search( customer_id=customer_id, query=query ) operations: List[ApplyRecommendationOperation] = [] for row in response: recommendation = row.recommendation print( f"Keyword recommendation ('{recommendation.resource_name}') " f"was found for campaign '{recommendation.campaign}." ) keyword = recommendation.keyword_recommendation.keyword print( f"\tKeyword = '{keyword.text}'\n" f"\tType = '{keyword.match_type}'" ) # Create an ApplyRecommendationOperation that will be used to apply # this recommendation, and add it to the list of operations. operations.append( build_recommendation_operation(client, recommendation.resource_name) )
Ruby
query = <<~QUERY SELECT recommendation.resource_name, recommendation.campaign, recommendation.keyword_recommendation FROM recommendation WHERE recommendation.type = KEYWORD QUERY google_ads_service = client.service.google_ads response = google_ads_service.search( customer_id: customer_id, query: query, ) operations = response.each do |row| recommendation = row.recommendation puts "Keyword recommendation ('#{recommendation.resource_name}') was found for "\ "campaign '#{recommendation.campaign}'." if recommendation.keyword_recommendation keyword = recommendation.keyword_recommendation.keyword puts "\tKeyword = '#{keyword.text}'" puts "\ttype = '#{keyword.match_type}'" end build_recommendation_operation(client, recommendation.resource_name) end
Perl
# Create the search query. my $search_query = "SELECT recommendation.resource_name, " . "recommendation.campaign, recommendation.keyword_recommendation " . "FROM recommendation " . "WHERE recommendation.type = KEYWORD"; # Get the GoogleAdsService. my $google_ads_service = $api_client->GoogleAdsService(); my $search_stream_handler = Google::Ads::GoogleAds::Utils::SearchStreamHandler->new({ service => $google_ads_service, request => { customerId => $customer_id, query => $search_query }}); # Create apply operations for all the recommendations found. my $apply_recommendation_operations = (); $search_stream_handler->process_contents( sub { my $google_ads_row = shift; my $recommendation = $google_ads_row->{recommendation}; printf "Keyword recommendation '%s' was found for campaign '%s'.\n", $recommendation->{resourceName}, $recommendation->{campaign}; my $keyword = $recommendation->{keywordRecommendation}{keyword}; printf "\tKeyword = '%s'\n", $keyword->{text}; printf "\tMatch type = '%s'\n", $keyword->{matchType}; # Creates an ApplyRecommendationOperation that will apply this recommendation, and adds # it to the list of operations. push @$apply_recommendation_operations, build_recommendation_operation($recommendation); });
curl
# Gets keyword recommendations. # # Variables: # API_VERSION, # CUSTOMER_ID, # MANAGER_CUSTOMER_ID, # OAUTH2_ACCESS_TOKEN: # See https://developers.google.com/google-ads/api/rest/auth#request_headers # for details. curl -f --request POST \ "https://googleads.googleapis.com/v${API_VERSION}/customers/${CUSTOMER_ID}/googleAds:search" \ --header "Content-Type: application/json" \ --header "login-customer-id: ${MANAGER_CUSTOMER_ID}" \ --header "Authorization: Bearer ${OAUTH2_ACCESS_TOKEN}" \ --data @- <<EOF { "query": " SELECT recommendation.campaign, recommendation.keyword_recommendation FROM recommendation WHERE recommendation.type = KEYWORD " } EOF
Chọn cách giải quyết
Bạn có thể áp dụng hoặc loại bỏ mọi đề xuất đã truy xuất.
Tuỳ thuộc vào loại đề xuất, các đề xuất có thể thay đổi hằng ngày hoặc thậm chí nhiều lần trong ngày. Khi điều đó xảy ra, resource_name của đối tượng đề xuất có thể trở nên lỗi thời sau khi đề xuất được truy xuất.
Bạn nên thực hiện hành động theo đề xuất ngay sau khi truy xuất.
Áp dụng các đề xuất
Bạn có thể áp dụng các đề xuất đang hoạt động hoặc đã bị loại bỏ bằng phương thức ApplyRecommendation của RecommendationService.
Các loại đề xuất có thể có tham số bắt buộc hoặc không bắt buộc. Hầu hết các đề xuất đều có giá trị được đề xuất và được dùng theo mặc định.
Chúng tôi không hỗ trợ việc thiết lập tài khoản để tự động áp dụng các đề xuất cho tất cả các loại đề xuất. Tuy nhiên, bạn có thể triển khai hành vi tương tự cho các loại đề xuất được Google Ads API hỗ trợ đầy đủ.
Hãy tham khảo DetectAndApplyRecommendations ví dụ về mã để tìm hiểu thêm.
Sử dụng trường hợp nhất apply_parameters của ApplyRecommendationOperation để áp dụng các đề xuất có giá trị tham số cụ thể. Mỗi loại đề xuất phù hợp đều có trường riêng. Mọi loại đề xuất không có trong trường apply_parameters đều không sử dụng các giá trị tham số này.
Ví dụ về mã
Đoạn mã sau đây minh hoạ cách tạo
ApplyRecommendationOperation và
cách ghi đè các giá trị được đề xuất nếu bạn muốn thay thế các giá trị đó bằng giá trị của riêng bạn.
Java
/** Creates and returns an ApplyRecommendationOperation to apply the given recommendation. */ private ApplyRecommendationOperation buildRecommendationOperation(Recommendation recommendation) { // If you have a recommendation ID instead of a resource name, you can create a resource name // like this: // String resourceName = ResourceNames.recommendation(customerId, recommendationId); // Creates a builder to construct the operation. Builder operationBuilder = ApplyRecommendationOperation.newBuilder(); // Each recommendation type has optional parameters to override the recommended values. Below is // an example showing how to override a recommended ad when a TextAdRecommendation is applied. // operationBuilder.getTextAdBuilder().getAdBuilder().setResourceName("INSERT_AD_RESOURCE_NAME"); // Sets the operation's resource name to the resource name of the recommendation to apply. operationBuilder.setResourceName(recommendation.getResourceName()); return operationBuilder.build(); }
C#
private ApplyRecommendationOperation BuildApplyRecommendationOperation( string recommendationResourceName ) { // If you have a recommendation_id instead of the resource_name you can create a // resource name from it like this: // string recommendationResourceName = // ResourceNames.Recommendation(customerId, recommendationId) // Each recommendation type has optional parameters to override the recommended values. // This is an example to override a recommended ad when a TextAdRecommendation is // applied. // For details, please read // https://developers.google.com/google-ads/api/reference/rpc/latest/ApplyRecommendationOperation. /* Ad overridingAd = new Ad() { Id = "INSERT_AD_ID_AS_LONG_HERE" }; applyRecommendationOperation.TextAd = new TextAdParameters() { Ad = overridingAd }; */ ApplyRecommendationOperation applyRecommendationOperation = new ApplyRecommendationOperation() { ResourceName = recommendationResourceName }; return applyRecommendationOperation; }
PHP
private static function buildRecommendationOperation( string $recommendationResourceName ): ApplyRecommendationOperation { // If you have a recommendation_id instead of the resource name, you can create a resource // name from it like this: /* $recommendationResourceName = ResourceNames::forRecommendation($customerId, $recommendationId); */ // Each recommendation type has optional parameters to override the recommended values. // This is an example to override a recommended ad when a TextAdRecommendation is applied. // For details, please read // https://developers.google.com/google-ads/api/reference/rpc/latest/ApplyRecommendationOperation. /* $overridingAd = new Ad([ 'id' => 'INSERT_AD_ID_AS_INTEGER_HERE' ]); $applyRecommendationOperation->setTextAd(new TextAdParameters(['ad' => $overridingAd])); */ // Issues a mutate request to apply the recommendation. $applyRecommendationOperation = new ApplyRecommendationOperation(); $applyRecommendationOperation->setResourceName($recommendationResourceName); return $applyRecommendationOperation; }
Python
def build_recommendation_operation( client: GoogleAdsClient, recommendation: str ) -> ApplyRecommendationOperation: """Creates a ApplyRecommendationOperation to apply the given recommendation. Args: client: an initialized GoogleAdsClient instance. recommendation: a resource name for the recommendation to be applied. """ # If you have a recommendation ID instead of a resource name, you can create # a resource name like this: # # googleads_service = client.get_service("GoogleAdsService") # resource_name = googleads_service.recommendation_path( # customer_id, recommendation.id # ) operation: ApplyRecommendationOperation = client.get_type( "ApplyRecommendationOperation" ) # Each recommendation type has optional parameters to override the # recommended values. Below is an example showing how to override a # recommended ad when a TextAdRecommendation is applied. # # operation.text_ad.ad.resource_name = "INSERT_AD_RESOURCE_NAME" # # For more details, see: # https://developers.google.com/google-ads/api/reference/rpc/latest/ApplyRecommendationOperation#apply_parameters operation.resource_name = recommendation return operation
Ruby
def build_recommendation_operation(client, recommendation) # If you have a recommendation_id instead of the resource_name # you can create a resource name from it like this: # recommendation_resource = # client.path.recommendation(customer_id, recommendation_id) operations = client.operation.apply_recommendation operations.resource_name = recommendation_resource # Each recommendation type has optional parameters to override the recommended # values. This is an example to override a recommended ad when a # TextAdRecommendation is applied. # # text_ad_parameters = client.resource.text_ad_parameters do |tap| # tap.ad = client.resource.ad do |ad| # ad.id = "INSERT_AD_ID_AS_INTEGER_HERE" # end # end # operation.text_ad = text_ad_parameters # # For more details, see: # https://developers.google.com/google-ads/api/reference/rpc/latest/ApplyRecommendationOperation#apply_parameters return operation end
Perl
sub build_recommendation_operation { my ($recommendation) = @_; # If you have a recommendation ID instead of a resource name, you can create a resource # name like this: # my $recommendation_resource_name = # Google::Ads::GoogleAds::V26::Utils::ResourceNames::recommendation( # $customer_id, $recommendation_id); # Each recommendation type has optional parameters to override the recommended values. # Below is an example showing how to override a recommended ad when a TextAdRecommendation # is applied. # my $overriding_ad = Google::Ads::GoogleAds::V26::Resources::Ad->new({ # id => "INSERT_AD_ID_AS_INTEGER_HERE" # }); # my $text_ad_parameters = # Google::Ads::GoogleAds::V26::Services::RecommendationService::TextAdParameters # ->new({ad => $overriding_ad}); # $apply_recommendation_operation->{textAd} = $text_ad_parameters; # Create an apply recommendation operation. my $apply_recommendation_operation = Google::Ads::GoogleAds::V26::Services::RecommendationService::ApplyRecommendationOperation ->new({ resourceName => $recommendation->{resourceName}}); return $apply_recommendation_operation; }
curl
Ví dụ tiếp theo gọi ApplyRecommendation, gửi các thao tác áp dụng đề xuất đã được tạo trong đoạn mã trước đó.
Java
// Issues a mutate request to apply the recommendations. ApplyRecommendationResponse applyRecommendationsResponse = recommendationServiceClient.applyRecommendation( Long.toString(customerId), applyRecommendationOperations); for (ApplyRecommendationResult applyRecommendationResult : applyRecommendationsResponse.getResultsList()) { System.out.printf( "Applied recommendation with resource name: '%s'.%n", applyRecommendationResult.getResourceName()); }
C#
private void ApplyRecommendation(GoogleAdsClient client, long customerId, List<ApplyRecommendationOperation> operations) { // Get the RecommendationServiceClient. RecommendationServiceClient recommendationService = client.GetService( Services.V26.RecommendationService); ApplyRecommendationRequest applyRecommendationRequest = new ApplyRecommendationRequest() { CustomerId = customerId.ToString(), }; applyRecommendationRequest.Operations.AddRange(operations); ApplyRecommendationResponse response = recommendationService.ApplyRecommendation(applyRecommendationRequest); foreach (ApplyRecommendationResult result in response.Results) { Console.WriteLine("Applied a recommendation with resource name: " + result.ResourceName); } }
PHP
private static function applyRecommendations( GoogleAdsClient $googleAdsClient, int $customerId, array $operations ): void { // Issues a mutate request to apply the recommendations. $recommendationServiceClient = $googleAdsClient->getRecommendationServiceClient(); $response = $recommendationServiceClient->applyRecommendation( ApplyRecommendationRequest::build($customerId, $operations) ); foreach ($response->getResults() as $appliedRecommendation) { /** @var Recommendation $appliedRecommendation */ printf( "Applied a recommendation with resource name: '%s'.%s", $appliedRecommendation->getResourceName(), PHP_EOL ); } }
Python
def apply_recommendations( client: GoogleAdsClient, customer_id: str, operations: List[ApplyRecommendationOperation], ) -> None: """Applies a batch of recommendations. Args: client: an initialized GoogleAdsClient instance. customer_id: a client customer ID. operations: a list of ApplyRecommendationOperation messages. """ # Issues a mutate request to apply the recommendations. recommendation_service = client.get_service("RecommendationService") response: ApplyRecommendationResult = ( recommendation_service.apply_recommendation( customer_id=customer_id, operations=operations ) ) for result in response.results: print( "Applied a recommendation with resource name: " f"'{result.resource_name}'." )
Ruby
def apply_recommendations(client, customer_id, operations) # Issues a mutate request to apply the recommendation. recommendation_service = client.service.recommendation response = recommendation_service.apply_recommendation( customer_id: customer_id, operations: [operations], ) response.results.each do |applied_recommendation| puts "Applied recommendation with resource name: '#{applied_recommendation.resource_name}'." end end
Perl
# Issue a mutate request to apply the recommendations. my $apply_recommendation_response = $api_client->RecommendationService()->apply({ customerId => $customer_id, operations => $apply_recommendation_operations }); foreach my $result (@{$apply_recommendation_response->{results}}) { printf "Applied recommendation with resource name: '%s'.\n", $result->{resourceName}; }
curl
# Applies a recommendation. # # Variables: # API_VERSION, # CUSTOMER_ID, # DEVELOPER_TOKEN, # MANAGER_CUSTOMER_ID, # OAUTH2_ACCESS_TOKEN: # See https://developers.google.com/google-ads/api/rest/auth#request_headers # for details. # # RECOMMENDATION_RESOURCE_NAME: The resource name of the recommendation to # apply, from the previous request. curl -f --request POST \ "https://googleads.googleapis.com/v${API_VERSION}/customers/${CUSTOMER_ID}/recommendations:apply" \ --header "Content-Type: application/json" \ --header "developer-token: ${DEVELOPER_TOKEN}" \ --header "login-customer-id: ${MANAGER_CUSTOMER_ID}" \ --header "Authorization: Bearer ${OAUTH2_ACCESS_TOKEN}" \ --data @- <<EOF { "operations": [ { "resourceName": "${RECOMMENDATION_RESOURCE_NAME}" } ] } EOF
Loại bỏ đề xuất
Bạn có thể loại bỏ các đề xuất bằng biểu tượng
RecommendationService. Cấu trúc mã tương tự như áp dụng đề xuất, nhưng thay vào đó, bạn sử dụng DismissRecommendationOperation và RecommendationService.DismissRecommendation.
Thao tác hàng loạt và xử lý lỗi
Cả ApplyRecommendation và DismissRecommendation đều chấp nhận tối đa 100 thao tác cho mỗi yêu cầu. Khi gửi nhiều thao tác trong một yêu cầu, hãy lưu ý những hành vi sau:
- Kết hợp các loại đề xuất: Theo mặc định (
partial_failure = false), tất cả các thao tác trong một yêu cầu duy nhất phải nhắm đến cùng một loại đề xuất; nếu không, API sẽ trả vềRecommendationError.DIFFERENT_TYPES_NOT_SUPPORTED. Để áp dụng hoặc loại bỏ các đề xuất thuộc nhiều loại trong cùng một yêu cầu, hãy đặtpartial_failurethànhtruetrong yêu cầu để các thao tác hợp lệ thành công một cách độc lập. - Lỗi vòng đời: Vì các đề xuất được đánh giá linh động, nên trạng thái của đề xuất có thể thay đổi giữa thời điểm truy xuất và thời điểm hành động. Nếu một đề xuất đã được áp dụng, đã bị loại bỏ hoặc không còn áp dụng được nữa, thì API sẽ trả về
RECOMMENDATION_ALREADY_APPLIED,RECOMMENDATION_ALREADY_DISMISSEDhoặcRECOMMENDATION_INVALIDATEDtrongRecommendationError.
Tự động áp dụng nội dung đề xuất
Bạn có thể sử dụng biểu tượng RecommendationSubscriptionService để tự động áp dụng các đề xuất thuộc một loại cụ thể.
Để đăng ký một loại đề xuất cụ thể, hãy tạo một đối tượng RecommendationSubscription, đặt trường type thành một trong các loại đề xuất được hỗ trợ và đặt trường status thành ENABLED.
Các loại đề xuất được hỗ trợ trong gói thuê bao
ENHANCED_CPC_OPT_INKEYWORDKEYWORD_MATCH_TYPELOWER_TARGET_ROASMAXIMIZE_CLICKS_OPT_INOPTIMIZE_AD_ROTATIONRAISE_TARGET_CPARESPONSIVE_SEARCH_ADRESPONSIVE_SEARCH_AD_IMPROVE_AD_STRENGTHSEARCH_PARTNERS_OPT_INSET_TARGET_CPASET_TARGET_ROASTARGET_CPA_OPT_INTARGET_ROAS_OPT_INUSE_BROAD_MATCH_KEYWORD
Truy xuất gói thuê bao
Để biết thông tin về các gói thuê bao đề xuất của một tài khoản, hãy truy vấn tài nguyên recommendation_subscription.
Để xem những thay đổi đã được tự động áp dụng, hãy truy vấn tài nguyên change_event, lọc change_event.client_type thành GOOGLE_ADS_RECOMMENDATIONS_SUBSCRIPTION.
Đề xuất trong quá trình tạo chiến dịch
Bạn có thể sử dụng
RecommendationService.GenerateRecommendationsRequest để
tạo đề xuất trong quá trình tạo chiến dịch, cho một nhóm
loại đề xuất nhất định.
GenerateRecommendations chấp nhận dữ liệu đầu vào là mã khách hàng, loại kênh quảng cáo (phải là SEARCH hoặc PERFORMANCE_MAX), danh sách các loại đề xuất cần tạo và nhiều điểm dữ liệu phụ thuộc vào các loại đã chỉ định. Hàm này sẽ xuất ra danh sách các đối tượng Recommendation dựa trên dữ liệu bạn cung cấp. Nếu không có đủ dữ liệu để tạo đề xuất cho recommendation_types được yêu cầu hoặc nếu chiến dịch đã ở trạng thái được đề xuất, thì tập kết quả sẽ không chứa đề xuất cho loại đó.
Đảm bảo ứng dụng của bạn xử lý trường hợp không có đề xuất nào được trả về cho các loại đề xuất được yêu cầu.
Bảng sau đây mô tả các loại đề xuất mà GenerateRecommendations hỗ trợ, cũng như các trường bạn phải cung cấp để nhận đề xuất cho loại đó. Tốt nhất là bạn nên gửi yêu cầu GenerateRecommendations sau khi thu thập tất cả thông tin liên quan đến các loại đề xuất được yêu cầu. Để biết thêm thông tin chi tiết về các trường bắt buộc và không bắt buộc, kể cả các trường lồng ghép, hãy tham khảo tài liệu tham khảo.
| RecommendationType | Các trường bắt buộc | Trường tuỳ chọn |
|---|---|---|
CAMPAIGN_BUDGET |
Đối với cả chiến dịch Tìm kiếm và chiến dịch Tối đa hoá hiệu suất, bạn phải cung cấp các trường sau:
|
|
KEYWORD |
|
|
MAXIMIZE_CLICKS_OPT_IN |
|
|
MAXIMIZE_CONVERSIONS_OPT_IN |
|
|
MAXIMIZE_CONVERSION_VALUE_OPT_IN |
|
|
SET_TARGET_CPA |
|
|
SET_TARGET_ROAS |
|
|
SITELINK_ASSET
Lưu ý: Đối tượng SitelinkAssetRecommendation
được trả về sẽ chứa danh sách trống. Nếu phản hồi của GenerateRecommendations chứa SitelinkAssetRecommendation, thì bạn có thể coi đó là tín hiệu để thêm ít nhất một thành phần đường liên kết của trang web vào chiến dịch. |
|
|
TARGET_CPA_OPT_IN |
|
|
TARGET_ROAS_OPT_IN |
|
Ví dụ về luồng sử dụng
Giả sử công ty của bạn là một công ty quảng cáo cung cấp quy trình xây dựng chiến dịch cho người dùng và bạn muốn đưa ra đề xuất cho người dùng trong quy trình đó. Bạn có thể sử dụng GenerateRecommendationsRequest để tạo đề xuất theo yêu cầu và kết hợp những đề xuất đó vào giao diện người dùng tạo chiến dịch.
Quy trình sử dụng có thể như sau:
Người dùng truy cập vào ứng dụng của bạn để tạo chiến dịch Tối đa hoá hiệu suất.
Người dùng cung cấp một số thông tin ban đầu trong quy trình thiết lập chiến dịch. Ví dụ: họ cung cấp thông tin chi tiết để tạo một
SitelinkAssetvà chọnTARGET_SPENDlàm chiến lược Đặt giá thầu thông minh.Bạn gửi một
GenerateRecommendationsRequestđể đặt các trường sau:campaign_sitelink_count: được đặt thành1, tức là số lượng thành phần đường liên kết của trang web trong chiến dịch đang tiến hành.bidding_info: đặt trườngbidding_strategy_typelồng nhau thànhTARGET_SPEND.conversion_tracking_status: đặt thànhConversionTrackingStatuscủa khách hàng này. Để biết hướng dẫn về cách truy xuất trường này, hãy truy cập vào hướng dẫn Bắt đầu để quản lý lượt chuyển đổi.recommendation_types: đặt thành[SITELINK_ASSET, MAXIMIZE_CLICKS_OPT_IN].advertising_channel_type: đặt thànhPERFORMANCE_MAX.customer_id: được đặt thành mã nhận dạng của khách hàng tạo chiến dịch.
Bạn có thể lấy các đề xuất trong
GenerateRecommendationsResponse(trong trường hợp này làSitelinkAssetRecommendationvàMaximizeClicksOptInRecommendation) rồi đề xuất cho người dùng bằng cách hiển thị các đề xuất đó trong giao diện tạo chiến dịch. Nếu người dùng chấp nhận một đề xuất, thì bạn có thể kết hợp đề xuất đó vào yêu cầu tạo chiến dịch sau khi người dùng hoàn tất quy trình thiết lập chiến dịch.