動態搜尋廣告網頁動態饋給

根據預設,動態搜尋廣告會指定整個網站,或 如果您需要更棒的做法 能讓您更精準地控制網址 要用於動態搜尋廣告的網址。如果您在 產品及其到達網頁,有助於 Google Ads 判斷何時顯示 以及該將使用者導向網站上的哪個位置。

本指南說明如何建立以素材資源為基礎的動態搜尋廣告網頁動態饋給。

為網站的每個頁面建立素材資源

首先,請為網站上的每個網址建立 Asset

Java

List<String> urls =
    ImmutableList.of(
        "http://www.example.com/discounts/rental-cars",
        "http://www.example.com/discounts/hotel-deals",
        "http://www.example.com/discounts/flight-deals");

// Creates one operation per URL.
List<AssetOperation> assetOperations = new ArrayList<>();
for (String url : urls) {
  PageFeedAsset pageFeedAsset =
      PageFeedAsset.newBuilder()
          // Sets the URL of the page to include.
          .setPageUrl(url)
          // Recommended: adds labels to the asset. These labels can be used later in ad group
          // targeting to restrict the set of pages that can serve.
          .addLabels(dsaPageUrlLabel)
          .build();
  Asset asset = Asset.newBuilder().setPageFeedAsset(pageFeedAsset).build();
  assetOperations.add(AssetOperation.newBuilder().setCreate(asset).build());
}

// Creates the service client.
try (AssetServiceClient assetServiceClient =
    googleAdsClient.getLatestVersion().createAssetServiceClient()) {
  // Adds the assets.
  MutateAssetsResponse response =
      assetServiceClient.mutateAssets(String.valueOf(customerId), assetOperations);
  // Prints some information about the result.
  List<String> resourceNames =
      response.getResultsList().stream()
          .map(MutateAssetResult::getResourceName)
          .collect(Collectors.toList());
  resourceNames.forEach(r -> System.out.printf("Created asset with resource name %s.%n", r));
  return resourceNames;
}
      

C#

/// <summary>
/// Creates Assets to be used in a DSA page feed.
/// </summary>
/// <param name="client">The Google Ads client.</param>
/// <param name="customerId">The Google Ads customer ID for which the call is made.</param>
/// <param name="dsaPageUrlLabel">The DSA page URL label.</param>
/// <returns>The list of asset resource names.</returns>
private static List<string> CreateAssets(GoogleAdsClient client, long customerId,
    string dsaPageUrlLabel)
{
    AssetServiceClient assetService = client.GetService(Services.V17.AssetService);

    string[] urls = new[]
    {
        "http://www.example.com/discounts/rental-cars",
        "http://www.example.com/discounts/hotel-deals",
        "http://www.example.com/discounts/flight-deals"
    };

    // Creates one operation per URL.
    List<AssetOperation> assetOperations = new List<AssetOperation>();
    foreach (string url in urls)
    {
        PageFeedAsset pageFeedAsset = new PageFeedAsset()
        {
            // Sets the URL of the page to include.
            PageUrl = url,

            // Recommended: adds labels to the asset. These labels can be used later in
            // ad group targeting to restrict the set of pages that can serve.
            Labels = { dsaPageUrlLabel }
        };

        assetOperations.Add(
            new AssetOperation()
            {
                Create = new Asset()
                {
                    PageFeedAsset = pageFeedAsset
                }
            });
    }

    // Adds the assets.
    MutateAssetsResponse response =
        assetService.MutateAssets(customerId.ToString(), assetOperations);

    // Prints some information about the result.
    List<string> resourceNames = response.Results.Select(
        assetResult => assetResult.ResourceName).ToList();
    foreach (string resourceName in resourceNames)
    {
        Console.Write($"Created asset with resource name {resourceName}.");
    }
    return resourceNames;
}
      

PHP

$urls = [
    'http://www.example.com/discounts/rental-cars',
    'http://www.example.com/discounts/hotel-deals',
    'http://www.example.com/discounts/flight-deals'
];
$operations = [];
// Creates one asset per URL.
foreach ($urls as $url) {
    $pageFeedAsset = new PageFeedAsset([
        'page_url' => $url,
        // Recommended: adds labels to the asset. These labels can be used later in ad group
        // targeting to restrict the set of pages that can serve.
        'labels' => [$dsaPageUrlLabel]
    ]);

    // Wraps the page feed asset in an asset.
    $asset = new Asset(['page_feed_asset' => $pageFeedAsset]);

    // Creates an asset operation and adds it to the list of operations.
    $assetOperation = new AssetOperation();
    $assetOperation->setCreate($asset);
    $operations[] = $assetOperation;
}

// Issues a mutate request to add the assets and prints its information.
$assetServiceClient = $googleAdsClient->getAssetServiceClient();
$response = $assetServiceClient->mutateAssets(MutateAssetsRequest::build(
    $customerId,
    $operations
));
$assetResourceNames = [];
printf("Added %d assets:%s", $response->getResults()->count(), PHP_EOL);
foreach ($response->getResults() as $addedAsset) {
    /** @var Asset $addedAsset */
    $assetResourceName = $addedAsset->getResourceName();
    printf(
        "Created an asset with resource name: '%s'.%s",
        $assetResourceName,
        PHP_EOL
    );
    $assetResourceNames[] = $assetResourceName;
}
return $assetResourceNames;
      

Python

def create_assets(client, customer_id, dsa_page_url_label):
    """Creates assets to be used in a DSA page feed.

    Args:
        client: an initialized GoogleAdsClient instance.
        customer_id: a client customer ID.
        dsa_page_url_label: the label for the DSA page URLs.

    Returns:
        a list of the created assets' resource names.
    """
    urls = [
        "http://www.example.com/discounts/rental-cars",
        "http://www.example.com/discounts/hotel-deals",
        "http://www.example.com/discounts/flight-deals",
    ]
    operations = []

    # Creates one asset per URL.
    for url in urls:
        # Creates an asset operation and adds it to the list of operations.
        operation = client.get_type("AssetOperation")
        asset = operation.create
        page_feed_asset = asset.page_feed_asset
        page_feed_asset.page_url = url
        # Recommended: adds labels to the asset. These labels can be used later
        # in ad group targeting to restrict the set of pages that can serve.
        page_feed_asset.labels.append(dsa_page_url_label)
        operations.append(operation)

    # Issues a mutate request to add the assets and prints its information.
    asset_service = client.get_service("AssetService")
    response = asset_service.mutate_assets(
        customer_id=customer_id, operations=operations
    )

    print(f"Added {len(response.results)} assets:")

    resource_names = []
    for result in response.results:
        resource_name = result.resource_name
        print(f"\tCreated an asset with resource name: '{resource_name}'")
        resource_names.append(resource_name)

    return resource_names
      

小茹

def create_assets(client, dsa_page_url_label, customer_id)
  urls = [
    'http://www.example.com/discounts/rental-cars',
    'http://www.example.com/discounts/hotel-deals',
    'http://www.example.com/discounts/flight-deals',
  ]

  operations = urls.map do |url|
    client.operation.create_resource.asset do |asset|
      asset.page_feed_asset = client.resource.page_feed_asset do |pfa|
        # Sets the URL of the page to include.
        pfa.page_url = url
        # Recommended: adds labels to the asset. These labels can be used later
        # in ad group targeting to restrict the set of pages that can serve.
        pfa.labels << dsa_page_url_label
      end
    end
  end

  response = client.service.asset.mutate_assets(
    customer_id: customer_id,
    operations: operations,
  )

  resource_names = []
  response.results.each do |result|
    resource_name = result.resource_name
    puts "Created asset with resource name '#{resource_name}'"
    resource_names << resource_name
  end

  resource_names
end
      

Perl

my $urls = [
  "http://www.example.com/discounts/rental-cars",
  "http://www.example.com/discounts/hotel-deals",
  "http://www.example.com/discounts/flight-deals"
];

# Create one operation per URL.
my $asset_operations = [];
foreach my $url (@$urls) {
  my $page_feed_asset =
    Google::Ads::GoogleAds::V17::Common::PageFeedAsset->new({
      # Set the URL of the page to include.
      pageUrl => $url,
      # Recommended: add labels to the asset. These labels can be used later in
      # ad group targeting to restrict the set of pages that can serve.
      labels => [$dsa_page_url_label]});
  my $asset = Google::Ads::GoogleAds::V17::Resources::Asset->new({
    pageFeedAsset => $page_feed_asset
  });

  push @$asset_operations,
    Google::Ads::GoogleAds::V17::Services::AssetService::AssetOperation->new({
      create => $asset
    });
}

# Add the assets.
my $response = $api_client->AssetService()->mutate({
  customerId => $customer_id,
  operations => $asset_operations
});

# Print some information about the response.
my $resource_names = [];
foreach my $result (@{$response->{results}}) {
  push @$resource_names, $result->{resourceName};
  printf "Created asset with resource name '%s'.\n", $result->{resourceName};
}
return $resource_names;
      

將網頁動態饋給素材資源組合成 AssetSet

接著,建立資產集合,也就是 AssetSet。這組群組代表了 專屬於個別的廣告活動。Asset 可以是多個值 AssetSet 物件。

首先,請建立新的 AssetSet

Java

// Creates an AssetSet which will be used to link the dynamic page feed assets to a campaign.
AssetSet assetSet =
    AssetSet.newBuilder()
        .setName("My dynamic page feed " + CodeSampleHelper.getPrintableDateTime())
        .setType(AssetSetType.PAGE_FEED)
        .build();
// Creates an operation to add the AssetSet.
AssetSetOperation operation = AssetSetOperation.newBuilder().setCreate(assetSet).build();
try (AssetSetServiceClient serviceClient =
    googleAdsClient.getLatestVersion().createAssetSetServiceClient()) {
  // Sends the mutate request.
  MutateAssetSetsResponse response =
      serviceClient.mutateAssetSets(
          String.valueOf(params.customerId), ImmutableList.of(operation));
  // Prints some information about the response.
  String resourceName = response.getResults(0).getResourceName();
  System.out.printf("Created asset set with resource name %s.%n", resourceName);
  return resourceName;
}
      

C#

/// <summary>
/// Creates an AssetSet.
/// </summary>
/// <param name="client">The Google Ads client.</param>
/// <param name="customerId">The Google Ads customer ID for which the call is made.</param>
/// <returns>The resource name of the asset set.</returns>
private string CreateAssetSet(GoogleAdsClient client, long customerId)
{
    AssetSetServiceClient assetSetService = client.GetService(
        Services.V17.AssetSetService);

    // Creates an AssetSet which will be used to link the dynamic page feed assets
    // to a campaign.
    AssetSet assetSet = new AssetSet()
    {
        Name = "My dynamic page feed " + ExampleUtilities.GetRandomString(),
        Type = AssetSetType.PageFeed
    };

    // Creates an operation to add the AssetSet.
    AssetSetOperation operation = new AssetSetOperation()
    {
        Create = assetSet
    };

    // Sends the mutate request.
    MutateAssetSetsResponse response =
        assetSetService.MutateAssetSets(
            customerId.ToString(), new[] { operation });
    // Prints some information about the response.
    string resourceName = response.Results[0].ResourceName;
    Console.WriteLine($"Created asset set with resource name {resourceName}.");
    return resourceName;
}
      

PHP

// Creates an asset set which will be used to link the dynamic page feed assets to a
// campaign.
$assetSet = new AssetSet([
    'name' => 'My dynamic page feed ' . Helper::getPrintableDatetime(),
    'type' => AssetSetType::PAGE_FEED
]);

// Creates an asset set operation.
$assetSetOperation = new AssetSetOperation();
$assetSetOperation->setCreate($assetSet);

// Issues a mutate request to add the asset set and prints its information.
$assetSetServiceClient = $googleAdsClient->getAssetSetServiceClient();
$response = $assetSetServiceClient->mutateAssetSets(MutateAssetSetsRequest::build(
    $customerId,
    [$assetSetOperation]
));
$assetSetResourceName = $response->getResults()[0]->getResourceName();
printf(
    "Created an asset set with resource name: '%s'.%s",
    $assetSetResourceName,
    PHP_EOL
);

return $assetSetResourceName;
      

Python

def create_asset_set(client, customer_id):
    """Creates an asset set.

    Args:
        client: an initialized GoogleAdsClient instance.
        customer_id: a client customer ID.

    Returns:
        the created asset set's resource name.
    """
    operation = client.get_type("AssetSetOperation")
    # Creates an asset set which will be used to link the dynamic page feed
    # assets to a campaign.
    asset_set = operation.create
    asset_set.name = f"My dynamic page feed {get_printable_datetime()}"
    asset_set.type_ = client.enums.AssetSetTypeEnum.PAGE_FEED

    # Issues a mutate request to add the asset set and prints its information.
    asset_set_service = client.get_service("AssetSetService")
    response = asset_set_service.mutate_asset_sets(
        customer_id=customer_id, operations=[operation]
    )

    resource_name = response.results[0].resource_name
    print(f"Created an asset set with resource name: '{resource_name}'")
    return resource_name
      

小茹

def create_asset_set(client, customer_id)
  # Creates an AssetSet which will be used to link the dynamic page feed assets to a campaign.
  # Creates an operation to add the AssetSet.
  operation = client.operation.create_resource.asset_set do |asset_set|
    asset_set.name = "My dynamic page feed #{Time.now}"
    asset_set.type = :PAGE_FEED
  end

  # Sends the mutate request.
  response = client.service.asset_set.mutate_asset_sets(
    customer_id: customer_id,
    operations: [operation],
  )
  # Prints some information about the response.
  resource_name = response.results.first.resource_name
  puts "Created asset set with resource name '#{resource_name}'"

  resource_name
end
      

Perl

# Create an AssetSet which will be used to link the dynamic page feed assets to
# a campaign.
my $asset_set = Google::Ads::GoogleAds::V17::Resources::AssetSet->new({
  name => "My dynamic page feed #" . uniqid(),
  type => PAGE_FEED
});

# Create an operation to add the AssetSet.
my $operation =
  Google::Ads::GoogleAds::V17::Services::AssetSetService::AssetSetOperation->
  new({
    create => $asset_set
  });

# Send the mutate request.
my $response = $api_client->AssetSetService()->mutate({
    customerId => $customer_id,
    operations => [$operation]});

# Print some information about the response.
my $resource_name = $response->{results}[0]{resourceName};
printf "Created asset set with resource name '%s'.\n", $resource_name;
return $resource_name;
      

接著,在上方和 AssetSet 中的素材資源建立連結:

Java

List<AssetSetAssetOperation> operations = new ArrayList<>();
for (String assetResourceName : assetResourceNames) {
  AssetSetAsset assetSetAsset =
      AssetSetAsset.newBuilder()
          .setAsset(assetResourceName)
          .setAssetSet(assetSetResourceName)
          .build();
  // Creates an operation to add the link.
  AssetSetAssetOperation operation =
      AssetSetAssetOperation.newBuilder().setCreate(assetSetAsset).build();
  operations.add(operation);
}
try (AssetSetAssetServiceClient client =
    googleAdsClient.getLatestVersion().createAssetSetAssetServiceClient()) {
  // Sends the mutate request.
  MutateAssetSetAssetsResponse response =
      client.mutateAssetSetAssets(String.valueOf(params.customerId), operations);
  // Prints some information about the response.
  String resourceName = response.getResults(0).getResourceName();
  System.out.printf("Created AssetSetAsset link with resource name %s.%n", resourceName);
}
      

C#

/// <summary>
/// Adds an Asset to an AssetSet by creating an AssetSetAsset link.
/// </summary>
/// <param name="client">The Google Ads client.</param>
/// <param name="customerId">The Google Ads customer ID for which the call is made.</param>
/// <param name="assetResourceNames">The asset resource names.</param>
/// <param name="assetSetResourceName">Resource name of the asset set.</param>
private void AddAssetsToAssetSet(GoogleAdsClient client, long customerId,
    List<string> assetResourceNames, string assetSetResourceName)
{
    AssetSetAssetServiceClient assetSetAssetService = client.GetService(
        Services.V17.AssetSetAssetService);

    List<AssetSetAssetOperation> operations = new List<AssetSetAssetOperation>();
    foreach (string assetResourceName in assetResourceNames)
    {
        AssetSetAsset assetSetAsset = new AssetSetAsset()
        {
            Asset = assetResourceName,
            AssetSet = assetSetResourceName
        };

        // Creates an operation to add the link.
        AssetSetAssetOperation operation = new AssetSetAssetOperation()
        {
            Create = assetSetAsset
        };

        operations.Add(operation);
    }
    // Sends the mutate request.
    MutateAssetSetAssetsResponse response =
        assetSetAssetService.MutateAssetSetAssets(customerId.ToString(), operations);
    // Prints some information about the response.
    string resourceName = response.Results[0].ResourceName;
    Console.WriteLine($"Created AssetSetAsset link with resource name {resourceName}.");
}
      

PHP

$operations = [];
foreach ($assetResourceNames as $assetResourceName) {
    // Creates an asset set asset.
    $assetSetAsset = new AssetSetAsset([
        'asset' => $assetResourceName,
        'asset_set' => $assetSetResourceName
    ]);

    // Creates an asset set asset operation and adds it to the list of operations.
    $assetSetAssetOperation = new AssetSetAssetOperation();
    $assetSetAssetOperation->setCreate($assetSetAsset);
    $operations[] = $assetSetAssetOperation;
}

// Issues a mutate request to add the asset set assets and prints its information.
$assetSetAssetServiceClient = $googleAdsClient->getAssetSetAssetServiceClient();
$response = $assetSetAssetServiceClient->mutateAssetSetAssets(
    MutateAssetSetAssetsRequest::build($customerId, $operations)
);
printf("Added %d asset set assets:%s", $response->getResults()->count(), PHP_EOL);
foreach ($response->getResults() as $addedAssetSetAsset) {
    /** @var AssetSetAsset $addedAssetSetAsset */
    printf(
        "Created an asset set asset link with resource name: '%s'.%s",
        $addedAssetSetAsset->getResourceName(),
        PHP_EOL
    );
}
      

Python

def add_assets_to_asset_set(
    client, customer_id, asset_resource_names, asset_set_resource_name
):
    """Adds assets to an asset set by creating an asset set asset link.

    Args:
        client: an initialized GoogleAdsClient instance.
        customer_id: a client customer ID.
        asset_resource_names: a list of asset resource names.
        asset_set_resource_name: a resource name for an asset set.
    """
    operations = []
    for resource_name in asset_resource_names:
        # Creates an asset set asset operation and adds it to the list of
        # operations.
        operation = client.get_type("AssetSetAssetOperation")
        asset_set_asset = operation.create
        asset_set_asset.asset = resource_name
        asset_set_asset.asset_set = asset_set_resource_name
        operations.append(operation)

    # Issues a mutate request to add the asset set assets and prints its
    # information.
    asset_set_asset_service = client.get_service("AssetSetAssetService")
    response = asset_set_asset_service.mutate_asset_set_assets(
        customer_id=customer_id, operations=operations
    )

    print(f"Added {len(response.results)} asset set assets:")

    for result in response.results:
        print(
            "\tCreated an asset set asset link with resource name "
            f"'{result.resource_name}'"
        )
      

小茹

def add_assets_to_asset_set(client, asset_resource_names, asset_set_resource_name, customer_id)
  operations = asset_resource_names.map do |asset_resource_name|
    client.operation.create_resource.asset_set_asset do |asa|
      asa.asset = asset_resource_name
      asa.asset_set = asset_set_resource_name
    end
  end

  response = client.service.asset_set_asset.mutate_asset_set_assets(
    customer_id: customer_id,
    operations: operations,
  )
  resource_name = response.results.first.resource_name
  puts "Created asset set asset with resource name '#{resource_name}'"
end
      

Perl

my $operations = [];
foreach my $asset_resource_name (@$asset_resource_names) {
  my $asset_set_asset =
    Google::Ads::GoogleAds::V17::Resources::AssetSetAsset->new({
      asset    => $asset_resource_name,
      assetSet => $asset_set_resource_name
    });

  # Create an operation to add the link.
  my $operation =
    Google::Ads::GoogleAds::V17::Services::AssetSetAssetService::AssetSetAssetOperation
    ->new({
      create => $asset_set_asset
    });
  push @$operations, $operation;
}

# Send the mutate request.
my $response = $api_client->AssetSetAssetService()->mutate({
  customerId => $customer_id,
  operations => $operations
});

# Print some information about the response.
my $resource_name = $response->{results}[0]{resourceName};
printf "Created AssetSetAsset link with resource name '%s'.\n",
  $resource_name;
      

將 AssetSet 與廣告活動建立關聯

AssetSet 中收集資產後,請將 PageFeedAsset 包含廣告活動。

Java

// Creates a CampaignAssetSet representing the link between an AssetSet and a Campaign.
CampaignAssetSet campaignAssetSet =
    CampaignAssetSet.newBuilder()
        .setCampaign(ResourceNames.campaign(params.customerId, params.campaignId))
        .setAssetSet(assetSetResourceName)
        .build();
// Creates an operation to add the CampaignAssetSet.
CampaignAssetSetOperation operation =
    CampaignAssetSetOperation.newBuilder().setCreate(campaignAssetSet).build();
// Creates the service client.
try (CampaignAssetSetServiceClient client =
    googleAdsClient.getLatestVersion().createCampaignAssetSetServiceClient()) {
  // Issues the mutate request.
  MutateCampaignAssetSetsResponse response =
      client.mutateCampaignAssetSets(
          String.valueOf(params.customerId), ImmutableList.of(operation));
  String resourceName = response.getResults(0).getResourceName();
  System.out.printf("Created a CampaignAssetSet with resource name %s.%n", resourceName);
}
      

C#

/// <summary>
/// Links an AssetSet to a Campaign by creating a CampaignAssetSet.
/// </summary>
/// <param name="client">The Google Ads client.</param>
/// <param name="customerId">The Google Ads customer ID for which the call is made.</param>
/// <param name="campaignId">ID of the campaign to which the asset is linked.</param>
/// <param name="assetSetResourceName">Resource name of the asset set.</param>
private void LinkAssetSetToCampaign(GoogleAdsClient client, long customerId,
    long campaignId, string assetSetResourceName)
{
    CampaignAssetSetServiceClient campaignAssetSetService = client.GetService(
        Services.V17.CampaignAssetSetService);

    // Creates a CampaignAssetSet representing the link between an AssetSet and a Campaign.
    CampaignAssetSet campaignAssetSet = new CampaignAssetSet()
    {
        Campaign = ResourceNames.Campaign(customerId, campaignId),
        AssetSet = assetSetResourceName,
    };

    // Creates an operation to add the CampaignAssetSet.
    CampaignAssetSetOperation operation = new CampaignAssetSetOperation()
    {
        Create = campaignAssetSet
    };
    // Issues the mutate request.
    MutateCampaignAssetSetsResponse response =
        campaignAssetSetService.MutateCampaignAssetSets(
            customerId.ToString(), new[] { operation });
    string resourceName = response.Results[0].ResourceName;
    Console.WriteLine($"Created a CampaignAssetSet with resource name {resourceName}.");
}
      

PHP

// Creates a campaign asset set representing the link between an asset set and a campaign.
$campaignAssetSet = new CampaignAssetSet([
    'asset_set' => $assetSetResourceName,
    'campaign' => ResourceNames::forCampaign($customerId, $campaignId)
]);

// Creates a campaign asset set operation.
$campaignAssetSetOperation = new CampaignAssetSetOperation();
$campaignAssetSetOperation->setCreate($campaignAssetSet);

// Issues a mutate request to add the campaign asset set and prints its information.
$campaignAssetSetServiceClient = $googleAdsClient->getCampaignAssetSetServiceClient();
$response = $campaignAssetSetServiceClient->mutateCampaignAssetSets(
    MutateCampaignAssetSetsRequest::build($customerId, [$campaignAssetSetOperation])
);
printf(
    "Created a campaign asset set with resource name: '%s'.%s",
    $response->getResults()[0]->getResourceName(),
    PHP_EOL
);
      

Python

def link_asset_set_to_campaign(
    client, customer_id, campaign_id, asset_set_resource_name
):
    """Links the asset set to the campaign by creating a campaign asset set.

    Args:
        client: an initialized GoogleAdsClient instance.
        customer_id: a client customer ID.
        campaign_id: the ID for a Campaign.
        asset_set_resource_name: a resource name for an asset set.
    """
    googleads_service = client.get_service("GoogleAdsService")
    # Creates a campaign asset set representing the link between an asset set
    # and a campaign.
    operation = client.get_type("CampaignAssetSetOperation")
    campaign_asset_set = operation.create
    campaign_asset_set.asset_set = asset_set_resource_name
    campaign_asset_set.campaign = googleads_service.campaign_path(
        customer_id, campaign_id
    )

    campaign_asset_set_service = client.get_service("CampaignAssetSetService")
    response = campaign_asset_set_service.mutate_campaign_asset_sets(
        customer_id=customer_id, operations=[operation]
    )

    resource_name = response.results[0].resource_name
    print(f"Created a campaign asset set with resource name: '{resource_name}'")
      

小茹

def link_asset_set_to_campaign(client, asset_set_resource_name, customer_id, campaign_id)
  # Creates a CampaignAssetSet representing the link between an AssetSet and a Campaign.
  # Creates an operation to add the CampaignAssetSet.
  operation = client.operation.create_resource.campaign_asset_set do |cas|
    cas.campaign = client.path.campaign(customer_id, campaign_id)
    cas.asset_set = asset_set_resource_name
  end

  # Issues the mutate request.
  response = client.service.campaign_asset_set.mutate_campaign_asset_sets(
    customer_id: customer_id,
    operations: [operation],
  )
  resource_name = response.results.first.resource_name
  puts "Created a campaign asset set with resource name '#{resource_name}'"
end
      

Perl

# Create a CampaignAssetSet representing the link between an AssetSet and a Campaign.
my $campaign_asset_set =
  Google::Ads::GoogleAds::V17::Resources::CampaignAssetSet->new({
    campaign => Google::Ads::GoogleAds::V17::Utils::ResourceNames::campaign(
      $customer_id, $campaign_id
    ),
    assetSet => $asset_set_resource_name
  });

# Create an operation to add the CampaignAssetSet.
my $operation =
  Google::Ads::GoogleAds::V17::Services::CampaignAssetSetService::CampaignAssetSetOperation
  ->new({
    create => $campaign_asset_set
  });

# Issue the mutate request.
my $response = $api_client->CampaignAssetSetService()->mutate({
    customerId => $customer_id,
    operations => [$operation]});

# Print some information about the response.
my $resource_name = $response->{results}[0]{resourceName};
printf "Created a CampaignAssetSet with resource name '%s'.\n",
  $resource_name;
      

建議:使用自訂標籤指定網頁動態饋給網址

您可以選擇使用自訂標籤,為網頁動態饋給中的網址指定目標及出價。 我們只需根據 WebpageInfo 會使用以下條件進行篩選: 已經將 operand 設為 WebpageConditionOperand.CUSTOM_LABEL