فیدهای صفحه «آگهی‌های جستجوی پویا»

به‌طور پیش‌فرض، «آگهی‌های جستجوهای پویا» (DSA) کل وب‌سایت‌ها یا بخش‌هایی از آن‌ها را بدون تمرکز روی نشانی‌های وب صفحه خاصی هدف‌یابی می‌کنند. اگر به کنترل دقیق‌تری روی نشانی‌های وب نیاز دارید، می‌توانید از فیدهای صفحه «آگهی‌های جستجوهای پویا» استفاده کنید تا مشخص کنید کدام نشانی‌های وب با «آگهی‌های جستجوهای پویا» استفاده شود. ارائه فید صفحه محصولات و صفحه‌های مقصد آن‌ها به Google Ads کمک می‌کند تعیین کند چه زمانی آگهی‌هایتان را نشان دهد و افراد را به کجا در وب‌سایتتان هدایت کند.

این راهنما به شما نشان می‌دهد که چگونه فیدهای صفحه «آگهی‌های جستجوی پویا» مبتنی بر دارایی ایجاد کنید. در پویش‌های «عملکرد بیشینه»، فیدهای صفحه به‌عنوان گنجاندن‌های نشانی وب نیز شناخته می‌شوند.

برای هر صفحه در وب‌سایتتان دارایی بسازید

ابتدا، Asset با PageFeedAsset (page_feed_asset.page_url و labels اختیاری) برای هر نشانی وب در وب‌سایتتان ایجاد کنید:

جاوا

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.V26.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: GoogleAdsClient, customer_id: str, dsa_page_url_label: str
) -> List[str]:
    """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: List[str] = [
        "http://www.example.com/discounts/rental-cars",
        "http://www.example.com/discounts/hotel-deals",
        "http://www.example.com/discounts/flight-deals",
    ]
    operations: List[AssetOperation] = []

    # Creates one asset per URL.
    for url in urls:
        # Creates an asset operation and adds it to the list of operations.
        operation: AssetOperation = client.get_type("AssetOperation")
        asset: Asset = operation.create
        page_feed_asset: PageFeedAsset = 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: AssetServiceClient = client.get_service("AssetService")
    response: MutateAssetsResponse = asset_service.mutate_assets(
        customer_id=customer_id, operations=operations
    )

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

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

    return resource_names
      

Ruby

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
      

پرل

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::V26::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::V26::Resources::Asset->new({
    pageFeedAsset => $page_feed_asset
  });

  push @$asset_operations,
    Google::Ads::GoogleAds::V26::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;
      

curl

گنجاندن نشانی‌های وب صفحه بسته در «مجموعه دارایی»

سپس، مجموعه‌ای از این دارایی‌ها (که نشان‌دهنده نشانی‌های وب گنجانده‌شده شما است) بااستفاده از AssetSet با type تنظیم‌شده روی PAGE_FEED ایجاد کنید. این گروه‌بندی نشان‌دهنده همه نشانی‌های وبی است که باید برای پویشی خاص درنظر گرفته شود. یک Asset می‌تواند به چندین شیء AssetSet تعلق داشته باشد.

ابتدا، AssetSet جدیدی ایجاد کنید:

جاوا

// 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.V26.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: GoogleAdsClient, customer_id: str) -> str:
    """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: AssetSetOperation = client.get_type("AssetSetOperation")
    # Creates an asset set which will be used to link the dynamic page feed
    # assets to a campaign.
    asset_set: AssetSet = 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: AssetSetServiceClient = client.get_service(
        "AssetSetService"
    )
    response: MutateAssetSetsResponse = asset_set_service.mutate_asset_sets(
        customer_id=customer_id, operations=[operation]
    )

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

Ruby

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
      

پرل

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

# Create an operation to add the AssetSet.
my $operation =
  Google::Ads::GoogleAds::V26::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;
      

curl

سپس، دارایی‌های فید صفحه‌تان را بااستفاده از AssetSetAsset به AssetSet پیوند دهید:

جاوا

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.V26.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: GoogleAdsClient,
    customer_id: str,
    asset_resource_names: List[str],
    asset_set_resource_name: str,
) -> None:
    """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: List[AssetSetAssetOperation] = []
    for resource_name in asset_resource_names:
        # Creates an asset set asset operation and adds it to the list of
        # operations.
        operation: AssetSetAssetOperation = client.get_type(
            "AssetSetAssetOperation"
        )
        asset_set_asset: AssetSetAsset = 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: AssetSetAssetServiceClient = client.get_service(
        "AssetSetAssetService"
    )
    response: MutateAssetSetAssetsResponse = (
        asset_set_asset_service.mutate_asset_set_assets(
            customer_id=customer_id, operations=operations
        )
    )

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

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

Ruby

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
      

پرل

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

  # Create an operation to add the link.
  my $operation =
    Google::Ads::GoogleAds::V26::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;
      

curl

«مجموعه دارایی» را با پویشی مرتبط کنید

پس‌از جمع‌آوری دارایی‌ها در AssetSet، AssetSet را بااستفاده از CampaignAssetSet به پویش پیوند دهید. برای کنترل نحوه استفاده پویش از نشانی‌های وب فید صفحه‌تان، DynamicSearchAdsSetting.use_supplied_urls_only را در Campaign پیکربندی کنید (use_supplied_urls_only = true هدف‌یابی را فقط به نشانی‌های وب فید صفحه محدود می‌کند؛ false هم از نمایه Google دامنه‌تان و هم از نشانی‌های وب فید صفحه استفاده می‌کند):

جاوا

// 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.V26.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: GoogleAdsClient,
    customer_id: str,
    campaign_id: str,
    asset_set_resource_name: str,
) -> None:
    """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: GoogleAdsServiceClient = client.get_service(
        "GoogleAdsService"
    )
    # Creates a campaign asset set representing the link between an asset set
    # and a campaign.
    operation: CampaignAssetSetOperation = client.get_type(
        "CampaignAssetSetOperation"
    )
    campaign_asset_set: CampaignAssetSet = 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: CampaignAssetSetServiceClient = (
        client.get_service("CampaignAssetSetService")
    )
    response: MutateCampaignAssetSetsResponse = (
        campaign_asset_set_service.mutate_campaign_asset_sets(
            customer_id=customer_id, operations=[operation]
        )
    )

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

Ruby

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
      

پرل

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

# Create an operation to add the CampaignAssetSet.
my $operation =
  Google::Ads::GoogleAds::V26::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;
      

curl

توصیه‌شده: دربرگیری‌های نشانی وب هدف را بااستفاده از برچسب‌های سفارشی هدف‌یابی کنید

می‌توانید به‌طور اختیاری از برچسب‌های سفارشی (page_feed_asset.labels) برای هدف‌یابی و پیشنهاد قیمت برای زیرمجموعه‌های خاصی از دربرگیری‌های نشانی وب خود استفاده کنید. یک AdGroupCriterion با WebpageInfo (تنظیم criterion_name الزامی) ایجاد کنید که بااستفاده از شرطی فیلتر می‌کند که operand آن روی WebpageConditionOperand.CUSTOM_LABEL تنظیم شده است و argument آن روی رشته برچسب هدف تنظیم شده است:

جاوا

String adGroupResourceName = ResourceNames.adGroup(params.customerId, params.adGroupId);

// Creates the webpage condition info that targets an advertiser's webpages based on the
// custom label specified by the dsaPageUrlLabel (e.g. "discounts").
WebpageConditionInfo webpageConditionInfo =
    WebpageConditionInfo.newBuilder()
        .setOperand(WebpageConditionOperand.CUSTOM_LABEL)
        .setArgument(dsaPageUrlLabel)
        .build();

// Creates the webpage info, or criterion for targeting webpages of an advertiser's website.
WebpageInfo webpageInfo =
    WebpageInfo.newBuilder()
        .setCriterionName("Test Criterion")
        .addAllConditions(ImmutableList.of(webpageConditionInfo))
        .build();

// Creates the ad group criterion.
AdGroupCriterion adGroupCriterion =
    AdGroupCriterion.newBuilder()
        .setAdGroup(adGroupResourceName)
        .setWebpage(webpageInfo)
        .setCpcBidMicros(1_500_000)
        .build();

// Creates the operation.
AdGroupCriterionOperation operation =
    AdGroupCriterionOperation.newBuilder().setCreate(adGroupCriterion).build();

// Creates the service client.
try (AdGroupCriterionServiceClient adGroupCriterionServiceClient =
    googleAdsClient.getLatestVersion().createAdGroupCriterionServiceClient()) {
  // Adds the ad group criterion.
  MutateAdGroupCriteriaResponse response =
      adGroupCriterionServiceClient.mutateAdGroupCriteria(
          Long.toString(params.customerId), ImmutableList.of(operation));

  // Displays the results.
  System.out.printf(
      "Created ad group criterion with resource name '%s'.%n",
      response.getResults(0).getResourceName());
}
      

C#‎

/// <summary>
/// Adds the DSA target.
/// </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="adGroupId">The ad group to which DSA label targeting is added.</param>
/// <param name="dsaPageUrlLabel">The DSA page URL label.</param>
private static void AddDsaTarget(
    GoogleAdsClient client, long customerId, long adGroupId, string dsaPageUrlLabel)
{
    AdGroupCriterionServiceClient adGroupCriterionService = client.GetService(
        Services.V26.AdGroupCriterionService);

    string adGroupResourceName = ResourceNames.AdGroup(customerId, adGroupId);

    // Creates the webpage condition info that targets an advertiser's webpages
    // based on the custom label specified by the dsaPageUrlLabel (e.g. "discounts").
    WebpageConditionInfo webpageConditionInfo = new WebpageConditionInfo()
    {
        Operand = WebpageConditionOperand.CustomLabel,
        Argument = dsaPageUrlLabel
    };

    // Creates the webpage info, or criterion for targeting webpages of an
    // advertiser's website.
    WebpageInfo webpageInfo = new WebpageInfo()
    {
        CriterionName = "Test Criterion",
        Conditions = { webpageConditionInfo }
    };

    // Creates the ad group criterion.
    AdGroupCriterion adGroupCriterion = new AdGroupCriterion()
    {
        AdGroup = adGroupResourceName,
        Webpage = webpageInfo,
        CpcBidMicros = 1_500_000
    };

    // Creates the operation.
    AdGroupCriterionOperation operation = new AdGroupCriterionOperation()
    {
        Create = adGroupCriterion
    };

    // Adds the ad group criterion.
    MutateAdGroupCriteriaResponse response =
        adGroupCriterionService.MutateAdGroupCriteria(
            customerId.ToString(), new[] { operation });

    string resourceName = response.Results[0].ResourceName;
    // Displays the results.
    Console.WriteLine($"Created ad group criterion with resource " +
        $"name '{resourceName}'.");
}
      

PHP

// Creates the webpage condition info that targets an advertiser's webpages based on the
// custom label specified by the DSA page URL label (e.g. "discounts").
$webpageConditionInfo = new WebpageConditionInfo(
    [
    'operand' => WebpageConditionOperand::CUSTOM_LABEL,
    'argument' => $dsaPageUrlLabel
    ]
);

// Creates the webpage info, or criterion for targeting webpages of an advertiser's website.
$webpageInfo = new WebpageInfo(
    [
    'criterion_name' => 'Test Criterion',
    'conditions' => [$webpageConditionInfo]
    ]
);

// Creates the ad group criterion.
$adGroupCriterion = new AdGroupCriterion(
    [
    'ad_group' => ResourceNames::forAdGroup($customerId, $adGroupId),
    'webpage' => $webpageInfo,
    'cpc_bid_micros' => 1_500_000
    ]
);

// Creates the ad group criterion operation.
$adGroupCriterionOperation = new AdGroupCriterionOperation();
$adGroupCriterionOperation->setCreate($adGroupCriterion);

// Issues a mutate request to add the ad group criterion and prints its information.
$adGroupCriterionServiceClient = $googleAdsClient->getAdGroupCriterionServiceClient();
$response = $adGroupCriterionServiceClient->mutateAdGroupCriteria(
    MutateAdGroupCriteriaRequest::build($customerId, [$adGroupCriterionOperation])
);
printf(
    "Created ad group criterion with resource name '%s'.%s",
    $response->getResults()[0]->getResourceName(),
    PHP_EOL
);
      

Python

def add_dsa_target(
    client: GoogleAdsClient,
    customer_id: str,
    ad_group_id: str,
    dsa_page_url_label: str,
) -> None:
    """Creates an ad group criterion targeting the DSA label.

    Args:
        client: an initialized GoogleAdsClient instance.
        customer_id: a client customer ID.
        ad_group_id: the ID for an Ad Group.
        dsa_page_url_label: the label for the DSA page URLs.
    """
    googleads_service: GoogleAdsServiceClient = client.get_service(
        "GoogleAdsService"
    )
    # Creates the ad group criterion.
    operation: AdGroupCriterionOperation = client.get_type(
        "AdGroupCriterionOperation"
    )
    criterion: AdGroupCriterion = operation.create
    criterion.ad_group = googleads_service.ad_group_path(
        customer_id, ad_group_id
    )
    criterion.cpc_bid_micros = 1500000
    # Creates the webpage info, or criterion for targeting webpages of an
    # advertiser's website.
    criterion.webpage.criterion_name = "Test Criterion"
    # Creates the webpage condition info that targets an advertiser's webpages
    # based on the custom label specified by the DSA page URL label
    # (e.g. "discounts").
    webpage_condition: WebpageConditionInfo = client.get_type(
        "WebpageConditionInfo"
    )
    webpage_condition.operand = (
        client.enums.WebpageConditionOperandEnum.CUSTOM_LABEL
    )
    webpage_condition.argument = dsa_page_url_label
    criterion.webpage.conditions.append(webpage_condition)

    # Issues a mutate request to add the ad group criterion and prints its
    # information.
    ad_group_criterion_service: AdGroupCriterionServiceClient = (
        client.get_service("AdGroupCriterionService")
    )
    response: MutateAdGroupCriteriaResponse = (
        ad_group_criterion_service.mutate_ad_group_criteria(
            customer_id=customer_id, operations=[operation]
        )
    )
    print(
        "Created ad group criterion with resource name: "
        f"'{response.results[0].resource_name}'"
    )
      

Ruby

def add_dsa_target(client, dsa_page_url_label, customer_id, ad_group_id)
  operation = client.operation.create_resource.ad_group_criterion do |agc|
    agc.ad_group = client.path.ad_group(customer_id, ad_group_id)
    agc.cpc_bid_micros = 1_500_000

    # Creates the webpage info, or criterion for targeting webpages of an
    # advertiser's website.
    agc.webpage = client.resource.webpage_info do |webpage|
      webpage.criterion_name = "Test Criterion"
      # Creates the webpage condition info that targets an advertiser's webpages
      # based on the custom label specified by the dsaPageUrlLabel
      # (e.g. "discounts").
      webpage.conditions << client.resource.webpage_condition_info do |wci|
        wci.operand = :CUSTOM_LABEL
        wci.argument = dsa_page_url_label
      end
    end
  end

  response = client.service.ad_group_criterion.mutate_ad_group_criteria(
    customer_id: customer_id,
    operations: [operation],
  )
  resource_name = response.results.first.resource_name
  puts "Created ad group criterion with resource name '#{resource_name}'"
end
      

پرل

my $ad_group_resource_name =
  Google::Ads::GoogleAds::V26::Utils::ResourceNames::ad_group($customer_id,
  $ad_group_id);

# Create the webpage condition info that targets an advertiser's webpages based
# on the custom label specified by the $dsa_page_url_label (e.g. "discounts").
my $webpage_condition_info =
  Google::Ads::GoogleAds::V26::Common::WebpageConditionInfo->new({
    operand  => CUSTOM_LABEL,
    argument => $dsa_page_url_label
  });

# Create the webpage info, or criterion for targeting webpages of an advertiser's website.
my $webpage_info = Google::Ads::GoogleAds::V26::Common::WebpageInfo->new({
    criterionName => "Test Criterion",
    conditions    => [$webpage_condition_info]});

# Create the ad group criterion.
my $ad_group_criterion =
  Google::Ads::GoogleAds::V26::Resources::AdGroupCriterion->new({
    adGroup      => $ad_group_resource_name,
    webpage      => $webpage_info,
    cpcBidMicros => 1_500_000
  });

# Create the operation.
my $operation =
  Google::Ads::GoogleAds::V26::Services::AdGroupCriterionService::AdGroupCriterionOperation
  ->new({
    create => $ad_group_criterion
  });

# Add the ad group criterion.
my $response = $api_client->AdGroupCriterionService()->mutate({
    customerId => $customer_id,
    operations => [$operation]});

# Display the results.
printf "Created ad group criterion with resource name '%s'.\n",
  $response->{results}[0]{resourceName};
      

curl