Erste Schritte

Sie müssen Conversion-Tracking in Ihrem Google Ads-Conversion-Konto aktivieren, um Conversions erfassen zu können. In diesem Leitfaden erfahren Sie, wie Sie prüfen, ob das Conversion-Tracking aktiviert ist, und es gegebenenfalls aktivieren. Außerdem wird beschrieben, wie Sie Informationen zu vorhandenen Conversion-Aktionen abrufen.

Für die meisten Conversion-Aktionen sind außerdem zusätzliche Schritte erforderlich, um sie zu erfassen. Weitere Informationen zu den verschiedenen Conversion-Aktionstypen und ihren Anforderungen finden Sie im Leitfaden zum Erstellen von Conversion-Aktionen.

Website für das Conversion-Tracking einrichten

Wenn Sie den Import von Offline-Conversions einbinden möchten, müssen Sie zuerst die Schritte in der Anleitung Google-Tag für erweiterte Conversions für Leads konfigurieren ausführen, um Ihre Website für das Tracking erweiterter Conversions für Leads zu konfigurieren. Sie können Ihre Website auch mit Google Tag Manager konfigurieren. Folgen Sie dazu der Anleitung unter Google Tag Manager für erweiterte Conversions für Leads konfigurieren.

Conversion-Tracking in Ihrem Google Ads-Conversion-Konto aktivieren

Informationen zur Konfiguration des Conversion-Trackings abrufen

Sie können die Einrichtung des Conversion-Trackings in Ihrem Konto prüfen und bestätigen, dass das Conversion-Tracking aktiviert ist. Rufen Sie dazu die Ressource Customer für ConversionTrackingSetting ab. Führen Sie die folgende Abfrage mit GoogleAdsService.SearchStream aus:

SELECT
  customer.conversion_tracking_setting.google_ads_conversion_customer,
  customer.conversion_tracking_setting.conversion_tracking_status,
  customer.conversion_tracking_setting.conversion_tracking_id,
  customer.conversion_tracking_setting.cross_account_conversion_tracking_id
FROM customer

Im Feld google_ads_conversion_customer wird das Google Ads-Konto angegeben, in dem Conversions für diesen Kunden erstellt und verwaltet werden. Bei Kunden, die kontoübergreifendes Conversion-Tracking verwenden, ist dies die ID eines Verwaltungskontos. Die Google Ads-Conversion-Kundennummer muss als customer_id in Google Ads API-Anfragen angegeben werden, um Conversions zu erstellen und zu verwalten. Dieses Feld wird auch dann ausgefüllt, wenn das Conversion-Tracking nicht aktiviert ist.

Im Feld conversion_tracking_status wird angegeben, ob das Conversion-Tracking aktiviert ist und ob im Konto das kontoübergreifende Conversion-Tracking verwendet wird.

Conversion-Aktion für den Google Ads-Conversion-Kunden erstellen

Wenn der Wert für conversion_tracking_status NOT_CONVERSION_TRACKED ist, ist das Conversion-Tracking für das Konto nicht aktiviert. Aktivieren Sie das Conversion-Tracking, indem Sie im Google Ads-Conversion-Konto mindestens eine ConversionAction erstellen, wie im folgenden Beispiel. Alternativ können Sie eine Conversion-Aktion auch über die Benutzeroberfläche erstellen. Folgen Sie dazu der Anleitung in der Google Ads-Hilfe für den Conversion-Typ, den Sie aktivieren möchten.

Erweiterte Conversions werden automatisch aktiviert, wenn sie über die Google Ads API gesendet werden. Sie können sie aber über die Google Ads-Benutzeroberfläche deaktivieren.

Codebeispiel

Java

private void runExample(GoogleAdsClient googleAdsClient, long customerId) {

  // Creates a ConversionAction.
  ConversionAction conversionAction =
      ConversionAction.newBuilder()
          // Note that conversion action names must be unique. If a conversion action already
          // exists with the specified conversion_action_name the create operation will fail with
          // a ConversionActionError.DUPLICATE_NAME error.
          .setName("Earth to Mars Cruises Conversion #" + getPrintableDateTime())
          .setCategory(ConversionActionCategory.DEFAULT)
          .setType(ConversionActionType.WEBPAGE)
          .setStatus(ConversionActionStatus.ENABLED)
          .setViewThroughLookbackWindowDays(15L)
          .setValueSettings(
              ValueSettings.newBuilder()
                  .setDefaultValue(23.41)
                  .setAlwaysUseDefaultValue(true)
                  .build())
          .build();

  // Creates the operation.
  ConversionActionOperation operation =
      ConversionActionOperation.newBuilder().setCreate(conversionAction).build();

  try (ConversionActionServiceClient conversionActionServiceClient =
      googleAdsClient.getLatestVersion().createConversionActionServiceClient()) {
    MutateConversionActionsResponse response =
        conversionActionServiceClient.mutateConversionActions(
            Long.toString(customerId), Collections.singletonList(operation));
    System.out.printf("Added %d conversion actions:%n", response.getResultsCount());
    for (MutateConversionActionResult result : response.getResultsList()) {
      System.out.printf(
          "New conversion action added with resource name: '%s'%n", result.getResourceName());
    }
  }
}
      

C#

public void Run(GoogleAdsClient client, long customerId)
{
    // Get the ConversionActionService.
    ConversionActionServiceClient conversionActionService =
        client.GetService(Services.V19.ConversionActionService);

    // Note that conversion action names must be unique.
    // If a conversion action already exists with the specified name the create operation
    // will fail with a ConversionAction.DUPLICATE_NAME error.
    string ConversionActionName = "Earth to Mars Cruises Conversion #"
        + ExampleUtilities.GetRandomString();

    // Add a conversion action.
    ConversionAction conversionAction = new ConversionAction()
    {
        Name = ConversionActionName,
        Category = ConversionActionCategory.Default,
        Type = ConversionActionType.Webpage,
        Status = ConversionActionStatus.Enabled,
        ViewThroughLookbackWindowDays = 15,
        ValueSettings = new ConversionAction.Types.ValueSettings()
        {
            DefaultValue = 23.41,
            AlwaysUseDefaultValue = true
        }
    };

    // Create the operation.
    ConversionActionOperation operation = new ConversionActionOperation()
    {
        Create = conversionAction
    };

    try
    {
        // Create the conversion action.
        MutateConversionActionsResponse response =
            conversionActionService.MutateConversionActions(customerId.ToString(),
                    new ConversionActionOperation[] { operation });

        // Display the results.
        foreach (MutateConversionActionResult newConversionAction in response.Results)
        {
            Console.WriteLine($"New conversion action with resource name = " +
                $"'{newConversionAction.ResourceName}' was added.");
        }
    }
    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 a conversion action.
    $conversionAction = new ConversionAction([
        // Note that conversion action names must be unique.
        // If a conversion action already exists with the specified conversion_action_name
        // the create operation will fail with a ConversionActionError.DUPLICATE_NAME error.
        'name' => 'Earth to Mars Cruises Conversion #' . Helper::getPrintableDatetime(),
        'category' => ConversionActionCategory::PBDEFAULT,
        'type' => ConversionActionType::WEBPAGE,
        'status' => ConversionActionStatus::ENABLED,
        'view_through_lookback_window_days' => 15,
        'value_settings' => new ValueSettings([
            'default_value' => 23.41,
            'always_use_default_value' => true
        ])
    ]);

    // Creates a conversion action operation.
    $conversionActionOperation = new ConversionActionOperation();
    $conversionActionOperation->setCreate($conversionAction);

    // Issues a mutate request to add the conversion action.
    $conversionActionServiceClient = $googleAdsClient->getConversionActionServiceClient();
    $response = $conversionActionServiceClient->mutateConversionActions(
        MutateConversionActionsRequest::build($customerId, [$conversionActionOperation])
    );

    printf("Added %d conversion actions:%s", $response->getResults()->count(), PHP_EOL);

    foreach ($response->getResults() as $addedConversionAction) {
        /** @var ConversionAction $addedConversionAction */
        printf(
            "New conversion action added with resource name: '%s'%s",
            $addedConversionAction->getResourceName(),
            PHP_EOL
        );
    }
}
      

Python

def main(client, customer_id):
    conversion_action_service = client.get_service("ConversionActionService")

    # Create the operation.
    conversion_action_operation = client.get_type("ConversionActionOperation")

    # Create conversion action.
    conversion_action = conversion_action_operation.create

    # Note that conversion action names must be unique. If a conversion action
    # already exists with the specified conversion_action_name, the create
    # operation will fail with a ConversionActionError.DUPLICATE_NAME error.
    conversion_action.name = f"Earth to Mars Cruises Conversion {uuid.uuid4()}"
    conversion_action.type_ = (
        client.enums.ConversionActionTypeEnum.UPLOAD_CLICKS
    )
    conversion_action.category = (
        client.enums.ConversionActionCategoryEnum.DEFAULT
    )
    conversion_action.status = client.enums.ConversionActionStatusEnum.ENABLED
    conversion_action.view_through_lookback_window_days = 15

    # Create a value settings object.
    value_settings = conversion_action.value_settings
    value_settings.default_value = 15.0
    value_settings.always_use_default_value = True

    # Add the conversion action.
    conversion_action_response = (
        conversion_action_service.mutate_conversion_actions(
            customer_id=customer_id,
            operations=[conversion_action_operation],
        )
    )

    print(
        "Created conversion action "
        f'"{conversion_action_response.results[0].resource_name}".'
    )
      

Ruby

def add_conversion_action(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


  # Add a conversion action.
  conversion_action = client.resource.conversion_action do |ca|
    ca.name = "Earth to Mars Cruises Conversion #{(Time.new.to_f * 100).to_i}"
    ca.type = :UPLOAD_CLICKS
    ca.category = :DEFAULT
    ca.status = :ENABLED
    ca.view_through_lookback_window_days = 15

    # Create a value settings object.
    ca.value_settings = client.resource.value_settings do |vs|
      vs.default_value = 15
      vs.always_use_default_value = true
    end
  end

  # Create the operation.
  conversion_action_operation = client.operation.create_resource.conversion_action(conversion_action)

  # Add the ad group ad.
  response = client.service.conversion_action.mutate_conversion_actions(
    customer_id: customer_id,
    operations: [conversion_action_operation],
  )

  puts "New conversion action with resource name = #{response.results.first.resource_name}."
end
      

Perl

sub add_conversion_action {
  my ($api_client, $customer_id) = @_;

  # Note that conversion action names must be unique.
  # If a conversion action already exists with the specified conversion_action_name,
  # the create operation fails with error ConversionActionError.DUPLICATE_NAME.
  my $conversion_action_name = "Earth to Mars Cruises Conversion #" . uniqid();

  # Create a conversion action.
  my $conversion_action =
    Google::Ads::GoogleAds::V19::Resources::ConversionAction->new({
      name                          => $conversion_action_name,
      category                      => DEFAULT,
      type                          => WEBPAGE,
      status                        => ENABLED,
      viewThroughLookbackWindowDays => 15,
      valueSettings                 =>
        Google::Ads::GoogleAds::V19::Resources::ValueSettings->new({
          defaultValue          => 23.41,
          alwaysUseDefaultValue => "true"
        })});

  # Create a conversion action operation.
  my $conversion_action_operation =
    Google::Ads::GoogleAds::V19::Services::ConversionActionService::ConversionActionOperation
    ->new({create => $conversion_action});

  # Add the conversion action.
  my $conversion_actions_response =
    $api_client->ConversionActionService()->mutate({
      customerId => $customer_id,
      operations => [$conversion_action_operation]});

  printf "New conversion action added with resource name: '%s'.\n",
    $conversion_actions_response->{results}[0]{resourceName};

  return 1;
}
      

Achten Sie darauf, dass conversion_action_type auf den richtigen ConversionActionType-Wert festgelegt ist. Weitere Informationen zum Erstellen von Conversion-Aktionen in der Google Ads API finden Sie unter Conversion-Aktionen erstellen.

Vorhandene Conversion-Aktion abrufen

Mit der folgenden Abfrage können Sie Details zu einer vorhandenen Conversion-Aktion abrufen. Achten Sie darauf, dass in der Anfrage die Kundennummer des Google Ads-Conversion-Kunden festgelegt ist, den Sie oben angegeben haben, und dass der Conversion-Aktionstyp den richtigen Wert ConversionActionType hat.

SELECT
  conversion_action.resource_name,
  conversion_action.name,
  conversion_action.status
FROM conversion_action
WHERE conversion_action.type = 'INSERT_CONVERSION_ACTION_TYPE'

Kontoübergreifendes Conversion-Tracking

Wenn Sie kontoübergreifendes Conversion-Tracking verwenden, werden für ConversionActionService die folgenden Conversion-Aktionen zurückgegeben:

  • Alle Conversion-Aktionen, die im Verwaltungskonto definiert wurden, das vom Konto für das kontoübergreifende Conversion-Tracking verwendet wird
  • Alle Conversion-Aktionen, für die der Kunde Statistiken erfasst hat, einschließlich systemdefinierter Aktionen und Aktionen, deren Inhaber der Verwaltungskontoinhaber ist, auch wenn die Verknüpfung später aufgehoben wird
  • Alle Aktionen, die der Kunde in seinem eigenen Konto definiert hat
  • Analytics-Conversions, die in verknüpften Google Analytics-Properties erstellt wurden. Dazu gehören auch Aktionen für Analytics-Conversions, die nicht in Google Ads importiert wurden und den Status HIDDEN haben.

Ab der Version v19.1 können Sie beim Erstellen von Kundenkonten die Google Ads API verwenden, um das Conversion-Tracking zu aktivieren.

Wenn Sie eine neue Customer erstellen, legen Sie conversion_tracking_setting.google_ads_conversion_customer als Ressourcennamen des Verwaltungskontos fest, das Conversion-Aktionen im Namen des Kundenkontos verwalten soll. Dieses Verwaltungskonto muss auch das Konto sein, über das der create-Antrag für das neue Kundenkonto gestellt wird.

Wenn Sie das kontoübergreifende Conversion-Tracking für vorhandene Kundenkonten aktivieren möchten, müssen Sie die Google Ads-Benutzeroberfläche verwenden.

Conversion-Aktionen erstellen

Wenn Sie Conversions erfassen möchten, richten Sie einen ConversionAction für die type der Conversion-Aktion ein, die Sie erfassen möchten. Für einen Onlinekauf und einen Anruf sind beispielsweise unterschiedliche Conversion-Aktionen erforderlich.

Am besten verwenden Sie das unten stehende Codebeispiel zum Hinzufügen einer Conversion-Aktion, um neue Conversion-Aktionen in der API einzurichten. Das Beispiel übernimmt alle Aufgaben der Authentifizierung im Hintergrund und führt Sie durch das Erstellen einer ConversionAction.

Bei den meisten Conversion-Aktionen sind außerdem zusätzliche Schritte erforderlich, um sie zu erfassen. Wenn Sie beispielsweise Conversions auf Ihrer Website erfassen möchten, müssen Sie der Conversion-Seite Ihrer Website ein Code-Snippet hinzufügen, das als Tag bezeichnet wird. Ausführliche Anforderungen für andere Conversion-Aktionstypen finden Sie in diesem Hilfeartikel.

Codebeispiel

Im folgenden Codebeispiel wird beschrieben, wie Sie eine neue Conversion-Aktion erstellen. Konkret wird eine Conversion-Aktion mit type = UPLOAD_CLICKS erstellt. Dieser Vorgang entspricht dem, der bei der Erstellung einer neuen Conversion-Aktion über Import > Manueller Import über API oder Uploads > Conversions aus Klicks erfassen ausgeführt wird. Außerdem wird die category auf DEFAULT gesetzt.

Es gelten die folgenden Standardeinstellungen:

Java

private void runExample(GoogleAdsClient googleAdsClient, long customerId) {

  // Creates a ConversionAction.
  ConversionAction conversionAction =
      ConversionAction.newBuilder()
          // Note that conversion action names must be unique. If a conversion action already
          // exists with the specified conversion_action_name the create operation will fail with
          // a ConversionActionError.DUPLICATE_NAME error.
          .setName("Earth to Mars Cruises Conversion #" + getPrintableDateTime())
          .setCategory(ConversionActionCategory.DEFAULT)
          .setType(ConversionActionType.WEBPAGE)
          .setStatus(ConversionActionStatus.ENABLED)
          .setViewThroughLookbackWindowDays(15L)
          .setValueSettings(
              ValueSettings.newBuilder()
                  .setDefaultValue(23.41)
                  .setAlwaysUseDefaultValue(true)
                  .build())
          .build();

  // Creates the operation.
  ConversionActionOperation operation =
      ConversionActionOperation.newBuilder().setCreate(conversionAction).build();

  try (ConversionActionServiceClient conversionActionServiceClient =
      googleAdsClient.getLatestVersion().createConversionActionServiceClient()) {
    MutateConversionActionsResponse response =
        conversionActionServiceClient.mutateConversionActions(
            Long.toString(customerId), Collections.singletonList(operation));
    System.out.printf("Added %d conversion actions:%n", response.getResultsCount());
    for (MutateConversionActionResult result : response.getResultsList()) {
      System.out.printf(
          "New conversion action added with resource name: '%s'%n", result.getResourceName());
    }
  }
}
      

C#

public void Run(GoogleAdsClient client, long customerId)
{
    // Get the ConversionActionService.
    ConversionActionServiceClient conversionActionService =
        client.GetService(Services.V19.ConversionActionService);

    // Note that conversion action names must be unique.
    // If a conversion action already exists with the specified name the create operation
    // will fail with a ConversionAction.DUPLICATE_NAME error.
    string ConversionActionName = "Earth to Mars Cruises Conversion #"
        + ExampleUtilities.GetRandomString();

    // Add a conversion action.
    ConversionAction conversionAction = new ConversionAction()
    {
        Name = ConversionActionName,
        Category = ConversionActionCategory.Default,
        Type = ConversionActionType.Webpage,
        Status = ConversionActionStatus.Enabled,
        ViewThroughLookbackWindowDays = 15,
        ValueSettings = new ConversionAction.Types.ValueSettings()
        {
            DefaultValue = 23.41,
            AlwaysUseDefaultValue = true
        }
    };

    // Create the operation.
    ConversionActionOperation operation = new ConversionActionOperation()
    {
        Create = conversionAction
    };

    try
    {
        // Create the conversion action.
        MutateConversionActionsResponse response =
            conversionActionService.MutateConversionActions(customerId.ToString(),
                    new ConversionActionOperation[] { operation });

        // Display the results.
        foreach (MutateConversionActionResult newConversionAction in response.Results)
        {
            Console.WriteLine($"New conversion action with resource name = " +
                $"'{newConversionAction.ResourceName}' was added.");
        }
    }
    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 a conversion action.
    $conversionAction = new ConversionAction([
        // Note that conversion action names must be unique.
        // If a conversion action already exists with the specified conversion_action_name
        // the create operation will fail with a ConversionActionError.DUPLICATE_NAME error.
        'name' => 'Earth to Mars Cruises Conversion #' . Helper::getPrintableDatetime(),
        'category' => ConversionActionCategory::PBDEFAULT,
        'type' => ConversionActionType::WEBPAGE,
        'status' => ConversionActionStatus::ENABLED,
        'view_through_lookback_window_days' => 15,
        'value_settings' => new ValueSettings([
            'default_value' => 23.41,
            'always_use_default_value' => true
        ])
    ]);

    // Creates a conversion action operation.
    $conversionActionOperation = new ConversionActionOperation();
    $conversionActionOperation->setCreate($conversionAction);

    // Issues a mutate request to add the conversion action.
    $conversionActionServiceClient = $googleAdsClient->getConversionActionServiceClient();
    $response = $conversionActionServiceClient->mutateConversionActions(
        MutateConversionActionsRequest::build($customerId, [$conversionActionOperation])
    );

    printf("Added %d conversion actions:%s", $response->getResults()->count(), PHP_EOL);

    foreach ($response->getResults() as $addedConversionAction) {
        /** @var ConversionAction $addedConversionAction */
        printf(
            "New conversion action added with resource name: '%s'%s",
            $addedConversionAction->getResourceName(),
            PHP_EOL
        );
    }
}
      

Python

def main(client, customer_id):
    conversion_action_service = client.get_service("ConversionActionService")

    # Create the operation.
    conversion_action_operation = client.get_type("ConversionActionOperation")

    # Create conversion action.
    conversion_action = conversion_action_operation.create

    # Note that conversion action names must be unique. If a conversion action
    # already exists with the specified conversion_action_name, the create
    # operation will fail with a ConversionActionError.DUPLICATE_NAME error.
    conversion_action.name = f"Earth to Mars Cruises Conversion {uuid.uuid4()}"
    conversion_action.type_ = (
        client.enums.ConversionActionTypeEnum.UPLOAD_CLICKS
    )
    conversion_action.category = (
        client.enums.ConversionActionCategoryEnum.DEFAULT
    )
    conversion_action.status = client.enums.ConversionActionStatusEnum.ENABLED
    conversion_action.view_through_lookback_window_days = 15

    # Create a value settings object.
    value_settings = conversion_action.value_settings
    value_settings.default_value = 15.0
    value_settings.always_use_default_value = True

    # Add the conversion action.
    conversion_action_response = (
        conversion_action_service.mutate_conversion_actions(
            customer_id=customer_id,
            operations=[conversion_action_operation],
        )
    )

    print(
        "Created conversion action "
        f'"{conversion_action_response.results[0].resource_name}".'
    )
      

Ruby

def add_conversion_action(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


  # Add a conversion action.
  conversion_action = client.resource.conversion_action do |ca|
    ca.name = "Earth to Mars Cruises Conversion #{(Time.new.to_f * 100).to_i}"
    ca.type = :UPLOAD_CLICKS
    ca.category = :DEFAULT
    ca.status = :ENABLED
    ca.view_through_lookback_window_days = 15

    # Create a value settings object.
    ca.value_settings = client.resource.value_settings do |vs|
      vs.default_value = 15
      vs.always_use_default_value = true
    end
  end

  # Create the operation.
  conversion_action_operation = client.operation.create_resource.conversion_action(conversion_action)

  # Add the ad group ad.
  response = client.service.conversion_action.mutate_conversion_actions(
    customer_id: customer_id,
    operations: [conversion_action_operation],
  )

  puts "New conversion action with resource name = #{response.results.first.resource_name}."
end
      

Perl

sub add_conversion_action {
  my ($api_client, $customer_id) = @_;

  # Note that conversion action names must be unique.
  # If a conversion action already exists with the specified conversion_action_name,
  # the create operation fails with error ConversionActionError.DUPLICATE_NAME.
  my $conversion_action_name = "Earth to Mars Cruises Conversion #" . uniqid();

  # Create a conversion action.
  my $conversion_action =
    Google::Ads::GoogleAds::V19::Resources::ConversionAction->new({
      name                          => $conversion_action_name,
      category                      => DEFAULT,
      type                          => WEBPAGE,
      status                        => ENABLED,
      viewThroughLookbackWindowDays => 15,
      valueSettings                 =>
        Google::Ads::GoogleAds::V19::Resources::ValueSettings->new({
          defaultValue          => 23.41,
          alwaysUseDefaultValue => "true"
        })});

  # Create a conversion action operation.
  my $conversion_action_operation =
    Google::Ads::GoogleAds::V19::Services::ConversionActionService::ConversionActionOperation
    ->new({create => $conversion_action});

  # Add the conversion action.
  my $conversion_actions_response =
    $api_client->ConversionActionService()->mutate({
      customerId => $customer_id,
      operations => [$conversion_action_operation]});

  printf "New conversion action added with resource name: '%s'.\n",
    $conversion_actions_response->{results}[0]{resourceName};

  return 1;
}
      

Dieses Beispiel finden Sie auch im Ordner „Remarketing“ Ihrer Clientbibliothek und in der Sammlung mit Codebeispielen: Beispiel für Code zum Hinzufügen einer Conversion-Aktion.

Validierungen

Google Ads und die Google Ads API unterstützen eine Vielzahl von Conversion-Aktionen. Daher variieren einige Validierungsregeln je nach type.

Der mit Abstand häufigste Fehler beim Erstellen einer Conversion-Aktion ist DUPLICATE_NAME. Verwenden Sie für jede Conversion-Aktion einen eindeutigen Namen.

Hier sind einige Tipps zum Festlegen der ConversionAction-Felder:

Alle enum-Felder
Der Versuch, ein Enum-Feld auf UNKNOWN festzulegen, führt zu einem RequestError.INVALID_ENUM_VALUE-Fehler.
app_id
Das app_id-Attribut ist unveränderlich und kann nur beim Erstellen einer neuen App-Conversion festgelegt werden.
attribution_model_settings
Wenn Sie diese Option auf eine veraltete Option setzen, wird der Fehler CANNOT_SET_RULE_BASED_ATTRIBUTION_MODELS ausgegeben. In Google Ads werden nur GOOGLE_ADS_LAST_CLICK und GOOGLE_SEARCH_ATTRIBUTION_DATA_DRIVEN unterstützt.
click_through_lookback_window_days

Wenn Sie für dieses Attribut einen Wert außerhalb des zulässigen Bereichs festlegen, wird der Fehler RangeError.TOO_LOW oder RangeError.TOO_HIGH ausgegeben.

Dieses Attribut muss im Bereich [1,60] für eine AD_CALL- oder WEBSITE_CALL-Conversion-Aktion liegen. Bei den meisten anderen Conversion-Aktionen beträgt der zulässige Bereich [1,30].

include_in_conversions_metric

Wenn Sie diesen Wert in einem create- oder update-Vorgang festlegen, schlägt der Vorgang mit einem FieldError.IMMUTABLE_FIELD-Fehler fehl. Legen Sie stattdessen primary_for_goal wie im Leitfaden zu Conversion-Zielvorhaben beschrieben fest.

phone_call_duration_seconds

Wenn Sie versuchen, dieses Attribut für eine Conversion-Aktion festzulegen, die nicht für Anrufe bestimmt ist, wird der Fehler FieldError.VALUE_MUST_BE_UNSET ausgegeben.

type

Das type-Attribut ist unveränderlich und kann nur beim Erstellen einer neuen Conversion festgelegt werden.

Wenn Sie eine Conversion-Aktion aktualisieren, bei der type = UNKNOWN ist, führt das zu einem MutateError.MUTATE_NOT_ALLOWED-Fehler.

value_settings

Für die value_settings einer WEBSITE_CALL- oder AD_CALL-Conversion-Aktion muss always_use_default_value auf true festgelegt sein. Wenn Sie beim Erstellen oder Aktualisieren dieses Werts false angeben, führt das zu einem INVALID_VALUE-Fehler.

view_through_lookback_window_days

Wenn Sie für dieses Attribut einen Wert außerhalb des zulässigen Bereichs festlegen, wird der Fehler RangeError.TOO_LOW oder RangeError.TOO_HIGH ausgegeben. Für die meisten Conversion-Aktionen ist der zulässige Bereich [1,30].

Dieses Attribut kann nicht für AD_CALL- oder WEBSITE_CALL-Conversion-Aktionen festgelegt werden. Wenn Sie einen Wert angeben, wird der Fehler VALUE_MUST_BE_UNSET ausgegeben.