动态搜索广告

借助动态搜索广告,您可以定位整个网站或其中的某些部分,而不需要为所有可能的匹配创建关键字和广告文案。只要出现相关用户搜索,系统即会动态地生成广告,其中广告标题基于具体的查询,广告文字则基于最相关的着陆页。这些广告将进入竞价,正常参与竞争。因此,您无需对现有关键字广告系列做出任何更改,就能向更广泛的受众展示更多有库存的产品,进而取得更理想的效果。

除了让您更广泛地定位到整个网站或网域,动态搜索广告还可以作为您现有广告系列和关键字的很好的补充或备用选项。您可以按照目前所用的方式设置关键字、广告组和广告文案,然后添加动态搜索广告,以尽可能收集与现有广告系列设置不匹配的查询。

本指南介绍了如何使用 AdWords API 创建和使用动态搜索广告。

创建动态搜索广告

要使用 API 设置动态搜索广告,请按以下步骤操作:

  1. 设置广告系列,并指定其网域。
  2. 创建一个广告组,以使用动态搜索广告的相关功能。
  3. 创建一个或多个动态搜索广告。
  4. 在广告系列中指定展示动态搜索广告的一个或多个条件。

设置您的广告系列

要告知 AdWords 您要在广告系列中使用动态搜索广告,首先需要创建一个 advertisingChannelTypeSEARCH 的广告系列。另外,您还需指定要投放动态搜索广告的网域。通过在 Campaign 对象的 settings 属性中设置 DynamicSearchAdsSetting 对象,可达到这一目的。

以下示例创建了一个动态搜索广告系列。

C#

private static Campaign CreateCampaign(AdWordsUser user, Budget budget) {
  // Get the CampaignService.
  CampaignService campaignService =
    (CampaignService) user.GetService(AdWordsService.v201705.CampaignService);

  // Create a Dynamic Search Ads campaign.
  Campaign campaign = new Campaign();
  campaign.name = "Interplanetary Cruise #" + ExampleUtilities.GetRandomString();
  campaign.advertisingChannelType = AdvertisingChannelType.SEARCH;

  // 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 = CampaignStatus.PAUSED;

  BiddingStrategyConfiguration biddingConfig = new BiddingStrategyConfiguration();
  biddingConfig.biddingStrategyType = BiddingStrategyType.MANUAL_CPC;
  campaign.biddingStrategyConfiguration = biddingConfig;

  campaign.budget = new Budget();
  campaign.budget.budgetId = budget.budgetId;

  // Required: Set the campaign's Dynamic Search Ads settings.
  DynamicSearchAdsSetting dynamicSearchAdsSetting = new DynamicSearchAdsSetting();
  // Required: Set the domain name and language.
  dynamicSearchAdsSetting.domainName = "example.com";
  dynamicSearchAdsSetting.languageCode = "en";

  // Set the campaign settings.
  campaign.settings = new Setting[] { dynamicSearchAdsSetting };

  // Optional: Set the start date.
  campaign.startDate = DateTime.Now.AddDays(1).ToString("yyyyMMdd");

  // Optional: Set the end date.
  campaign.endDate = DateTime.Now.AddYears(1).ToString("yyyyMMdd");

  // Create the operation.
  CampaignOperation operation = new CampaignOperation();
  operation.@operator = Operator.ADD;
  operation.operand = campaign;

  try {
    // Add the campaign.
    CampaignReturnValue retVal = campaignService.mutate(new CampaignOperation[] { operation });

    // Display the results.
    Campaign newCampaign = retVal.value[0];
    Console.WriteLine("Campaign with id = '{0}' and name = '{1}' was added.",
      newCampaign.id, newCampaign.name);
    return newCampaign;
  } catch (Exception e) {
    throw new System.ApplicationException("Failed to add campaigns.", e);
  }
}

Java

private static Campaign createCampaign(
    AdWordsServicesInterface adWordsServices, AdWordsSession session, Budget budget)
    throws RemoteException, ApiException {
  // Get the CampaignService.
  CampaignServiceInterface campaignService =
      adWordsServices.get(session, CampaignServiceInterface.class);

  // Create campaign.
  Campaign campaign = new Campaign();
  campaign.setName("Interplanetary Cruise #" + System.currentTimeMillis());
  campaign.setAdvertisingChannelType(AdvertisingChannelType.SEARCH);

  // 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.setStatus(CampaignStatus.PAUSED);

  BiddingStrategyConfiguration biddingStrategyConfiguration = new BiddingStrategyConfiguration();
  biddingStrategyConfiguration.setBiddingStrategyType(BiddingStrategyType.MANUAL_CPC);
  campaign.setBiddingStrategyConfiguration(biddingStrategyConfiguration);

  // Only the budgetId should be sent, all other fields will be ignored by CampaignService.
  Budget campaignBudget = new Budget();
  campaignBudget.setBudgetId(budget.getBudgetId());
  campaign.setBudget(campaignBudget);

  // Required: Set the campaign's Dynamic Search Ads settings.
  DynamicSearchAdsSetting dynamicSearchAdsSetting = new DynamicSearchAdsSetting();
  // Required: Set the domain name and language.
  dynamicSearchAdsSetting.setDomainName("example.com");
  dynamicSearchAdsSetting.setLanguageCode("en");

  // Set the campaign settings.
  campaign.setSettings(new Setting[] {dynamicSearchAdsSetting});

  // Optional: Set the start date.
  campaign.setStartDate(new DateTime().plusDays(1).toString("yyyyMMdd"));
  // Optional: Set the end date.
  campaign.setEndDate(new DateTime().plusYears(1).toString("yyyyMMdd"));

  // Create the operation.
  CampaignOperation operation = new CampaignOperation();
  operation.setOperand(campaign);
  operation.setOperator(Operator.ADD);

  // Add the campaign.
  Campaign newCampaign = campaignService.mutate(new CampaignOperation[] {operation}).getValue(0);

  // Display the results.
  System.out.printf(
      "Campaign with name '%s' and ID %d was added.%n",
      newCampaign.getName(), newCampaign.getId());

  return newCampaign;
}

Python

campaign_service = client.GetService('CampaignService')

operations = [{
    'operator': 'ADD',
    'operand': {
        'name': 'Interplanetary Cruise #%d' % uuid.uuid4(),
        # 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': 'PAUSED',
        'advertisingChannelType': 'SEARCH',
        'biddingStrategyConfiguration': {
            'biddingStrategyType': 'MANUAL_CPC',
        },
        'budget': budget,
        # Required: Set the campaign's Dynamic Search Ad settings.
        'settings': [{
            'xsi_type': 'DynamicSearchAdsSetting',
            # Required: Set the domain name and language.
            'domainName': 'example.com',
            'languageCode': 'en'
        }],
        # Optional: Set the start date.
        'startDate': (datetime.datetime.now() +
                      datetime.timedelta(1)).strftime('%Y%m%d'),
        # Optional: Set the end date.
        'endDate': (datetime.datetime.now() +
                    datetime.timedelta(365)).strftime('%Y%m%d'),
    }
}]

campaign = campaign_service.mutate(operations)['value'][0]
campaign_id = campaign['id']

print 'Campaign with ID "%d" and name "%s" was added.' % (
    campaign_id, campaign['name'])

PHP

private static function createCampaign(AdWordsServices $adWordsServices,
    AdWordsSession $session, Budget $budget) {
  $campaignService = $adWordsServices->get($session, CampaignService::class);

  // Create campaign with some properties set.
  $campaign = new Campaign();
  $campaign->setName('Interplanetary Cruise #' . uniqid());
  $campaign->setAdvertisingChannelType(AdvertisingChannelType::SEARCH);

  // 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->setStatus(CampaignStatus::PAUSED);

  $biddingStrategyConfiguration = new BiddingStrategyConfiguration();
  $biddingStrategyConfiguration->setBiddingStrategyType(
      BiddingStrategyType::MANUAL_CPC);
  $campaign->setBiddingStrategyConfiguration($biddingStrategyConfiguration);

  // Only the budgetId should be sent, all other fields will be ignored by
  // CampaignService.
  $campaignBudget = new Budget();
  $campaignBudget->setBudgetId($budget->getBudgetId());
  $campaign->setBudget($campaignBudget);

  // Required: Set the campaign's Dynamic Search Ads settings.
  $dynamicSearchAdsSetting = new DynamicSearchAdsSetting();
  // Required: Set the domain name and language.
  $dynamicSearchAdsSetting->setDomainName('example.com');
  $dynamicSearchAdsSetting->setLanguageCode('en');

  // Set the campaign settings.
  $campaign->setSettings([$dynamicSearchAdsSetting]);

  // Optional: Set the start date.
  $campaign->setStartDate(date('Ymd', strtotime('+1 day')));
  // Optional: Set the end date.
  $campaign->setEndDate(date('Ymd', strtotime('+1 year')));

  // Create a campaign operation.
  $operation = new CampaignOperation();
  $operation->setOperand($campaign);
  $operation->setOperator(Operator::ADD);

  // Create the campaign on the server and print out some information.
  $result = $campaignService->mutate([$operation]);
  $campaign = $result->getValue()[0];
  printf("Campaign with name '%s' and ID %d was added.\n",
      $campaign->getName(), $campaign->getId());

  return $campaign;
}

Perl

# Creates the campaign.
sub _create_campaign {
  my ($client, $budget) = @_;

  # Required: Set the campaign's Dynamic Search Ads settings.
  my $dynamic_search_ads_setting =
    Google::Ads::AdWords::v201705::DynamicSearchAdsSetting->new({
      # Required: Set the domain name and language.
      domainName   => "example.com",
      languageCode => "en"
    });

  # Calculating a start date of today and an end date 1 year from now.
  my (undef, undef, undef, $mday, $mon, $year) = localtime(time + 60 * 60 * 24);
  my $start_date = sprintf("%d%02d%02d", ($year + 1900), ($mon + 1), $mday);
  (undef, undef, undef, $mday, $mon, $year) =
    localtime(time + 60 * 60 * 24 * 365);
  my $end_date = sprintf("%d%02d%02d", ($year + 1900), ($mon + 1), $mday);

  my $campaign = Google::Ads::AdWords::v201705::Campaign->new({
      name => sprintf("Interplanetary Cruise #%s", uniqid()),
      biddingStrategyConfiguration =>
        Google::Ads::AdWords::v201705::BiddingStrategyConfiguration->new({
          biddingStrategyType => "MANUAL_CPC"
        }
        ),
      # Only the budgetId should be sent, all other fields will be ignored by
      # CampaignService.
      budget => Google::Ads::AdWords::v201705::Budget->new(
        {budgetId => $budget->get_budgetId()}
      ),
      advertisingChannelType => "SEARCH",
      settings               => [$dynamic_search_ads_setting],
      # Additional properties (non-required).
      startDate => $start_date,
      endDate   => $end_date,
      # Recommendation: Set the campaign to PAUSED when creating it to stop
      # the ads from immediately serving. Set to ENABLED once you've added
      # targeting and the ads are ready to serve.
      status => "PAUSED"
    });

  # Create operation.
  my $campaign_operation =
    Google::Ads::AdWords::v201705::CampaignOperation->new({
      operator => "ADD",
      operand  => $campaign
    });

  # Add campaigns.
  my $result =
    $client->CampaignService()->mutate({operations => [$campaign_operation]});

  # Display campaigns.
  my $new_campaign = $result->get_value()->[0];
  printf "Campaign with name '%s' and ID %d was added.\n",
    $new_campaign->get_name(),
    $new_campaign->get_id();
  return $new_campaign;
}

Ruby

def create_campaign(adwords, budget)
  campaign_srv = adwords.service(:CampaignService, API_VERSION)

  campaign = {
    :name => "Interplanetary Cruise #%d" % (Time.now.to_f * 1000).to_i,
    :advertising_channel_type => 'SEARCH',
    # 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 => 'PAUSED',
    :bidding_strategy_configuration => {
      :bidding_strategy_type => 'MANUAL_CPC'
    },
    # Only the budgetId should be sent; all other fields will be ignored by
    # CampaignService.
    :budget => {
      :budget_id => budget[:budget_id]
    },
    :settings => [
      :xsi_type => 'DynamicSearchAdsSetting',
      :domain_name => 'example.com',
      :language_code => 'en'
    ],
    # Optional: Set the start and end dates.
    :start_date => DateTime.parse((Date.today + 1).to_s).strftime('%Y%m%d'),
    :end_date => DateTime.parse(Date.today.next_year.to_s).strftime('%Y%m%d')
  }

  operation = {
    :operand => campaign,
    :operator => 'ADD'
  }

  new_campaign = campaign_srv.mutate([operation])[:value].first
  puts "Campaign with name '%s' and ID %d was added." %
      [new_campaign[:name], new_campaign[:id]]

  return new_campaign
end

在广告系列中停用动态搜索广告

要在广告系列一级关闭动态搜索广告,无需暂停整个广告系列,只需更新 DynamicSearchAdsSetting 的值并将 domainName 设置为 "-" 即可。您仍需要指定语言代码。

创建广告组

AdWords API v201705 为动态搜索广告引入了新的广告组类型。此广告组类型的 adGroupTypeAdGroupType.SEARCH_DYNAMIC_ADS,且会实施以下限制:

  • 此广告组类型只能添加到搜索广告系列。
  • 在广告系列一级应该有一个有效 DynamicSearchAdsSetting,以便添加广告组。如果缺少此设置,将会导致 AdGroupServiceError.CANNOT_ADD_ADGROUP_OF_TYPE_DSA_TO_CAMPAIGN_WITHOUT_DSA_SETTING 错误。
  • 此广告组类型中不得包含肯定关键字,可以包含受众群体、动态广告定位条件和否定关键字。
  • 与所有其他广告组一样,adGroupType 构建完成后便无法更改。
  • 此广告组只能使用与动态搜索广告相关的广告格式。

以下代码示例显示了如何创建 SEARCH_DYNAMIC_ADS 广告组。

C#

private static AdGroup CreateAdGroup(AdWordsUser user, long campaignId) {
  // Get the AdGroupService.
  AdGroupService adGroupService =
      (AdGroupService) user.GetService(AdWordsService.v201705.AdGroupService);

  // Create the ad group.
  AdGroup adGroup = new AdGroup();

  // Required: Set the ad group's type to Dynamic Search Ads.
  adGroup.adGroupType = AdGroupType.SEARCH_DYNAMIC_ADS;

  adGroup.name = string.Format("Earth to Mars Cruises #{0}",
    ExampleUtilities.GetRandomString());
  adGroup.campaignId = campaignId;
  adGroup.status = AdGroupStatus.PAUSED;

  // Recommended: Set a tracking URL template for your ad group if you want to use URL
  // tracking software.
  adGroup.trackingUrlTemplate = "http://tracker.example.com/traveltracker/{escapedlpurl}";

  // Set the ad group bids.
  BiddingStrategyConfiguration biddingConfig = new BiddingStrategyConfiguration();

  CpcBid cpcBid = new CpcBid();
  cpcBid.bid = new Money();
  cpcBid.bid.microAmount = 3000000;

  biddingConfig.bids = new Bids[] { cpcBid };

  adGroup.biddingStrategyConfiguration = biddingConfig;

  // Create the operation.
  AdGroupOperation operation = new AdGroupOperation();
  operation.@operator = Operator.ADD;
  operation.operand = adGroup;

  try {
    // Create the ad group.
    AdGroupReturnValue retVal = adGroupService.mutate(new AdGroupOperation[] { operation });

    // Display the results.
    AdGroup newAdGroup = retVal.value[0];
    Console.WriteLine("Ad group with id = '{0}' and name = '{1}' was created.",
      newAdGroup.id, newAdGroup.name);
    return newAdGroup;
  } catch (Exception e) {
    throw new System.ApplicationException("Failed to create ad group.", e);
  }
}

Java

private static AdGroup createAdGroup(
    AdWordsServicesInterface adWordsServices, AdWordsSession session, Campaign campaign)
    throws ApiException, RemoteException {
  // Get the AdGroupService.
  AdGroupServiceInterface adGroupService =
      adWordsServices.get(session, AdGroupServiceInterface.class);

  // Create the ad group.
  AdGroup adGroup = new AdGroup();

  // Required: Set the ad group's type to Dynamic Search Ads.
  adGroup.setAdGroupType(AdGroupType.SEARCH_DYNAMIC_ADS);

  adGroup.setName("Earth to Mars Cruises #" + System.currentTimeMillis());
  adGroup.setCampaignId(campaign.getId());
  adGroup.setStatus(AdGroupStatus.PAUSED);

  // Recommended: Set a tracking URL template for your ad group if you want to use URL
  // tracking software.
  adGroup.setTrackingUrlTemplate("http://tracker.example.com/traveltracker/{escapedlpurl}");

  // Set the ad group bids.
  BiddingStrategyConfiguration biddingConfig = new BiddingStrategyConfiguration();

  CpcBid cpcBid = new CpcBid();
  cpcBid.setBid(new Money());
  cpcBid.getBid().setMicroAmount(3000000L);

  biddingConfig.setBids(new Bids[] {cpcBid});

  adGroup.setBiddingStrategyConfiguration(biddingConfig);

  // Create the operation.
  AdGroupOperation operation = new AdGroupOperation();
  operation.setOperand(adGroup);
  operation.setOperator(Operator.ADD);

  AdGroup newAdGroup = adGroupService.mutate(new AdGroupOperation[] {operation}).getValue(0);
  System.out.printf(
      "Ad group with name '%s' and ID %d was added.%n", newAdGroup.getName(), newAdGroup.getId());
  return newAdGroup;
}

Python

ad_group_service = client.GetService('AdGroupService')

operations = [{
    'operator': 'ADD',
    'operand': {
        'campaignId': campaign_id,
        'adGroupType': 'SEARCH_DYNAMIC_ADS',
        'name': 'Earth to Mars Cruises #%d' % uuid.uuid4(),
        'status': 'PAUSED',
        'biddingStrategyConfiguration': {
            'bids': [{
                'xsi_type': 'CpcBid',
                'bid': {
                    'microAmount': '3000000'
                },
            }]
        }
    }
}]

ad_group = ad_group_service.mutate(operations)['value'][0]
ad_group_id = ad_group['id']

print 'Ad group with ID "%d" and name "%s" was created.' % (
    ad_group_id, ad_group['name'])

PHP

private static function createAdGroup(
    AdWordsServices $adWordsServices,
    AdWordsSession $session,
    Campaign $campaign
) {
  $adGroupService = $adWordsServices->get($session, AdGroupService::class);

  // Create the ad group.
  $adGroup = new AdGroup();

  // Required: Set the ad group's type to Dynamic Search Ads.
  $adGroup->setAdGroupType(AdGroupType::SEARCH_DYNAMIC_ADS);

  $adGroup->setName('Interplanetary Cruise #' . uniqid());
  $adGroup->setCampaignId($campaign->getId());
  $adGroup->setStatus(AdGroupStatus::PAUSED);

  // Recommended: Set a tracking URL template for your ad group if you want to
  // use URL tracking software.
  $adGroup->setTrackingUrlTemplate(
      'http://tracker.example.com/traveltracker/{escapedlpurl}');

  // Set the ad group bids.
  $biddingStrategyConfiguration = new BiddingStrategyConfiguration();

  $cpcBid = new CpcBid();
  $money = new Money();
  $money->setMicroAmount(3000000);
  $cpcBid->setBid($money);
  $biddingStrategyConfiguration->setBids([$cpcBid]);

  $adGroup->setBiddingStrategyConfiguration($biddingStrategyConfiguration);

  // Create an ad group operation.
  $operation = new AdGroupOperation();
  $operation->setOperand($adGroup);
  $operation->setOperator(Operator::ADD);

  // Create the ad group on the server and print out some information.
  $result = $adGroupService->mutate([$operation]);
  $adGroup = $result->getValue()[0];
  printf("Ad group with name '%s' and ID %d was added.\n",
      $adGroup->getName(), $adGroup->getId());

  return $adGroup;
}

Perl

# Creates the ad group.
sub _create_ad_group {
  my ($client, $campaign) = @_;

  my $ad_group = Google::Ads::AdWords::v201705::AdGroup->new({
      name       => sprintf("Earth to Mars Cruises #%s", uniqid()),
      campaignId => $campaign->get_id(),
      # Required: Set the ad group's type to Dynamic Search Ads.
      adGroupType => "SEARCH_DYNAMIC_ADS",
      status      => "PAUSED",
      # Recommended: Set a tracking URL template for your ad group if you want
      # to use URL tracking software.
      trackingUrlTemplate =>
        "http://tracker.example.com/traveltracker/{escapedlpurl}",
      biddingStrategyConfiguration =>
        Google::Ads::AdWords::v201705::BiddingStrategyConfiguration->new({
          bids => [
            Google::Ads::AdWords::v201705::CpcBid->new({
                bid => Google::Ads::AdWords::v201705::Money->new(
                  {microAmount => 3000000}
                ),
              }
            ),
          ]})});

  # Create operation.
  my $ad_group_operation =
    Google::Ads::AdWords::v201705::AdGroupOperation->new({
      operator => "ADD",
      operand  => $ad_group
    });

  my $result =
    $client->AdGroupService()->mutate({operations => [$ad_group_operation]});
  my $new_ad_group = $result->get_value()->[0];
  printf "Ad group with name '%s' and ID %d was added.\n",
    $new_ad_group->get_name(), $new_ad_group->get_id();
  return $new_ad_group;
}

Ruby

def create_ad_group(adwords, campaign)
  ad_group_srv = adwords.service(:AdGroupService, API_VERSION)

  ad_group = {
    # Required: Set the ad group's tpe to Dynamic Search Ads.
    :ad_group_type => 'SEARCH_DYNAMIC_ADS',
    :name => "Earth to Mars Cruises #%d" % (Time.now.to_f * 1000).to_i,
    :campaign_id => campaign[:id],
    :status => 'PAUSED',
    # Recommended: Set a tracking URL template for your ad group if you want to
    # use URL tracking software.
    :tracking_url_template =>
        'http://tracker.example.com/traveltracker/{escapedlpurl}',
    :bidding_strategy_configuration => {
      :bids => [{
        :xsi_type => 'CpcBid',
        :bid => {
          :micro_amount => 3_000_000
        }
      }]
    }
  }

  operation = {
    :operand => ad_group,
    :operator => 'ADD'
  }

  new_ad_group = ad_group_srv.mutate([operation])[:value].first
  puts "Ad group with name '%s' and ID %d was added." %
      [new_ad_group[:name], new_ad_group[:id]]

  return new_ad_group
end

创建动态搜索广告

下一步是创建一个 ExpandedDynamicSearchAd 对象。系统将根据广告系列级的 DynamicSearchAdsSetting 提供的域名特定信息,在投放相应广告时自动生成其标题、显示网址和最终到达网址。您需要提供该广告的 description

C#

private static ExpandedDynamicSearchAd CreateExpandedDSA(AdWordsUser user, long adGroupId) {
  // Get the AdGroupAdService.
  AdGroupAdService service =
    (AdGroupAdService) user.GetService(AdWordsService.v201705.AdGroupAdService);

  // Create an Expanded Dynamic Search Ad. This ad will have its headline, display URL and
  // final URL auto-generated at serving time according to domain name specific information
  // provided by DynamicSearchAdsSetting at the campaign level.
  ExpandedDynamicSearchAd expandedDSA = new ExpandedDynamicSearchAd();
  // Set the ad description.
  expandedDSA.description = "Buy your tickets now!";

  // Create the ad group ad.
  AdGroupAd adGroupAd = new AdGroupAd();
  adGroupAd.adGroupId = adGroupId;
  adGroupAd.ad = expandedDSA;

  // Optional: Set the status.
  adGroupAd.status = AdGroupAdStatus.PAUSED;

  // Create the operation.
  AdGroupAdOperation operation = new AdGroupAdOperation();
  operation.@operator = Operator.ADD;
  operation.operand = adGroupAd;

  try {
    // Create the ad.
    AdGroupAdReturnValue retval = service.mutate(new AdGroupAdOperation[] { operation });

    // Display the results.
    AdGroupAd newAdGroupAd = retval.value[0];
    ExpandedDynamicSearchAd newAd = newAdGroupAd.ad as ExpandedDynamicSearchAd;
    Console.WriteLine("Expanded Dynamic Search Ad with ID '{0}' and description '{1}' " +
        "was added.", newAd.id, newAd.description);
    return newAd;
  } catch (Exception e) {
    throw new System.ApplicationException("Failed to create Expanded Dynamic Search Ad.", e);
  }
}

Java

private static void createExpandedDSA(
    AdWordsServicesInterface adWordsServices, AdWordsSession session, AdGroup adGroup)
    throws ApiException, RemoteException {
  // Get the AdGroupAdService.
  AdGroupAdServiceInterface adGroupAdService =
      adWordsServices.get(session, AdGroupAdServiceInterface.class);

  // Create the expanded Dynamic Search Ad. This ad will have its headline and final URL
  // auto-generated at serving time according to domain name specific information provided
  // by DynamicSearchAdsSetting at the campaign level.
  ExpandedDynamicSearchAd expandedDSA = new ExpandedDynamicSearchAd();
  // Set the ad description.
  expandedDSA.setDescription("Buy your tickets now!");

  // Create the ad group ad.
  AdGroupAd adGroupAd = new AdGroupAd();
  adGroupAd.setAdGroupId(adGroup.getId());
  adGroupAd.setAd(expandedDSA);

  // Optional: Set the status.
  adGroupAd.setStatus(AdGroupAdStatus.PAUSED);

  // Create the operation.
  AdGroupAdOperation operation = new AdGroupAdOperation();
  operation.setOperator(Operator.ADD);
  operation.setOperand(adGroupAd);

  // Create the ad.
  AdGroupAd newAdGroupAd =
      adGroupAdService.mutate(new AdGroupAdOperation[] {operation}).getValue(0);
  ExpandedDynamicSearchAd newExpandedDSA = (ExpandedDynamicSearchAd) newAdGroupAd.getAd();
  System.out.printf(
      "Expanded Dynamic Search Ad with ID %d and description '%s' was added.%n",
      newExpandedDSA.getId(), newExpandedDSA.getDescription());
}

Python

# Get the AdGroupAdService.
ad_group_ad_service = client.GetService('AdGroupAdService')

# Create the operation
operations = [{
    'operator': 'ADD',
    'operand': {
        'xsi_type': 'AdGroupAd',
        'adGroupId': ad_group_id,
        # Create the expanded dynamic search ad. This ad will have its
        # headline and final URL auto-generated at serving time according to
        # domain name specific information provided by DynamicSearchAdsSetting
        # at the campaign level.
        'ad': {
            'xsi_type': 'ExpandedDynamicSearchAd',
            # Set the ad description.
            'description': 'Buy your tickets now!'
        },
        # Optional: Set the status.
        'status': 'PAUSED',
    }
}]

# Create the ad.
ad = ad_group_ad_service.mutate(operations)['value'][0]['ad']

# Display the results.
print ('Expanded dynamic search ad with ID "%d" and description "%s" was '
       'added' % (ad['id'], ad['description']))

PHP

private static function createExpandedDSA(
    AdWordsServices $adWordsServices,
    AdWordsSession $session,
    AdGroup $adGroup
) {
  $adGroupAdService
      = $adWordsServices->get($session, AdGroupAdService::class);

  // Create the expanded Dynamic Search Ad. This ad will have its headline
  // and final URL auto-generated at serving time according to domain name
  // specific information provided by DynamicSearchAdsSetting at the
  // campaign level.
  $expandedDSA = new ExpandedDynamicSearchAd();
  // Set the ad description.
  $expandedDSA->setDescription('Buy your tickets now!');

  // Create the ad group ad.
  $adGroupAd = new AdGroupAd();
  $adGroupAd->setAdGroupId($adGroup->getId());
  $adGroupAd->setAd($expandedDSA);

  // Optional: Set the status.
  $adGroupAd->setStatus(AdGroupAdStatus::PAUSED);

  // Create the operation.
  $operation = new AdGroupAdOperation();
  $operation->setOperator(Operator::ADD);
  $operation->setOperand($adGroupAd);

  // Create the ad on the server and print some information.
  $result = $adGroupAdService->mutate([$operation]);
  $newAdGroupAd = $result->getValue()[0];
  $expandedDSA = $newAdGroupAd->getAd();
  printf(
      "Expanded Dynamic Search Ad with ID %d and description '%s' was"
          . " added.\n",
      $expandedDSA->getId(),
      $expandedDSA->getDescription()
  );
}

Perl

# Creates the expanded Dynamic Search Ad.
sub _create_expanded_DSA {
  my ($client, $ad_group) = @_;
  # Create the expanded Dynamic Search Ad. This ad will have its headline and
  # final URL auto-generated at serving time according to domain name specific
  # information provided by DynamicSearchAdsSetting at the campaign level.
  my $expanded_DSA =
    Google::Ads::AdWords::v201705::ExpandedDynamicSearchAd->new({
      # Set the ad description.
      description => "Buy your tickets now!",
    });

  # Create the ad group ad.
  my $ad_group_ad = Google::Ads::AdWords::v201705::AdGroupAd->new({
    adGroupId => $ad_group->get_id(),
    ad        => $expanded_DSA,
    # Optional: Set the status.
    status => "PAUSED"
  });

  # Create operation.
  my $operation = Google::Ads::AdWords::v201705::AdGroupAdOperation->new({
    operator => "ADD",
    operand  => $ad_group_ad
  });

  my $result =
    $client->AdGroupAdService()->mutate({operations => [$operation]});
  my $new_ad_group_ad = $result->get_value()->[0];
  my $new_expanded_dsa = $new_ad_group_ad->get_ad();
  printf
    "Expanded Dynamic Search Ad with ID %d and description '%s' was added.\n",
    $new_expanded_dsa->get_id(), $new_expanded_dsa->get_description();
}

Ruby

def create_expanded_dsa(adwords, ad_group)
  ad_group_ad_srv = adwords.service(:AdGroupAdService, API_VERSION)

  # Create the expanded Dynamic Search Ad. This ad will have its headline and
  # final URL auto-generated at serving time according to domain name specific
  # information provided by DynamicSearchAdsSetting at the campaign level.
  expanded_dsa = {
    :xsi_type => 'ExpandedDynamicSearchAd',
    :description => 'Buy your tickets now!'
  }

  ad_group_ad = {
    :ad_group_id => ad_group[:id],
    :ad => expanded_dsa,
    # Optional: Set the status.
    :status => 'PAUSED'
  }

  operation = {
    :operand => ad_group_ad,
    :operator => 'ADD'
  }

  new_ad_group_ad = ad_group_ad_srv.mutate([operation])[:value].first
  new_expanded_dsa = new_ad_group_ad[:ad]
  puts "Expanded Dynamic Search Ad with ID %d and description '%s' was added." %
      [new_expanded_dsa[:id], new_expanded_dsa[:description]]
end

动态搜索广告中的 finalUrls 字段由 AdWords 系统在创建动态搜索广告时计算。因此,创建动态搜索广告时不能设置此字段。要使用网址跟踪软件,您可以使用 trackingUrlTemplate 字段指定需要的其他跟踪参数或重定向。指定此字段时必须包括下列参数之一,以便 AdWords 系统加入匹配到的最终到达网址:

参数 说明
{unescapedlpurl}

非转义的着陆页网址,用于将某些内容添加到末尾,例如:

{unescapedlpurl}?dsa=true

{escapedlpurl}

转义的(网址编码)着陆页网址,用于重定向至某个跟踪器,例如:

http://tracking.com/lp={escapedurl}

{lpurlpath}

只包含来自所计算网址的路径和查询参数,例如:

http://tracking.com.com/track/{lpurlpath}

{lpurl}

对着陆页网址中的 ?= 进行编码,以搜索查询内容结尾。如果位于 trackingUrlTemplate 字段的开头,将被实际替换为 {unescapedurl} 值,例如:

http://tracking.com/redir.php?tracking=xyz&url={lpurl}

例如:

dsa.setTrackingUrlTemplate("http://example.org/traveltracker/{escapedlpurl}");

指定动态搜索广告的条件

最后,您要设置一些触发动态搜索广告投放的条件,通过 Webpage 条件对象可实现这一目的。

对于 Webpage 条件,您要添加 WebpageParameter 对象,其中包含 1 到 3 个 WebpageConditions。通过这些对象,您可以确切指定要在广告系列设置先前指定的网域中过滤或搜索的内容。

可以依据四项条件来过滤网域内的内容:

WebPageConditionOperand 说明
URL 与网页网址的部分内容匹配的字符串。
CATEGORY 要精确匹配的类别字符串。
PAGE_TITLE 与网页标题的部分内容匹配的字符串。
PAGE_CONTENT 与已编入索引的任一给定网页的部分内容匹配的字符串。
CUSTOM_LABEL 与网页自定义标签定位条件匹配的字符串。请参阅 [动态搜索广告页面 Feed](foo) 部分。

举个例子,我们将创建一个网页条件,以在火星度假网站的 /children 分支上搜索任意内容,但搜索范围仅限于标题中有“Special Offer”的网页:

了解自己的网站类别

您可以使用 DataService 获取 Google 认为适用于您的网站的类别列表。可以依据网域或广告系列进行过滤。例如,以下代码在特定广告系列中获取适用于我们网站的类别列表:

DataServiceInterface dataService =
  adWordsServices.get(session, DataServiceInterface.class);

// Create selector.
SelectorBuilder builder = new SelectorBuilder();
Selector selector = builder
    .fields("DomainName", "Category", "IsoLanguage")
    .equals("DomainName", "example.org")
    .equals("CampaignId", campaignId)
    .limit(PAGE_SIZE)
    .build();

DomainCategoryPage page = dataService.getDomainCategory(selector);

排除网站的某些部分

您还可以使用 AdGroupCriterionService 设置 Webpage 排除条件。例如,您可以使用此方法排除要通过另一个广告系列或广告组管理的带特定标题的网页。

其他条件

采用动态搜索广告的广告系列和广告组并非局限于仅使用 Webpage 条件,您可以继续使用其他类型的条件,以进一步优化和提高广告的质量。不过,使用附加条件时应该有明智的判断,因为添加太多条件会降低您通过动态搜索广告进行自动定位的有效性。

动态搜索广告页面 Feed

默认情况下,您可以将动态搜索广告设置为定位整个网站或网站的某些部分,而无需关注具体的网页网址。如果您需要更有效地控制网址,则可以使用动态搜索广告页面 Feed 来精确指定要在动态搜索广告中使用哪些网址。如果您提供产品及其着陆页的页面 Feed,将有助于 AdWords 确定何时展示您的广告以及将用户引导至您网站上的什么位置。

要设置动态搜索广告页面 Feed,请执行以下操作:

  1. 创建一个 Feed 并向其中填充网页网址。
  2. 设置广告系列,以使用动态搜索广告页面 Feed。
  3. 建议:为页面 Feed 中的网址添加自定义标签,以对您的动态搜索广告定位条件进行分类和整理。

创建页面 Feed

使用动态搜索广告页面 Feed 的第一步是创建一个 Feed,其中 criterionType = 61。该流程与我们的 Feed 服务指南中列出的流程类似,但存在以下差异:

  1. 您只需要创建 Feed,填充各项,然后将相应 Feed 映射到页面 Feed 占位符字段
  2. 动态搜索广告页面 Feed 使用 criterionType 字段,而不是 placeholderType 字段。

要查看工作示例,请参阅我们的代码示例部分

针对页面 Feed 设置广告系列

通过为动态搜索广告系列的 DynamicSearchAdSetting 设置 pagefeed 属性,您可以将相应广告系列设置为使用页面 Feed。

首先,检索动态搜索广告系列的 DynamicSearchAdSetting

C#

// Get the CampaignService.
CampaignService campaignService = (CampaignService) user.GetService(
    AdWordsService.v201705.CampaignService);

Selector selector = new Selector() {
  fields = new string[] { Campaign.Fields.Id, Campaign.Fields.Settings },
  predicates = new Predicate[]{
    Predicate.Equals(Campaign.Fields.Id, campaignId)
  },
  paging = Paging.Default
};

CampaignPage page = campaignService.get(selector);

if (page == null || page.entries == null || page.entries.Length == 0) {
  throw new System.ApplicationException(string.Format(
      "Failed to retrieve campaign with ID = {0}.", campaignId));
}
Campaign campaign = page.entries[0];

if (campaign.settings == null) {
  throw new System.ApplicationException("This is not a DSA campaign.");
}

DynamicSearchAdsSetting dsaSetting = null;
Setting[] campaignSettings = campaign.settings;

for (int i = 0; i < campaign.settings.Length; i++) {
  Setting setting = campaignSettings[i];
  if (setting is DynamicSearchAdsSetting) {
    dsaSetting = (DynamicSearchAdsSetting) setting;
    break;
  }
}

if (dsaSetting == null) {
  throw new System.ApplicationException("This is not a DSA campaign.");
}

Java

// Get the CampaignService.
CampaignServiceInterface campaignService =
    adWordsServices.get(session, CampaignServiceInterface.class);

Selector selector =
    new SelectorBuilder()
        .fields(CampaignField.Id, CampaignField.Settings)
        .equalsId(campaignId)
        .build();

CampaignPage campaignPage = campaignService.get(selector);
if (campaignPage.getEntries() == null || campaignPage.getTotalNumEntries() == 0) {
  throw new IllegalArgumentException("No campaign found with ID: " + campaignId);
}
Campaign campaign = campaignPage.getEntries(0);

if (campaign.getSettings() == null) {
  throw new IllegalArgumentException(
      "Campaign with ID " + campaignId + " is not a DSA campaign.");
}

DynamicSearchAdsSetting dsaSetting = null;
for (Setting setting : campaign.getSettings()) {
  if (setting instanceof DynamicSearchAdsSetting) {
    dsaSetting = (DynamicSearchAdsSetting) setting;
    break;
  }
}

if (dsaSetting == null) {
  throw new IllegalArgumentException(
      "Campaign with ID " + campaignId + " is not a DSA campaign.");
}

Python

# Get the CampaignService.
campaign_service = client.GetService('CampaignService', version='v201705')

selector = {
    'fields': ['Id', 'Settings'],
    'predicates': [{
        'field': 'Id',
        'operator': 'EQUALS',
        'values': [campaign_id]
    }]
}

response = campaign_service.get(selector)

if response['totalNumEntries']:
  campaign = response['entries'][0]
else:
  raise ValueError('No campaign with ID "%d" exists.' % campaign_id)

if not campaign['settings']:
  raise ValueError('This is not a DSA campaign.')

dsa_setting = None

campaign_settings = campaign['settings']

for setting in campaign_settings:
  if setting['Setting.Type'] == 'DynamicSearchAdsSetting':
    dsa_setting = setting
    break

if dsa_setting is None:
  raise ValueError('This is not a DSA campaign.')
    

PHP

$campaignService = $adWordsServices->get($session, CampaignService::class);

// Create selector.
$selector = new Selector();
$selector->setFields(['Id', 'Settings']);
$selector->setPredicates(
    [new Predicate('CampaignId', PredicateOperator::IN, [$campaignId])]);

$result = $campaignService->get($selector);
if (empty($result->getEntries()) || $result->getTotalNumEntries() === 0) {
  throw new InvalidArgumentException(
      'No campaign found with ID: ' . $campaignId);
}
$campaign = $result->getEntries()[0];

if ($campaign->getSettings() === null) {
  throw new InvalidArgumentException(
      'Campaign with ID ' . $campaignId . ' is not a DSA campaign.');
}

$dsaSetting = null;
foreach ($campaign->getSettings() as $setting) {
  if ($setting instanceof DynamicSearchAdsSetting) {
    $dsaSetting = $setting;
    break;
  }
}

if ($dsaSetting === null) {
  throw new InvalidArgumentException(
      'Campaign with ID ' . $campaignId . ' is not a DSA campaign.');
}
    

Perl

my $paging = Google::Ads::AdWords::v201705::Paging->new({
  startIndex    => 0,
  numberResults => PAGE_SIZE
});
my $selector = Google::Ads::AdWords::v201705::Selector->new({
    fields     => ["Id", "Settings"],
    predicates => [
      Google::Ads::AdWords::v201705::Predicate->new({
          field    => "CampaignId",
          operator => "EQUALS",
          values   => [$campaign_id]})
    ],
    paging => $paging
  });

my $dsa_setting = undef;
Google::Ads::AdWords::Utilities::PageProcessor->new({
    client   => $client,
    service  => $client->CampaignService(),
    selector => $selector
  }
  )->process_entries(
  sub {
    my ($campaign) = @_;
    if ($campaign->get_settings()) {
      foreach my $setting (@{$campaign->get_settings()}) {
        if (
          $setting->isa(
            "Google::Ads::AdWords::v201705::DynamicSearchAdsSetting"))
        {
          $dsa_setting = $setting;
          last;
        }
      }
    }
  });

if (!$dsa_setting) {
  die sprintf("Campaign with ID %s is not a DSA campaign.", $campaign_id);
}
    

Ruby

campaign_srv = adwords.service(:CampaignService, API_VERSION)

selector = {
  :fields => ['Id', 'Settings'],
  :predicates => [
    {:field => 'CampaignId', :operator => 'IN', :values => [campaign_id]}
  ]
}

campaign_page = campaign_srv.get(selector)
if campaign_page.nil? or campaign_page[:entries].nil? or
    campaign_page[:total_num_entries] == 0
  raise 'No campaign found with ID: %d' % campaign_id
end

campaign = campaign_page[:entries].first

if campaign[:settings].nil?
  raise 'Campaign with ID %d is not a DSA campaign.' % campaign_id
end

dsa_setting = nil
campaign[:settings].each do |setting|
  if setting[:setting_type] == 'DynamicSearchAdsSetting'
    dsa_setting = setting
    break
  end
end

if dsa_setting.nil?
  raise 'Campaign with ID %d is not a DSA campaign.' % campaign_id
end
    

接下来,在广告系列的 DynamicSearchAdsSettingpageFeed 属性中指定 feedIds,以此来设置页面 Feed。您可以选择使用 useSuppliedUrlsOnly 字段来指定针对您的动态搜索广告是否仅使用指定的网址。

C#

// Use a page feed to specify precisely which URLs to use with your
// Dynamic Search Ads.
dsaSetting.pageFeed = new PageFeed() {
  feedIds = new long[] {
    feedId
  },
};

// Optional: Specify whether only the supplied URLs should be used with your
// Dynamic Search Ads.
dsaSetting.useSuppliedUrlsOnly = true;

Campaign campaignToUpdate = new Campaign();
campaignToUpdate.id = campaignId;
campaignToUpdate.settings = campaignSettings;

CampaignOperation operation = new CampaignOperation();
operation.operand = campaignToUpdate;
operation.@operator = Operator.SET;

try {
  CampaignReturnValue retval = campaignService.mutate(new CampaignOperation[] { operation });
  Campaign updatedCampaign = retval.value[0];
  Console.WriteLine("DSA page feed for campaign ID '{0}' was updated with feed ID '{1}'.",
      updatedCampaign.id, feedId);
} catch (Exception e) {
  throw new System.ApplicationException("Failed to set page feed for campaign.", e);
}

Java

// Use a page feed to specify precisely which URLs to use with your
// Dynamic Search Ads.
PageFeed pageFeed = new PageFeed();
pageFeed.setFeedIds(new long[] {feedDetails.feedId});
dsaSetting.setPageFeed(pageFeed);

// Optional: Specify whether only the supplied URLs should be used with your
// Dynamic Search Ads.
dsaSetting.setUseSuppliedUrlsOnly(true);

Campaign updatedCampaign = new Campaign();
updatedCampaign.setId(campaignId);
updatedCampaign.setSettings(campaign.getSettings());

CampaignOperation operation = new CampaignOperation();
operation.setOperand(updatedCampaign);
operation.setOperator(Operator.SET);

updatedCampaign = campaignService.mutate(new CampaignOperation[] {operation}).getValue(0);
System.out.printf(
    "DSA page feed for campaign ID %d was updated with feed ID %d.%n",
    updatedCampaign.getId(), feedDetails.feedId);

Python

dsa_setting['pageFeed'] = {
    'feedIds': [feed_id]
}

# Optional: Specify whether only the supplied URLs should be used with your
# Dynamic Search Ads.
dsa_setting['useSuppliedUrlsOnly'] = True

operation = {
    'operand': {
        'id': campaign_id,
        'settings': campaign_settings
    },
    'operator': 'SET'
}

campaign_service.mutate([operation])
print 'DSA page feed for campaign ID "%d" was updated with feed ID "%d".' % (
    campaign_id, feed_id)

PHP

// Use a page feed to specify precisely which URLs to use with your
// Dynamic Search Ads.
$pageFeed = new PageFeed();
$pageFeed->setFeedIds([$feedDetails->feedId]);
$dsaSetting->setPageFeed($pageFeed);

// Optional: Specify whether only the supplied URLs should be used with your
// Dynamic Search Ads.
$dsaSetting->setUseSuppliedUrlsOnly(true);

$updatedCampaign = new Campaign();
$updatedCampaign->setId($campaignId);
$updatedCampaign->setSettings($campaign->getSettings());

$operation = new CampaignOperation();
$operation->setOperand($updatedCampaign);
$operation->setOperator(Operator::SET);

// Update the campaign on the server and print out some information.
$result = $campaignService->mutate([$operation]);
$updatedCampaign = $result->getValue()[0];
printf("DSA page feed for campaign ID %d was updated with feed ID %d.\n",
    $updatedCampaign->getId(), $feedDetails->feedId);

Perl

# Use a page feed to specify precisely which URLs to use with your
# Dynamic Search Ads.
my $page_feed = Google::Ads::AdWords::v201705::PageFeed->new({
    feedIds => [$feed_details->{"feedId"}]});
$dsa_setting->set_pageFeed($page_feed);

# Optional: Specify whether only the supplied URLs should be used with your
# Dynamic Search Ads.
$dsa_setting->set_useSuppliedUrlsOnly(1);

my $updated_campaign = Google::Ads::AdWords::v201705::Campaign->new({
    id       => $campaign_id,
    settings => [$dsa_setting]});

my $operation = Google::Ads::AdWords::v201705::CampaignOperation->new({
  operand  => $updated_campaign,
  operator => "SET"
});

$client->CampaignService()->mutate({operations => [$operation]});
printf(
  "DSA page feed for campaign ID %d was updated with feed ID %d.\n",
  $updated_campaign->get_id(),
  $feed_details->{"feedId"});

Ruby

# Use a page feed to specify precisely which URLs to use with your Dynamic
# Search Ads.
page_feed = {
  :feed_ids => [feed_details[:feed_id]]
}
dsa_setting[:page_feed] = page_feed

# Optional: Specify whether only the supplied URLs should be used with your
# Dynamic Search Ads.
dsa_setting[:use_supplied_urls_only] = true

updated_campaign = {
  :id => campaign_id,
  :settings => campaign[:settings]
}

operation = {
  :operand => updated_campaign,
  :operator => 'SET'
}

updated_campaign = campaign_srv.mutate([operation])[:value].first
puts "DSA page feed for campaign ID %d was updated with feed ID %d." % [
  updated_campaign[:id], feed_details[:feed_id]
]

这些设置将映射到 AdWords 界面,如下所示。

useSuppliedUrlsOnly pageFeed.feedIds AdWords 界面设置
false 不适用 使用 Google 为我的网站编制的索引。
false 指定了一个或多个 Feed ID。 同时使用 Google 为我网站编制的索引中的网址和我的页面 Feed 中的网址。
true 指定了一个或多个 Feed ID。 仅使用来自我的页面 Feed 的网址。
true 空或 null 不支持。API 将引发 SettingError.DYNAMIC_SEARCH_ADS_SETTING_AT_LEAST_ONE_FEED_ID_MUST_BE_PRESENT 错误。

使用自定义标签定位页面 Feed 网址

您可以选择使用自定义标签来定位页面 Feed 中的网址并出价。这可以通过创建 Webpage 条件(将 operand 用作 CUSTOM_LABEL 进行过滤)来实现。

C#

private static BiddableAdGroupCriterion AddDsaTargeting(AdWordsUser user, long adGroupId,
    string labelName) {
  // Get the AdGroupCriterionService.
  AdGroupCriterionService adGroupCriterionService =
    (AdGroupCriterionService) user.GetService(AdWordsService.v201705.AdGroupCriterionService);

  // Create a webpage criterion.
  Webpage webpage = new Webpage();

  WebpageParameter parameter = new WebpageParameter();
  parameter.criterionName = "Test criterion";
  webpage.parameter = parameter;

  // Add a condition for label=specified_label_name.
  WebpageCondition condition = new WebpageCondition();
  condition.operand = WebpageConditionOperand.CUSTOM_LABEL;
  condition.argument = labelName;
  parameter.conditions = new WebpageCondition[] { condition };

  BiddableAdGroupCriterion criterion = new BiddableAdGroupCriterion();
  criterion.adGroupId = adGroupId;
  criterion.criterion = webpage;

  // Set a custom bid for this criterion.
  BiddingStrategyConfiguration biddingStrategyConfiguration =
      new BiddingStrategyConfiguration();

  biddingStrategyConfiguration.bids = new Bids[] {
    new CpcBid() {
      bid = new Money() {
        microAmount = 1500000
      }
    }
  };

  criterion.biddingStrategyConfiguration = biddingStrategyConfiguration;

  AdGroupCriterionOperation operation = new AdGroupCriterionOperation();
  operation.operand = criterion;
  operation.@operator = Operator.ADD;

  try {
    AdGroupCriterionReturnValue retval = adGroupCriterionService.mutate(
        new AdGroupCriterionOperation[] { operation });
    BiddableAdGroupCriterion newCriterion = (BiddableAdGroupCriterion) retval.value[0];

    Console.WriteLine("Web page criterion with ID = {0} and status = {1} was created.",
      newCriterion.criterion.id, newCriterion.userStatus);

    return newCriterion;
  } catch (Exception e) {
    throw new System.ApplicationException("Failed to create webpage criterion for " +
        "custom page feed label.", e);
  }
}
    

Java

private static void addDsaTargeting(
    AdWordsServicesInterface adWordsServices,
    AdWordsSession session,
    Long adGroupId,
    String dsaPageUrlLabel)
    throws ApiException, RemoteException {
  // Get the AdGroupCriterionService.
  AdGroupCriterionServiceInterface adGroupCriterionService =
      adWordsServices.get(session, AdGroupCriterionServiceInterface.class);

  // Create a webpage criterion.
  Webpage webpage = new Webpage();

  WebpageParameter parameter = new WebpageParameter();
  parameter.setCriterionName("Test criterion");
  webpage.setParameter(parameter);

  // Add a condition for label=specified_label_name.
  WebpageCondition condition = new WebpageCondition();
  condition.setOperand(WebpageConditionOperand.CUSTOM_LABEL);
  condition.setArgument(dsaPageUrlLabel);
  parameter.setConditions(new WebpageCondition[] {condition});

  BiddableAdGroupCriterion criterion = new BiddableAdGroupCriterion();
  criterion.setAdGroupId(adGroupId);
  criterion.setCriterion(webpage);

  // Set a custom bid for this criterion.
  BiddingStrategyConfiguration biddingStrategyConfiguration = new BiddingStrategyConfiguration();

  CpcBid cpcBid = new CpcBid();
  Money money = new Money();
  money.setMicroAmount(1_500_000L);
  cpcBid.setBid(money);
  biddingStrategyConfiguration.setBids(new Bids[] {cpcBid});

  criterion.setBiddingStrategyConfiguration(biddingStrategyConfiguration);

  AdGroupCriterionOperation operation = new AdGroupCriterionOperation();
  operation.setOperand(criterion);
  operation.setOperator(Operator.ADD);

  BiddableAdGroupCriterion newCriterion =
      (BiddableAdGroupCriterion)
          adGroupCriterionService.mutate(new AdGroupCriterionOperation[] {operation}).getValue(0);
  System.out.printf(
      "Web page criterion with ID %d and status '%s' was created.%n",
      newCriterion.getCriterion().getId(), newCriterion.getUserStatus());
}
    

Python

# Get the AdGroupCriterionService.
ad_group_criterion_service = client.GetService('AdGroupCriterionService',
                                               version='v201705')

# Create the operation.
operation = {
    'operand': {
        'xsi_type': 'BiddableAdGroupCriterion',
        'adGroupId': ad_group_id,
        # Create a webpage criterion.
        'criterion': {
            'xsi_type': 'Webpage',
            'parameter': {
                'criterionName': 'Test criterion',
                # Add a condition for label=specified_label_name.
                'conditions': [{
                    'operand': 'CUSTOM_LABEL',
                    'argument': label_name
                }],
            }
        },
        # Set a custom bid for this criterion
        'biddingStrategyConfiguration': {
            'bids': [{
                'xsi_type': 'CpcBid',
                'bid': {
                    'microAmount': 1500000
                }
            }]
        }
    },
    'operator': 'ADD'
}

criterion = ad_group_criterion_service.mutate([operation])['value'][0]
print 'Web page criterion with ID "%d" and status "%s" was created.' % (
    criterion['criterion']['id'], criterion['userStatus'])
return criterion
    

PHP

private static function addDsaTargeting(
    AdWordsServices $adWordsServices,
    AdWordsSession $session,
    $adGroupId,
    $dsaPageUrlLabel
) {
  $adGroupCriterionService =
      $adWordsServices->get($session, AdGroupCriterionService::class);

  // Create a webpage criterion.
  $webpage = new Webpage();

  $parameter = new WebpageParameter();
  $parameter->setCriterionName('Test criterion');
  $webpage->setParameter($parameter);

  // Add a condition for label=specified_label_name.
  $condition = new WebpageCondition();
  $condition->setOperand(WebpageConditionOperand::CUSTOM_LABEL);
  $condition->setArgument($dsaPageUrlLabel);
  $parameter->setConditions([$condition]);

  $criterion = new BiddableAdGroupCriterion();
  $criterion->setAdGroupId($adGroupId);
  $criterion->setCriterion($webpage);

  // Set a custom bid for this criterion.
  $biddingStrategyConfiguration = new BiddingStrategyConfiguration();

  $cpcBid = new CpcBid();
  $money = new Money();
  $money->setMicroAmount(1500000);
  $cpcBid->setBid($money);
  $biddingStrategyConfiguration->setBids([$cpcBid]);

  $criterion->setBiddingStrategyConfiguration($biddingStrategyConfiguration);

  $operation = new AdGroupCriterionOperation();
  $operation->setOperand($criterion);
  $operation->setOperator(Operator::ADD);

  // Create ad group criterion on the server and print out some information.
  $result = $adGroupCriterionService->mutate([$operation]);
  $criterion = $result->getValue()[0];
  printf("Web page criterion with ID %d and status '%s' was created.\n",
      $criterion->getCriterion()->getId(), $criterion->getUserStatus());
}
    

Perl

sub _add_dsa_targeting {
  my ($client, $ad_group_id, $dsa_page_url_label) = @_;

  # Create a webpage criterion.
  # Add a condition for label=specified_label_name.
  my $condition = Google::Ads::AdWords::v201705::WebpageCondition->new({
    operand  => "CUSTOM_LABEL",
    argument => $dsa_page_url_label
  });

  # Create a webpage criterion for special offers.
  my $parameter = Google::Ads::AdWords::v201705::WebpageParameter->new({
      criterionName => "Test criterion",
      conditions    => [$condition]});

  my $webpage = Google::Ads::AdWords::v201705::Webpage->new({
    parameter => $parameter
  });

  # Create biddable ad group criterion.
  my $biddable_ad_group_criterion =
    Google::Ads::AdWords::v201705::BiddableAdGroupCriterion->new({
      adGroupId => $ad_group_id,
      criterion => $webpage,
      # Set a custom bid for this criterion.
      biddingStrategyConfiguration =>
        Google::Ads::AdWords::v201705::BiddingStrategyConfiguration->new({
          bids => [
            Google::Ads::AdWords::v201705::CpcBid->new({
                bid => Google::Ads::AdWords::v201705::Money->new(
                  {microAmount => 1500000}
                ),
              }
            ),
          ]})});

  # Create operation.
  my $operation =
    Google::Ads::AdWords::v201705::AdGroupCriterionOperation->new({
      operator => "ADD",
      operand  => $biddable_ad_group_criterion
    });

  # Create the criterion.
  my $result =
    $client->AdGroupCriterionService()->mutate({operations => [$operation]});
  my $new_ad_group_criterion = $result->get_value()->[0];
  printf "Web page criterion with ID %d and status '%s' was created.\n",
    $new_ad_group_criterion->get_criterion()->get_id(),
    $new_ad_group_criterion->get_userStatus();
}
    

Ruby

def add_dsa_targeting(adwords, ad_group_id, dsa_page_url_label)
  ad_group_criterion_srv =
      adwords.service(:AdGroupCriterionService, API_VERSION)

  webpage = {
    :xsi_type => 'Webpage',
    :parameter => {
      :criterion_name => 'Test criterion',
      :conditions => [{
        :operand => 'CUSTOM_LABEL',
        :argument => dsa_page_url_label
      }]
    }
  }

  bidding_strategy_configuration = {
    :bids => [{
      :xsi_type => 'CpcBid',
      :bid => {
        :micro_amount => 1_500_000
      }
    }]
  }

  criterion = {
    :xsi_type => 'BiddableAdGroupCriterion',
    :ad_group_id => ad_group_id,
    :criterion => webpage,
    :bidding_strategy_configuration => bidding_strategy_configuration
  }

  operation = {
    :operand => criterion,
    :operator => 'ADD'
  }

  new_criterion = ad_group_criterion_srv.mutate([operation])[:value].first
  puts "Web page criterion with ID %d and status '%s' was created." %
      [new_criterion[:criterion][:id], new_criterion[:user_status]]
end
    

报告

您可以针对动态搜索广告下载三种不同的报告。

条件效果报告

如果条件对象的类型是 WebpageCriterion,此报告中的 ParameterDynamic ad target 字段会纳入与此对象相关联的 WebpageParameter 的名称。请注意,这是一个“属性”类型字段,也就是说它包含固定数据,在本例中即是与效果数据相关联的 WebpageParameter

不含关键字的类别报告

按类别汇总动态搜索广告的统计信息时,不含关键字的类别效果报告会将不含关键字的广告纳入统计范围。此报告不会返回展示次数为零的行Category0Category1Category2 字段包含有关结果的类别和子类别信息。

顶级类别 第一级子类别 第二级子类别 点击次数 展示次数 日期 总费用
观光和旅游 外星球 火星 1 71 6/20/2014 0.05
观光和旅游 探险旅行 0 279 6/21/2014 0

不含关键字的查询报告

基于搜索字词统计动态搜索广告的相关信息时,不含关键字的查询效果报告会将不含关键字的广告纳入统计范围。此报告不会返回展示次数为零的行Query 字段会包含生成结果的所有匹配查询。

搜索字词 点击次数 展示次数 日期 总费用 网址
火星豪华 0 20 6/20/2014 0 http://example.org/LuxuryMarsCruises
火星豪华 0 14 6/21/2014 0 http://example.org/LuxuryMarsCruises
低成本火星 0 24 6/20/2014 0 http://example.org/MarsOnABudget
低成本火星 0 18 6/21/2014 0 http://example.org/MarsOnABudget
火星地标 0 130 6/21/2014 0 http://example.org/MajorTouristSpots
火星鬼脸 0 44 6/21/2014 0 http://example.org/MajorTouristSpots
太空旅行安全 1 3 6/20/2014 0.05 http://example.org/ButIsItSafe
火星出发点 0 11 6/21/2014 0 http://example.org/HowToGetToMars
火星沙滩 0 24 6/20/2014 0 http://example.org/MarsBeachVacations
火星沙滩 0 39 6/21/2014 0 http://example.org/MarsBeachVacations
火星峡谷 0 23 6/21/2014 0 http://example.org/DayTripsAndActivities
合计 1 350 -- 0.05 --

代码示例

每个客户端库中都提供了适用于动态搜索广告的完整代码示例:

发送以下问题的反馈:

此网页
AdWords API
AdWords API
需要帮助?请访问我们的支持页面