Kampagne für Anzeigen mit möglichen Aktivitäten erstellen

Als Erstes müssen Sie eine Kampagne für Anzeigen mit möglichen Aktivitäten erstellen. Beim Erstellen der Kampagne konfigurieren Sie das Budget, die Gebotsstrategie, die Einstellungen für Werbenetzwerke und die Konto-ID für das Things to do Center.

Schritte zur Kampagneneinrichtung

So konfigurieren Sie eine Kampagne für Anzeigen mit möglichen Aktivitäten:

  1. Erstellen Sie ein CampaignBudget (gemeinsam oder nicht gemeinsam genutzt) mit einem STANDARD delivery_method (ACCELERATED-Bereitstellung wird nicht unterstützt) und weisen Sie den zugehörigen Ressourcennamen campaign_budget zu (siehe add_campaign_budget im vollständigen Codebeispiel).
  2. Setzen Sie den advertising_channel_type der Kampagne auf TRAVEL und den advertising_channel_sub_type auf TRAVEL_ACTIVITIES.
  3. Erstellen Sie ein TravelCampaignSettings-Objekt, legen Sie die travel_account_id auf Ihre Things to do Center-Konto-ID fest (siehe Voraussetzungen) und weisen Sie es der Kampagne zu.
  4. Konfigurieren Sie für die Kampagne eine standardmäßige Gebotsstrategie (auf Kampagnenebene) vom Typ MaximizeConversionValue mit dem Wert target_roas (erforderlich; Portfolio-Gebotsstrategien werden nicht unterstützt), aktivieren Sie das Targeting für die Google Suche (network_settings.target_google_search = true) und deklarieren Sie den Status contains_eu_political_advertising der Kampagne.

Codebeispiel

Das folgende Codebeispiel zeigt, wie Sie eine Kampagne für Anzeigen mit möglichen Aktivitäten erstellen (vollständiges Codebeispiel für die Budgeterstellung):

Java

private String addThingsToDoCampaign(
    GoogleAdsClient googleAdsClient,
    long customerId,
    String budgetResourceName,
    long thingsToDoCenterAccountId) {
  // Creates the campaign.
  Campaign campaign =
      Campaign.newBuilder()
          .setName("Interplanetary Cruise #" + getPrintableDateTime())
          // Configures settings related to Things to do campaigns including advertising channel
          // type, advertising channel sub type and travel campaign settings.
          .setAdvertisingChannelType(AdvertisingChannelType.TRAVEL)
          .setAdvertisingChannelSubType(AdvertisingChannelSubType.TRAVEL_ACTIVITIES)
          .setTravelCampaignSettings(
              TravelCampaignSettings.newBuilder().setTravelAccountId(thingsToDoCenterAccountId))
          // Recommendation: Sets the campaign to PAUSED when creating it to prevent
          // the ads from immediately serving. Set to ENABLED once you've added
          // targeting and the ads are ready to serve
          .setStatus(CampaignStatus.PAUSED)
          // Sets the bidding strategy to MaximizeConversionValue. Only this type can be used
          // for Things to do campaigns.
          .setMaximizeConversionValue(MaximizeConversionValue.newBuilder())
          // Sets the budget.
          .setCampaignBudget(budgetResourceName)
          // Configures the campaign network options. Only Google Search is allowed for
          // Things to do campaigns.
          .setNetworkSettings(NetworkSettings.newBuilder().setTargetGoogleSearch(true))
          // Declares whether this campaign serves political ads targeting the EU.
          .setContainsEuPoliticalAdvertising(DOES_NOT_CONTAIN_EU_POLITICAL_ADVERTISING)
          .build();

  // Creates a campaign operation.
  CampaignOperation operation = CampaignOperation.newBuilder().setCreate(campaign).build();

  // Issues a mutate request to add the campaign.
  try (CampaignServiceClient campaignServiceClient =
      googleAdsClient.getLatestVersion().createCampaignServiceClient()) {
    MutateCampaignsResponse response =
        campaignServiceClient.mutateCampaigns(
            Long.toString(customerId), Collections.singletonList(operation));
    MutateCampaignResult result = response.getResults(0);
    System.out.printf(
        "Added a Things to do campaign with resource name: '%s'%n", result.getResourceName());
    return result.getResourceName();
  }
}
      

C#

// Creates a campaign.
Campaign campaign = new Campaign()
{
    Name = "Interplanetary Cruise #" + ExampleUtilities.GetRandomString(),
    AdvertisingChannelType = AdvertisingChannelType.Travel,
    AdvertisingChannelSubType = AdvertisingChannelSubType.TravelActivities,

    TravelCampaignSettings = new TravelCampaignSettings()
    {
        TravelAccountId = thingsToDoCenterAccountId
    },

    // Recommendation: Set the campaign to PAUSED when creating it to prevent
    // the ads from immediately serving. Set to ENABLED once you've added
    // targeting and the ads are ready to serve
    Status = CampaignStatus.Paused,

    // Set the bidding strategy and budget.
    MaximizeConversionValue = new MaximizeConversionValue(),
    CampaignBudget = budget,

    // Set the campaign network options.
    NetworkSettings = new NetworkSettings
    {
        TargetGoogleSearch = true
    },

    // Declare whether or not this campaign contains political ads targeting the EU.
    ContainsEuPoliticalAdvertising = EuPoliticalAdvertisingStatus.DoesNotContainEuPoliticalAdvertising,
};
      

PHP

    private static function addThingsToDoCampaign(
        GoogleAdsClient $googleAdsClient,
        int $customerId,
        string $budgetResourceName,
        int $thingsToDoCenterAccountId
    ) {
        // Creates a campaign.
        $campaign = new Campaign(
            [
            'name' => 'Interplanetary Cruise Campaign #' . Helper::getPrintableDatetime(),
            // Configures settings related to Things to do campaigns including advertising channel
            // type, advertising channel sub type and travel campaign settings.
            'advertising_channel_type' => AdvertisingChannelType::TRAVEL,
            'advertising_channel_sub_type' => AdvertisingChannelSubType::TRAVEL_ACTIVITIES,
            'travel_campaign_settings'
                => new TravelCampaignSettings(['travel_account_id' => $thingsToDoCenterAccountId]),
            // Recommendation: Set the campaign to PAUSED when creating it to prevent
            // the ads from immediately serving. Set to ENABLED once you've added
            // targeting and the ads are ready to serve.
            'status' => CampaignStatus::PAUSED,
            // Sets the bidding strategy to MaximizeConversionValue. Only this type can be used
            // for Things to do campaigns.
            'maximize_conversion_value' => new MaximizeConversionValue(),
            // Sets the budget.
            'campaign_budget' => $budgetResourceName,
            // Configures the campaign network options. Only Google Search is allowed for
            // Things to do campaigns.
            'network_settings' => new NetworkSettings(['target_google_search' => true]),
            // Declare whether or not this campaign serves political ads targeting the EU.
            'contains_eu_political_advertising' =>
                EuPoliticalAdvertisingStatus::DOES_NOT_CONTAIN_EU_POLITICAL_ADVERTISING
            ]
        );

        // Creates a campaign operation.
        $campaignOperation = new CampaignOperation();
        $campaignOperation->setCreate($campaign);

        // Issues a mutate request to add campaigns.
        $campaignServiceClient = $googleAdsClient->getCampaignServiceClient();
        $response = $campaignServiceClient->mutateCampaigns(
            MutateCampaignsRequest::build($customerId, [$campaignOperation])
        );

        /**
 * @var Campaign $addedCampaign
*/
        $addedCampaign = $response->getResults()[0];
        printf(
            "Added a Things to do campaign with resource name '%s'.%s",
            $addedCampaign->getResourceName(),
            PHP_EOL
        );

        return $addedCampaign->getResourceName();
    }
      

Python

def add_things_to_do_campaign(
    client: GoogleAdsClient,
    customer_id: str,
    budget_resource_name: str,
    things_to_do_center_account_id: int,
) -> str:
    """Creates a new Things to do campaign in the specified customer account.

    Args:
        client: an initialized GoogleAdsClient instance.
        customer_id: a client customer ID.
        budget_resource_name: the resource name of a budget for a new campaign.
        things_to_do_center_account_id: the Things to Do Center account ID.

    Returns:
        The resource name of the newly created campaign.
    """
    # Creates a campaign operation.
    operation: CampaignOperation = client.get_type("CampaignOperation")
    # Creates a campaign.
    campaign: Campaign = operation.create
    campaign.name = (
        f"Interplanetary Cruise Campaign #{get_printable_datetime()}"
    )
    # Configures settings related to Things to do campaigns including
    # advertising channel type, advertising channel sub type and travel
    # campaign settings.
    campaign.advertising_channel_type = (
        client.enums.AdvertisingChannelTypeEnum.TRAVEL
    )
    campaign.advertising_channel_sub_type = (
        client.enums.AdvertisingChannelSubTypeEnum.TRAVEL_ACTIVITIES
    )
    campaign.travel_campaign_settings.travel_account_id = (
        things_to_do_center_account_id
    )
    # Recommendation: Set the campaign to PAUSED when creating it to prevent
    # the ads from immediately serving. Set to ENABLED once you've added
    # targeting and the ads are ready to serve.
    campaign.status = client.enums.CampaignStatusEnum.PAUSED
    # Sets the bidding strategy to MaximizeConversionValue. Only this type can
    # be used for Things to do campaigns.
    campaign.maximize_conversion_value = client.get_type(
        "MaximizeConversionValue"
    )
    # Sets the budget.
    campaign.campaign_budget = budget_resource_name
    # Configures the campaign network options. Only Google Search is allowed for
    # Things to do campaigns.
    campaign.network_settings.target_google_search = True
    # Declare whether or not this campaign serves political ads targeting the
    # EU. Valid values are:
    #   CONTAINS_EU_POLITICAL_ADVERTISING
    #   DOES_NOT_CONTAIN_EU_POLITICAL_ADVERTISING
    campaign.contains_eu_political_advertising = (
        client.enums.EuPoliticalAdvertisingStatusEnum.DOES_NOT_CONTAIN_EU_POLITICAL_ADVERTISING
    )

    # Issues a mutate request to add campaigns.
    campaign_service: CampaignServiceClient = client.get_service(
        "CampaignService"
    )
    response: MutateCampaignsResponse = campaign_service.mutate_campaigns(
        customer_id=customer_id, operations=[operation]
    )

    resource_name: str = response.results[0].resource_name
    print(
        f"Added a Things to do campaign with resource name: '{resource_name}'."
    )
    return resource_name
      

Ruby

def add_things_to_do_campaign(client, customer_id, budget_resource,
  things_to_do_center_account_id)

  # Create a campaign.
  campaign_operation = client.operation.create_resource.campaign do |c|
    c.name = generate_random_name_field("Interplanetary Cruise Campaign")

    #  Configures settings related to Things to Do campaigns including
    # advertising channel type, advertising channel sub type and
    # travel campaign settings.
    c.advertising_channel_type = :TRAVEL
    c.advertising_channel_sub_type = :TRAVEL_ACTIVITIES

    c.travel_campaign_settings = client.resource.travel_campaign_settings do |tcs|
      tcs.travel_account_id = things_to_do_center_account_id
    end

    # Recommendation: Set the campaign to PAUSED when creating it to prevent the
    # ads from immediately serving. Set to ENABLED once you've added targeting
    # and the ads are ready to serve.
    c.status = :PAUSED

    # Sets the bidding strategy to MaximizeConversionValue. Only this type can
    # be used for Things to Do campaigns.
    c.maximize_conversion_value = client.resource.maximize_conversion_value

    # Set the budget.
    c.campaign_budget = budget_resource

    # Configures the campaign network options. Only Google Search is allowed for
    # Things to Do campaigns.
    c.network_settings = client.resource.network_settings do |ns|
      ns.target_google_search = true
    end

    # Declare whether or not this campaign serves political ads targeting the EU.
    # Valid values are CONTAINS_EU_POLITICAL_ADVERTISING and
    # DOES_NOT_CONTAIN_EU_POLITICAL_ADVERTISING.
    c.contains_eu_political_advertising = :DOES_NOT_CONTAIN_EU_POLITICAL_ADVERTISING
  end

  # Issue a mutate request to add the campaign.
  campaign_service = client.service.campaign
  response = campaign_service.mutate_campaigns(
    customer_id: customer_id,
    operations: [campaign_operation],
  )

  # Fetch the new campaign's resource name.
  campaign_resource = response.results.first.resource_name

  puts "Added Things To Do campaign with resource name '#{campaign_resource}'."

  campaign_resource
end
      

Perl

sub add_things_to_do_campaign {
  my ($api_client, $customer_id, $budget_resource_name,
    $things_to_do_center_account_id)
    = @_;

  # Create a campaign.
  my $campaign = Google::Ads::GoogleAds::V25::Resources::Campaign->new({
      name => "Interplanetary Cruise Campaign #" . uniqid(),
      # Configure settings related to Things to do campaigns including
      # advertising channel type, advertising channel sub type and travel
      # campaign settings.
      advertisingChannelType    => TRAVEL,
      advertisingChannelSubType => TRAVEL_ACTIVITIES,
      travelCampaignSettings    =>
        Google::Ads::GoogleAds::V25::Resources::TravelCampaignSettings->new({
          travelAccountId => $things_to_do_center_account_id
        }
        ),
      # Recommendation: Set the campaign to PAUSED when creating it to prevent
      # the ads from immediately serving. Set to ENABLED once you've added
      # targeting and the ads are ready to serve.
      status => Google::Ads::GoogleAds::V25::Enums::CampaignStatusEnum::PAUSED,
      # Set the bidding strategy to MaximizeConversionValue. Only this type can be
      # used for Things to do campaigns.
      maximizeConversionValue =>
        Google::Ads::GoogleAds::V25::Common::MaximizeConversionValue->new(),
      # Set the budget.
      campaignBudget => $budget_resource_name,
      # Declare whether or not this campaign serves political ads targeting the EU.
      # Valid values are CONTAINS_EU_POLITICAL_ADVERTISING and
      # DOES_NOT_CONTAIN_EU_POLITICAL_ADVERTISING.
      containsEuPoliticalAdvertising =>
        DOES_NOT_CONTAIN_EU_POLITICAL_ADVERTISING,
      # Configure the campaign network options. Only Google Search is allowed for
      # Things to do campaigns.
      networkSettings =>
        Google::Ads::GoogleAds::V25::Resources::NetworkSettings->new({
          targetGoogleSearch => "true"
        })});

  # Create a campaign operation.
  my $campaign_operation =
    Google::Ads::GoogleAds::V25::Services::CampaignService::CampaignOperation->
    new({create => $campaign});

  # Add the campaign.
  my $campaign_resource_name = $api_client->CampaignService()->mutate({
      customerId => $customer_id,
      operations => [$campaign_operation]})->{results}[0]{resourceName};

  printf "Added a Things to do campaign with resource name: '%s'.\n",
    $campaign_resource_name;

  return $campaign_resource_name;
}
      

curl

Nächste Schritte

Nachdem Sie eine Kampagne erstellt haben, müssen Sie mindestens eine Anzeigengruppe und eine Anzeige erstellen: