Google ads là công cụ mạnh mẽ giúp doanh nghiệp tiếp cận khách hàng mục tiêu. Tuy nhiên, việc sử dụng từ khóa có thể dẫn đến vi phạm chính sách, khiến quảng cáo không được phê duyệt. Trong bài viết này, chúng tôi sẽ hướng dẫn bạn cách xử lý từ khóa vi phạm chính sách trong google ads, bao gồm việc yêu cầu miễn trừ và khắc phục lỗi. Đây là giải pháp cần thiết để tối ưu hóa chiến dịch quảng cáo của bạn và đạt được hiệu quả cao nhất.
Các bước để yêu cầu miễn trừ từ khóa trong Google Ads được thực hiện như sau:
- Lưu trữ tất cả các từ khóa vi phạm chính sách có thể được miễn trừ:
- Các chi tiết vi phạm chính sách sẽ được cung cấp thông qua trường
PolicyViolationDetails
khi bạn gặp lỗi trong lần đầu tạo từ khóa không thành công. - Hãy lưu lại các từ khóa và thông tin liên quan được đánh dấu là miễn trừ để sử dụng trong các bước tiếp theo.
- Các chi tiết vi phạm chính sách sẽ được cung cấp thông qua trường
- Gửi yêu cầu thay đổi và tạo lại từ khóa:
- Khi gửi yêu cầu, bạn cần đính kèm danh sách các từ khóa vi phạm chính sách có thể được miễn trừ (nếu có).
- Hãy đảm bảo tuân thủ các yêu cầu của Google Ads trong quá trình này.
Lưu ý quan trọng: Nếu từ khóa của bạn chứa lỗi vi phạm chính sách không thể miễn trừ, bạn sẽ không thể thực hiện các bước trên để yêu cầu miễn trừ. Trong trường hợp này, hãy sửa đổi nội dung từ khóa để đảm bảo phù hợp với chính sách của Google Ads.
Lưu trữ toàn bộ các khóa vi phạm chính sách được miễn trừ
Thông tin chi tiết về các lỗi liên quan đến từ khóa sẽ được lưu trong PolicyViolationDetails. Từ đó, trường key chứa giá trị là một đối tượng PolicyViolationKey sẽ được lưu trữ.
Thu thập tất cả các khóa vi phạm chính sách được miễn trừ để phục vụ cho các bước xử lý tiếp theo.
private List<PolicyViolationKey> extractExemptiblePolicyViolationKeys(
GoogleAdsException googleAdsException) {
List<PolicyViolationKey> exemptibleKeys = new ArrayList<>();
System.out.println("Chi tiết lỗi trong Google Ads:");
for (GoogleAdsError googleAdsError : googleAdsException.getGoogleAdsFailure().getErrorsList()) {
System.out.printf("\t%s: %s%n", googleAdsError.getErrorCode(), googleAdsError.getMessage());
if (googleAdsError.hasDetails() && googleAdsError.getDetails().hasPolicyViolationDetails()) {
PolicyViolationDetails policyViolationDetails =
googleAdsError.getDetails().getPolicyViolationDetails();
System.out.println("\tChi tiết vi phạm chính sách:");
System.out.printf(
"\t\tTên chính sách bên ngoài: '%s'%n", policyViolationDetails.getExternalPolicyName());
System.out.printf(
"\t\tMô tả chính sách bên ngoài: '%s'%n",
policyViolationDetails.getExternalPolicyDescription());
System.out.printf("\t\tCó thể được miễn trừ? '%s'%n", policyViolationDetails.getIsExemptible());
if (policyViolationDetails.getIsExemptible() && policyViolationDetails.hasKey()) {
PolicyViolationKey policyViolationKey = policyViolationDetails.getKey();
exemptibleKeys.add(policyViolationKey);
System.out.println("\t\tKhóa vi phạm chính sách:");
System.out.printf("\t\t\tTên: '%s'%n", policyViolationKey.getPolicyName());
System.out.printf("\t\t\tNội dung vi phạm: '%s'%n", policyViolationKey.getViolatingText());
}
}
}
return exemptibleKeys;
}
Gửi yêu cầu sửa đổi với các khóa vi phạm chính sách được miễn trừ
- Đặt tất cả các khóa vi phạm chính sách được miễn trừ vào trường exempt_policy_violation_keys của toán tử tiêu chí nhóm quảng cáo.
- Gửi yêu cầu thay đổi để tạo lại từ khóa.
// Thử gửi yêu cầu miễn trừ để tạo từ khóa. Tuy nhiên, nếu từ khóa chứa nhiều vi phạm chính sách mà không thể miễn trừ tất cả, yêu cầu sẽ không được gửi.
if (exemptibleKeys.size() == errorCount) {
System.out.println(
"Đang cố gắng thêm từ khóa bằng cách yêu cầu miễn trừ các lỗi vi phạm chính sách.");
// Tạo phiên bản sửa đổi của thao tác với các khóa vi phạm chính sách được miễn trừ.
operation = operation.toBuilder().addAllExemptPolicyViolationKeys(exemptibleKeys).build();
// Thử gửi lại yêu cầu thay đổi.MutateAdGroupCriteriaResponse response =
adGroupCriterionServiceClient.mutateAdGroupCriteria(
String.valueOf(customerId), ImmutableList.of(operation));
System.out.printf(
“Đã thêm thành công từ khóa với tên tài nguyên ‘%s’ bằng cách yêu cầu miễn trừ vi phạm chính sách.%n”,
response.getResults(0).getResourceName());
} else {
System.out.println(“Không thể miễn trừ toàn bộ lỗi vi phạm chính sách cho từ khóa.”);
}
Ví dụ về mã
Ví dụ về mã hoàn chỉnh để xử lý các vi phạm chính sách về từ khóa:
// Copyright 2020 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// https://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package com.google.ads.googleads.examples.errorhandling;
import com.google.ads.googleads.lib.GoogleAdsClient;import com.google.ads.googleads.v17.common.KeywordInfo;
import com.google.ads.googleads.v17.common.PolicyViolationKey;
import com.google.ads.googleads.v17.enums.AdGroupCriterionStatusEnum.AdGroupCriterionStatus;
import com.google.ads.googleads.v17.enums.KeywordMatchTypeEnum.KeywordMatchType;
import com.google.ads.googleads.v17.errors.GoogleAdsError;
import com.google.ads.googleads.v17.errors.GoogleAdsException;
import com.google.ads.googleads.v17.errors.PolicyViolationDetails;
import com.google.ads.googleads.v17.resources.AdGroupCriterion;
import com.google.ads.googleads.v17.services.AdGroupCriterionOperation;
import com.google.ads.googleads.v17.services.AdGroupCriterionServiceClient;
import com.google.ads.googleads.v17.services.MutateAdGroupCriteriaResponse;
import com.google.ads.googleads.v17.utils.ResourceNames;
import com.google.common.collect.ImmutableList;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
public class HandleKeywordPolicyViolations {
public static void main(String[] args) throws IOException {
GoogleAdsClient googleAdsClient = GoogleAdsClient.newBuilder().fromPropertiesFile().build();
long customerId = Long.parseLong(“INSERT_CUSTOMER_ID_HERE”);
long adGroupId = Long.parseLong(“INSERT_AD_GROUP_ID_HERE”);
String keywordText = “medication”;
new HandleKeywordPolicyViolations()
.runExample(googleAdsClient, customerId, adGroupId, keywordText);
}
private void runExample(GoogleAdsClient googleAdsClient, long customerId, long adGroupId, String keywordText) {
try (AdGroupCriterionServiceClient adGroupCriterionServiceClient =
googleAdsClient.getLatestVersion().createAdGroupCriterionServiceClient()) {
KeywordInfo keywordInfo = KeywordInfo.newBuilder()
.setText(keywordText)
.setMatchType(KeywordMatchType.EXACT)
.build();
AdGroupCriterion adGroupCriterion = AdGroupCriterion.newBuilder()
.setAdGroup(ResourceNames.adGroup(customerId, adGroupId))
.setStatus(AdGroupCriterionStatus.ENABLED)
.setKeyword(keywordInfo)
.build();
AdGroupCriterionOperation operation = AdGroupCriterionOperation.newBuilder()
.setCreate(adGroupCriterion)
.build();
List<PolicyViolationKey> exemptibleKeys = new ArrayList<>();
int errorCount = 0;
try {
MutateAdGroupCriteriaResponse response = adGroupCriterionServiceClient
.mutateAdGroupCriteria(String.valueOf(customerId), ImmutableList.of(operation));
System.out.printf(“Successfully added keyword with resource name ‘%s’.%n”, response.getResults(0).getResourceName());
return;
} catch (GoogleAdsException e) {
exemptibleKeys = extractExemptiblePolicyViolationKeys(e);
errorCount = e.getGoogleAdsFailure().getErrorsCount();
}
if (exemptibleKeys.size() == errorCount) {
operation = operation.toBuilder().addAllExemptPolicyViolationKeys(exemptibleKeys).build();
MutateAdGroupCriteriaResponse response = adGroupCriterionServiceClient
.mutateAdGroupCriteria(String.valueOf(customerId), ImmutableList.of(operation));
System.out.printf(“Successfully added keyword with exemptions: ‘%s’.%n”, response.getResults(0).getResourceName());
} else {
System.out.println(“Unable to add keyword due to non-exemptible violations or other errors.”);
}
}
}
private List<PolicyViolationKey> extractExemptiblePolicyViolationKeys(GoogleAdsException googleAdsException) {
List<PolicyViolationKey> exemptibleKeys = new ArrayList<>();
System.out.println(“Extracting policy violation details…”);
for (GoogleAdsError error : googleAdsException.getGoogleAdsFailure().getErrorsList()) {
if (error.hasDetails() && error.getDetails().hasPolicyViolationDetails()) {
PolicyViolationDetails details = error.getDetails().getPolicyViolationDetails();
if (details.getIsExemptible() && details.hasKey()) {
exemptibleKeys.add(details.getKey());
}
}
}
return exemptibleKeys;
}
}
Việc xử lý từ khóa vi phạm chính sách trong google ads là một phần quan trọng trong việc duy trì hiệu quả của chiến dịch quảng cáo. Bằng cách tuân thủ hướng dẫn trên, bạn không chỉ đảm bảo quảng cáo hoạt động mà còn xây dựng được sự chuyên nghiệp và uy tín cho thương hiệu. Hãy áp dụng các bước này ngay hôm nay để tối ưu hóa chiến dịch và đạt được mục tiêu kinh doanh của bạn một cách hiệu quả.