Sie können für Keywords und Anzeigen, die Richtlinienverstöße auslösen, automatisch Überprüfungsanfragen senden.
Diese Funktion kann beispielsweise in folgenden Fällen verwendet werden:
- Ihre Anzeige enthält Satzzeichen, die im Allgemeinen als unkonventionell angesehen werden, in Ihrer Branche jedoch üblich sind.
- Ein Keyword in Ihre Anzeigengruppe enthält medizinische Begriffe, doch Sie (oder Ihre Nutzer) sind der Meinung, dass die Nutzung des Begriffs die AdWords-Richtlinien einhält und eine genauere Überprüfung gerechtfertigt ist.
In solchen Fällen scheitert der erste Versuch, die Anzeige oder das Keyword zu erstellen, mit dem Fehler PolicyViolationError
.
Wenn Sie die Sammlung exemptionRequests
Ihrer Anzeigen und Keywords gefüllt haben, werden diese automatisch zur Überprüfung gesendet. Bei einem positiven Ergebnis der Überprüfung können Sie die Anzeige oder die Keywords mit der Operation ADD
erneut senden.
Wichtig: Senden Sie nach dem Hinzufügen von Ausnahmeanfragen nicht jede Anzeige oder jedes Keyword, die bzw. das den Fehler PolicyViolationError
generiert hat, noch einmal. Senden Sie nur Anzeigen oder Keywords erneut, von denen Sie meinen, dass sie unseren Werberichtlinien entsprechen und eine weitere Überprüfung gerechtfertigt ist. Wenn Ihre Anzeige oder Ihre Keywords wiederholt aufgrund von Verstößen gegen unsere Werberichtlinien abgelehnt werden, kann Ihr AdWords-Konto gesperrt werden.
Falls eine Anzeige erfolgreich ohne einen PolicyViolationError
gesendet wird, aber später aufgrund eines Verstoßes gegen die Anzeigenrichtlinie abgelehnt wird, werden weitere Details in der AdGroupAdPolicySummary
bereitgestellt.
In den folgenden Abschnitten werden die Schritte zum Senden von Ausnahmeanfragen beschrieben.
Jede fehlgeschlagene Operation auf Fehler wegen Richtlinienverstoß überprüfen
Angenommen, Sie erstellen in einem einzigen Aufruf von AdGroupAdService.mutate()
drei Anzeigen:
- Die Anzeigen A und B enthalten denselben medizinischen Begriff in ihren Anzeigentiteln.
- Anzeige B enthält auch ungewöhnliche Satzzeichen im Anzeigentitel.
- Anzeige C enthält Text, der nicht die Form eines normalen Satzes hat oder nicht den Inhalt der Zielwebsite widerspiegelt.
Wenn Sie den Dienstaufruf mit den drei AdGroupAdOperation
s senden, schlägt die Anfrage mit den folgenden Fehlern fehl:
Fehler | PolicyViolationError.fieldPath | PolicyViolationError.isExemptable | PolicyViolationKey.policyName |
---|---|---|---|
PolicyViolationError | 0 (Anzeige A) | wahr | pharma |
PolicyViolationError | 1 (Anzeige B) | wahr | pharma |
PolicyViolationError | 1 (Anzeige B) | wahr | nonstandard_punctuation |
PolicyViolationError | 2 (Anzeige C) | falsch | unclear_or_inaccurate_ad_text |
Operationen mit ausnahmefähigen Richtlinienverstößen beibehalten
Da die Fehler für die Operationen 0 und 1 ausnahmefähig sind, können Sie sie mit Ausnahmeanfragen erneut senden. Der Fehler für Operation 2 ist jedoch nicht ausnahmefähig. Es ist daher sinnlos, sie noch einmal zu senden.
Das folgende Code-Snippet iteratiert über die Fehler in der Antwort und behält den index
jeder Operation bei, die mit einem ausnahmefähigen Richtlinienverstoß gescheitert ist.
Java
for (ApiError error : e.getErrors()) { // Get the index of the failed operation from the error's field path elements. FieldPathElement[] fieldPathElements = error.getFieldPathElements(); FieldPathElement firstFieldPathElement = null; if (fieldPathElements != null && fieldPathElements.length > 0) { firstFieldPathElement = fieldPathElements[0]; } if (firstFieldPathElement == null || !"operations".equals(firstFieldPathElement.getField()) || firstFieldPathElement.getIndex() == null) { // If the operation index is not present on the first error field path element, then // there's no way to determine which operation to remove, so simply throw the exception. throw e; } int operationIndex = firstFieldPathElement.getIndex(); AdGroupAdOperation operation = operations[operationIndex]; if (handleApiError(error, operationIndex, operation)) { operationIndicesToRetry.add(operationIndex); } else { System.out.printf( "Removing operation with non-exemptable error at index %d.%n", operationIndex); } }
CSharp
ApiException innerException = e.ApiException as ApiException; if (innerException == null) { throw new Exception("Failed to retrieve ApiError. See inner exception for more " + "details.", e); } // Examine each ApiError received from the server. foreach (ApiError apiError in innerException.errors) { int index = apiError.GetOperationIndex(); if (index == -1) { // This API error is not associated with an operand, so we cannot // recover from this error by removing one or more operations. // Rethrow the exception for manual inspection. throw; } // Handle policy violation errors. if (apiError is PolicyViolationError) { PolicyViolationError policyError = (PolicyViolationError) apiError; if (policyError.isExemptable) { // If the policy violation error is exemptable, add an exemption // request. List<ExemptionRequest> exemptionRequests = new List<ExemptionRequest>(); if (allOperations[index].exemptionRequests != null) { exemptionRequests.AddRange(allOperations[index].exemptionRequests); } ExemptionRequest exemptionRequest = new ExemptionRequest(); exemptionRequest.key = policyError.key; exemptionRequests.Add(exemptionRequest); allOperations[index].exemptionRequests = exemptionRequests.ToArray(); } else { // Policy violation error is not exemptable, remove this // operation from the list of operations. operationsToBeRemoved.Add(allOperations[index]); } } else { // This is not a policy violation error, remove this operation // from the list of operations. operationsToBeRemoved.Add(allOperations[index]); } }
Python
for error in e.errors: # Get the index of the failed operation from the error's field path # elements. field_path_elements = error['fieldPathElements'] first_field_path_element = None if field_path_elements: first_field_path_element = field_path_elements[0] # If the operation index is not present on the first error field path # element, then there's no way to determine which operation to remove, # so simply throw the exception. if (not (first_field_path_element and first_field_path_element['field'] == 'operations' and 'index' in first_field_path_element)): raise e index = long(first_field_path_element['index']) operation = operations[index] if not HandleAPIError(error, operation): # Set non-exemptable operation to None to mark for deletion. print ('Removing operation with non-exemptable error at index %s.' % index) operations[index] = None
PHP
foreach ($apiException->getErrors() as $error) { // Get the index of the failed operation from the error's field path // elements. $fieldPathElements = $error->getFieldPathElements(); $firstFieldPathElement = null; if ($fieldPathElements !== null && count($fieldPathElements) > 0) { $firstFieldPathElement = $fieldPathElements[0]; } if ($firstFieldPathElement === null || $firstFieldPathElement->getField() !== 'operations' || $firstFieldPathElement->getIndex() === null) { // If the operation index is not present on the first error field // path element, then there's no way to determine which operation to // remove, so simply throw the exception. throw $apiException; } $operationIndex = $firstFieldPathElement->getIndex(); $operation = $operations[$operationIndex]; if (self::handleApiError($error, $operationIndex, $operation)) { // Store the index of operations we want to retry as indices of the // bucket. $operationIndicesToRetryBucket[$operationIndex] = 1; } else { printf( "Removing operation with non-exemptable error at index %d.\n", $operationIndex ); } }
Perl
foreach my $error (@{$result->get_detail()->get_ApiExceptionFault()->get_errors()}) { # Get the index of the failed operation from the error's field path # elements. my $field_path_elements = $error->get_fieldPathElements(); my $first_field_path_element = ($field_path_elements && (scalar $field_path_elements > 0)) ? $field_path_elements->[0] : undef; if ( $first_field_path_element && $first_field_path_element->get_field() eq "operations" && defined $first_field_path_element->get_index()) { my $operation_index = $first_field_path_element->get_index(); my $operation = $operations[$operation_index]; if ($error->get_ApiError__Type() =~ "PolicyViolationError") { printf "Ad with headline '%s' violated '%s' policy '%s'.\n", $operation->get_operand()->get_ad()->get_headlinePart1(), $error->get_isExemptable ? 'exemptable' : 'non-exemptable', $error->get_externalPolicyName(); if ($error->get_isExemptable()) { # Add exemption request to the operation. printf( "Adding exemption request for policy name '%s' on text " . "'%s'.\n", $error->get_key()->get_policyName(), $error->get_key()->get_violatingText()); $operation->set_exemptionRequests([ new Google::Ads::AdWords::v201802::ExemptionRequest( {key => $error->get_key()})]); } else { # Remove non-exemptable operation. print "Removing from the request.\n"; push @operation_indicies_to_remove, $operation_index; } } else { # Non-policy error returned, remove ad. print "Removing from the request.\n"; push @operation_indicies_to_remove, $operation_index; } } }
Ruby
e.errors.each do |error| if error[:xsi_type] == 'PolicyViolationError' field_path_elements = error[:field_path_elements] first_field_path_element = nil unless field_path_elements.nil? || field_path_elements.length <= 0 first_field_path_element = field_path_elements.first end if first_field_path_element.nil? || 'operations' != first_field_path_element[:field] || first_field_path_element[:index].nil? # If the operation index is not present on the first error field path # element, then there's no way to determine which operation to # remove, so simply throw the exception. raise e end operation_index = first_field_path_element[:index] operation = operations[operation_index] process_api_error(error, operation) unless error[:is_exemptable] # Remove non-exemptable operation puts "Removing the operation from the request." operations.delete(operation) end else # Non-policy error returned, re-throw exception. raise e end end
VB.NET
Dim innerException As ApiException = TryCast(e.ApiException, ApiException) If (innerException Is Nothing) Then Throw New Exception("Failed to retrieve ApiError. See inner exception for more " & "details.", e) End If ' Examine each ApiError received from the server. For Each apiError As ApiError In innerException.errors Dim index As Integer = apiError.GetOperationIndex() If (index = -1) Then ' This API error is not associated with an operand, so we cannot ' recover from this error by removing one or more operations. ' Rethrow the exception for manual inspection. Throw End If ' Handle policy violation errors. If TypeOf apiError Is PolicyViolationError Then Dim policyError As PolicyViolationError = CType(apiError, PolicyViolationError) If policyError.isExemptable Then ' If the policy violation error is exemptable, add an exemption ' request. Dim exemptionRequests As New List(Of ExemptionRequest) If (Not allOperations.Item(index).exemptionRequests Is Nothing) Then exemptionRequests.AddRange(allOperations.Item(index).exemptionRequests) End If Dim exemptionRequest As New ExemptionRequest exemptionRequest.key = policyError.key exemptionRequests.Add(exemptionRequest) allOperations.Item(index).exemptionRequests = exemptionRequests.ToArray Else ' Policy violation error is not exemptable, remove this ' operation from the list of operations. operationsToBeRemoved.Add(allOperations.Item(index)) End If Else ' This is not a policy violation error, remove this operation ' from the list of operations. operationsToBeRemoved.Add(allOperations.Item(index)) End If Next
Operationen mit Ausnahmeanfragen aktualisieren
Um die Operationen, die aufgrund eines ausnahmefähigen Richtlinienverstoßes gescheitert sind, noch einmal zu senden, müssen Sie mindestens eine ExemptionRequest
der exemptionRequests
-Sammlung der Operation hinzufügen.
Eine ExemptionRequest
hat nur das Attribut PolicyViolationKey
. Es besteht aus diesen Komponenten:
- einem String, der den Richtliniennamen identifiziert
- einem String, der den bemängelten Text identifiziert
Jeder aufgetretene PolicyViolationError
stellt diese Informationen zur Verfügung. Wie aus dem folgenden Code-Snippet hervorgeht, können Sie das key
-Attribut jedes PolicyViolationError
für das key
-Attribut der entsprechenden ExemptionRequest
verwenden.
Java
private static boolean handleApiError( ApiError error, int operationIndex, AdGroupAdOperation operation) { // Determine if the operation can be resubmitted with an exemption request. boolean isExemptableError = false; PolicyViolationError policyViolationError = null; if (error instanceof PolicyViolationError) { policyViolationError = (PolicyViolationError) error; ExpandedTextAd expandedTextAd = (ExpandedTextAd) operation.getOperand().getAd(); System.out.printf( "Ad with headline '%s - %s' violated %s policy '%s'.%n", expandedTextAd.getHeadlinePart1(), expandedTextAd.getHeadlinePart2(), policyViolationError.getIsExemptable() ? "exemptable" : "non-exemptable", policyViolationError.getExternalPolicyName()); isExemptableError = policyViolationError.getIsExemptable(); } if (isExemptableError) { // Add exemption request to the operation. System.out.printf( "Adding exemption request for policy name '%s' on text '%s' to operation at index %d.%n", policyViolationError.getKey().getPolicyName(), policyViolationError.getKey().getViolatingText(), operationIndex); ExemptionRequest exemptionRequest = new ExemptionRequest(); exemptionRequest.setKey(policyViolationError.getKey()); List<ExemptionRequest> exemptionRequests = (operation.getExemptionRequests() == null) ? new ArrayList<ExemptionRequest>() : new ArrayList<>(Arrays.asList(operation.getExemptionRequests())); exemptionRequests.add(exemptionRequest); operation.setExemptionRequests( exemptionRequests.toArray(new ExemptionRequest[exemptionRequests.size()])); } return isExemptableError; }
CSharp
// Handle policy violation errors. if (apiError is PolicyViolationError) { PolicyViolationError policyError = (PolicyViolationError) apiError; if (policyError.isExemptable) { // If the policy violation error is exemptable, add an exemption // request. List<ExemptionRequest> exemptionRequests = new List<ExemptionRequest>(); if (allOperations[index].exemptionRequests != null) { exemptionRequests.AddRange(allOperations[index].exemptionRequests); } ExemptionRequest exemptionRequest = new ExemptionRequest(); exemptionRequest.key = policyError.key; exemptionRequests.Add(exemptionRequest); allOperations[index].exemptionRequests = exemptionRequests.ToArray(); } else { // Policy violation error is not exemptable, remove this // operation from the list of operations. operationsToBeRemoved.Add(allOperations[index]); } } else { // This is not a policy violation error, remove this operation // from the list of operations. operationsToBeRemoved.Add(allOperations[index]); }
Python
def HandleAPIError(error, operation): """Makes an exemption for exemptable PolicyViolationErrors. Args: error: the error associated with the given operation. operation: the operation associated with the given error. Returns: A boolean that is True if the given error was an exemptable PolicyViolationError; otherwise, returns False. """ is_exemptable = False # Determine if the operation can be resubmitted with an exemption request. if error['ApiError.Type'] == 'PolicyViolationError': expanded_text_ad = operation['operand']['ad'] is_exemptable = (error['isExemptable'] if 'isExemptable' in error else False) print ('Ad with headline "%s - %s" violated %s policy "%s".' % (expanded_text_ad['headlinePart1'], expanded_text_ad['headlinePart2'], 'exemptable' if is_exemptable else 'non-exemptable', error['externalPolicyName'])) if is_exemptable: # Add exemption request to the operation. print ('Adding exemption request for policy name "%s" on text "%s".' % (error['key']['policyName'], error['key']['violatingText'])) if 'exemptionRequests' not in operation: operation['exemptionRequests'] = [] operation['exemptionRequests'].append({'key': error['key']}) return is_exemptable
PHP
private static function handleApiError( ApiError $apiError, $operationIndex, AdGroupAdOperation $operation ) { $isExemptableError = false; $policyViolationError = null; $expandedTextAd = $operation->getOperand()->getAd(); if ($apiError instanceof PolicyViolationError) { printf( "Ad with headline '%s - %s' violated %s policy '%s'.\n", $expandedTextAd->getHeadlinePart1(), $expandedTextAd->getHeadlinePart2(), $apiError->getIsExemptable() ? 'exemptable' : 'non-exemptable', $apiError->getExternalPolicyName() ); $isExemptableError = $apiError->getIsExemptable(); } if ($isExemptableError) { // Add exemption request to the operation. printf( "Adding exemption request for policy name '%s' on text '%s' to operation at index %d.\n", $apiError->getKey()->getPolicyName(), $apiError->getKey()->getViolatingText(), $operationIndex ); if ($operation->getExemptionRequests() === null) { $exemptionRequests = []; } else { $exemptionRequests = $operation->getExemptionRequests(); } $exemptionRequests[] = new ExemptionRequest($apiError->getKey()); $operation->setExemptionRequests($exemptionRequests); } return $isExemptableError; }
Perl
if ($error->get_ApiError__Type() =~ "PolicyViolationError") { printf "Ad with headline '%s' violated '%s' policy '%s'.\n", $operation->get_operand()->get_ad()->get_headlinePart1(), $error->get_isExemptable ? 'exemptable' : 'non-exemptable', $error->get_externalPolicyName(); if ($error->get_isExemptable()) { # Add exemption request to the operation. printf( "Adding exemption request for policy name '%s' on text " . "'%s'.\n", $error->get_key()->get_policyName(), $error->get_key()->get_violatingText()); $operation->set_exemptionRequests([ new Google::Ads::AdWords::v201802::ExemptionRequest( {key => $error->get_key()})]); } else { # Remove non-exemptable operation. print "Removing from the request.\n"; push @operation_indicies_to_remove, $operation_index; } } else { # Non-policy error returned, remove ad. print "Removing from the request.\n"; push @operation_indicies_to_remove, $operation_index; }
Ruby
def process_api_error(error, operation) is_exemptable = error[:is_exemptable] puts "Ad with headline '%s - %s' violated %s policy '%s'." % [operation[:operand][:ad][:headline_part1], operation[:operand][:ad][:headline_part2], is_exemptable ? 'exemptable' : 'non-exemptable', error[:external_policy_name]] if is_exemptable # Add exemption request to the operation. puts "Adding exemption request for policy name '%s' on text '%s'." % [error[:key][:policy_name], error[:key][:violating_text]] unless operation[:exemption_requests] operation[:exemption_requests] = [] end operation[:exemption_requests] << { :key => error[:key] } end end
VB.NET
' Handle policy violation errors. If TypeOf apiError Is PolicyViolationError Then Dim policyError As PolicyViolationError = CType(apiError, PolicyViolationError) If policyError.isExemptable Then ' If the policy violation error is exemptable, add an exemption ' request. Dim exemptionRequests As New List(Of ExemptionRequest) If (Not allOperations.Item(index).exemptionRequests Is Nothing) Then exemptionRequests.AddRange(allOperations.Item(index).exemptionRequests) End If Dim exemptionRequest As New ExemptionRequest exemptionRequest.key = policyError.key exemptionRequests.Add(exemptionRequest) allOperations.Item(index).exemptionRequests = exemptionRequests.ToArray Else ' Policy violation error is not exemptable, remove this ' operation from the list of operations. operationsToBeRemoved.Add(allOperations.Item(index)) End If Else ' This is not a policy violation error, remove this operation ' from the list of operations. operationsToBeRemoved.Add(allOperations.Item(index)) End If
Geänderte Operationen noch einmal senden
Wenn Sie wie im Beispiel vorgegangen sind, gibt es jetzt die folgenden AdGroupAdOperation
s:
- Eine
AdGroupAdOperation
für Anzeige A mit einer einzigen Ausnahmeanfrage mit dem Richtlinienamen "pharma" und dem bemängelten Text aus dem erstenPolicyViolationError
. - Eine
AdGroupAdOperation
für Anzeige B mit zwei Ausnahmeanfragen: eine mit dem Richtliniennamen "pharma" und dem bemängelten Text aus dem zweitenPolicyViolationError
sowie eine weitere mit dem Richtliniennamen "nonstandard_punctuation" mit dem bemängelten Text aus dem drittenPolicyViolationError
.
Die AdGroupAdOperation
für Anzeige C wurde verworfen, da ihr PolicyViolationError
nicht ausnahmefähig war.
Nun können Sie die geänderten AdGroupAdOperation
s für die Anzeigen A und B senden. Diese Operationen werden erfolgreich sein und zwei neue Anzeigen ergeben, deren Überprüfung aussteht.
Freigabestatus jeder Anzeige oder jedes Keywords überwachen
Wie bei allen neuen Anzeigen können Sie regelmäßig AdGroupAdService.get()
- oder AdGroupAdService.query()
-Anfragen senden, in denen das Feld AdGroupCreativeApprovalStatus
enthalten ist, um die Anzeige zu überwachen und festzustellen, ob sie letztlich freigegeben oder abgelehnt wurde.
Codebeispiele
Jede Clientbibliothek enthält zwei Codebeispiele im Zusammenhang mit Richtlinienverstößen:
- Fehler bei Richtlinienverstößen behandeln: Dieses Beispiel zeigt, wie Sie
AdGroupAdOperations
, die aufgrund von ausnahmefähigen Richtlinienverstößen fehlgeschlagen sind, identifizieren und noch einmal senden. - Textanzeige überprüfen: Dieses Beispiel zeigt, wie Sie Anzeigen mithilfe des SOAP-Headers
validateOnly
(im Leitfaden zur API-Aufrufstruktur beschrieben) zur Überprüfung senden.