Dynamic Search Ads Page Feeds

By default, Dynamic Search Ads (DSAs) are set up to target entire websites, or portions of them without focusing on specific page URLs. If you need better control over the URLs, you can use DSA page feeds to specify precisely which URLs to use with your Dynamic Search Ads. When you provide a page feed of your products and their landing pages, it helps Google Ads determine when to show your ads and where to direct people on your website.

There are two options for creating page feeds.

  1. Asset-based page feeds. This is the preferred way to create page feeds.
  2. Feed-based page feeds. This is the legacy Feed route for creating page feeds.

This document covers both options.

Migration to asset-based DSA

Auto-migration process

Google will automatically migrate any existing DSA page feeds after April 27, 2022. We highly recommend manually migrating your accounts before then.

After migration, there will be no link between auto-migrated assets and the feed items they were based on (there are no common IDs). Additionally, your systems will need to handle both legacy and asset-based page feeds in the meantime.

After the auto-migration process has run on your accounts, write access will be blocked to the legacy feeds.

Migration timeline

The following timeline outlines the key dates for the DSA page feed migration.

Asset-based types available Auto migration date
Google Ads API v9.0 (November 2021) April 27, 2022

Hybrid serving

During the migration to asset-based DSA, your account will work in a hybrid mode. Both the legacy feeds and asset-based feeds will continue to serve. If a campaign has both an asset-based feed and a legacy feed, then both will serve during the migration.

Frequently Asked Questions

Will there be any gap in reporting statistics during the migration?

Gaps in statistics can be avoided if both the old and new page feeds are created with an overlap. Page feed statistics are keyed by the URL, not the feed/asset ID. To make sure no gaps are introduced, create the assets (and link an AssetSet) before removing the old feeds. The Google auto-migration won't produce gaps.

Will the old feeds be removed?

Yes, eventually the old feeds will be removed.

Can I update labels without re-creating the asset?

Yes, labels can be updated with a normal UPDATE operation on the asset. This does not affect reporting statistics which are always keyed by URL.

Asset-based workflow for creating DSA page feeds

Create assets for each page on your website

First, create an Asset for each URL on your website.

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.V10.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(
    $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, dsa_page_url_label, customer_id):
    """Creates Assets to be used in a DSA page feed.

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

    Returns:
        a list of asset 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 = []
    for url in urls:
        operation = client.get_type("AssetOperation")
        page_feed_asset = operation.create.page_feed_asset
        page_feed_asset.page_url = url
        page_feed_asset.labels.append(dsa_page_url_label)
        operations.append(operation)

    asset_service = client.get_service("AssetService")
    response = asset_service.mutate_assets(
        customer_id=customer_id, operations=operations
    )

    resource_names = []
    for result in response.results:
        resource_name = result.resource_name
        print(f"Created 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
      

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

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

Package page feed assets into an AssetSet

Next, create a collection of assets known as an AssetSet. This grouping represents all the URLs that should be considered for a particular campaign. An Asset can be in multiple AssetSet objects.

First, create a new 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.V10.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(
    $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 AssetSet.

    The AssetSet will be used to link the dynamic page feed assets to a
    campaign.

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

    Returns:
        an asset set resource name.
    """
    operation = client.get_type("AssetSetOperation")
    asset_set = operation.create
    asset_set.name = f"My dynamic page feed {datetime.now()}"
    asset_set.type_ = client.enums.AssetSetTypeEnum.PAGE_FEED

    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 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
      

Perl

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

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

Then, create a link between your assets from above and the 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.V10.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(
    $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, asset_resource_names, asset_set_resource_name, customer_id
):
    """Adds an Asset to an AssetSet by creating an AssetSetAsset link.

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

    asset_set_asset_service = client.get_service("AssetSetAssetService")
    response = asset_set_asset_service.mutate_asset_set_assets(
        customer_id=customer_id, operations=operations
    )
    resource_name = response.results[0].resource_name
    print(f"Created asset set asset with resource name '{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
      

Perl

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

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

Associate the AssetSet with a campaign

Once assets are collected in an AssetSet, associate the PageFeedAsset with a campaign.

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.V10.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(
    $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, asset_set_resource_name, customer_id, campaign_id
):
    """Links an AssetSet to a Campaign by creating a CampaignAssetSet.

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

    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}'")
      

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
      

Perl

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

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

You can optionally use custom labels to target and bid on URLs in the page feed. This can be done by creating a criterion based on a WebpageInfo that filters using a condition that has its operand set as WebpageConditionOperand.CUSTOM_LABEL.

Java

private static void addDsaTarget(
    GoogleAdsClient googleAdsClient, long customerId, long adGroupId, String dsaPageUrlLabel) {
  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 =
      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(customerId), ImmutableList.of(operation));

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

C#

private void AddDsaTarget(GoogleAdsClient client, long customerId, long adGroupId,
    string dsaPageUrlLabel)
{
    // Get the AdGroupCriterionService.
    AdGroupCriterionServiceClient adGroupCriterionService = client.GetService(
        Services.V10.AdGroupCriterionService);

    // Create the webpage condition info.
    WebpageConditionInfo webpageConditionInfo = new WebpageConditionInfo()
    {
        Operand = WebpageConditionOperand.CustomLabel,
        Argument = dsaPageUrlLabel,
    };

    // Creates the webpage info.
    WebpageInfo webpageInfo = new WebpageInfo()
    {
        CriterionName = "Test Criterion",
        Conditions = { webpageConditionInfo }
    };

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

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

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

    // Display the results.
    foreach (MutateAdGroupCriterionResult result in mutateAdGroupCriteriaResponse.Results)
    {
        Console.WriteLine($"Created ad group criterion with resource name " +
            $"'{result.ResourceName}'.");
    }
}
      

PHP

public static function addDsaTarget(
    GoogleAdsClient $googleAdsClient,
    int $customerId,
    int $adGroupId,
    string $dsaPageUrlLabel
) {
    // Creates the webpage condition info.
    $webPageConditionInfo = new WebpageConditionInfo([
        'operand' => WebpageConditionOperand::CUSTOM_LABEL,
        'argument' => $dsaPageUrlLabel
    ]);

    // Creates the webpage info.
    $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' => 1500000
    ]);

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

    $adGroupCriterionServiceClient = $googleAdsClient->getAdGroupCriterionServiceClient();
    $response = $adGroupCriterionServiceClient->mutateAdGroupCriteria(
        $customerId,
        [$adGroupCriterionOperation]
    );

    $adGroupCriterionResourceName = $response->getResults()[0]->getResourceName();
    printf(
        "Created ad group criterion with resource name '%s'.%s",
        $adGroupCriterionResourceName,
        PHP_EOL
    );
}
      

Python

def _add_dsa_targeting(client, customer_id, ad_group_resource_name, label):
    """Adds Dynamic Search Ad targeting criteria to the given ad group.

    Args:
        client: an initialized GoogleAdsClient instance.
        customer_id: a client customer ID str.
        ad_group_resource_name: a resource_name str for an Ad Group.
        label: a Dynamic Search Ad URL label str.
    """
    # Retrieve a new ad group criterion operation object.
    ad_group_criterion_operation = client.get_type("AdGroupCriterionOperation")
    # Create a new ad group criterion.
    ad_group_criterion = ad_group_criterion_operation.create
    ad_group_criterion.ad_group = ad_group_resource_name
    # Set the custom bid for this criterion.
    ad_group_criterion.cpc_bid_micros = 1500000
    ad_group_criterion.webpage.criterion_name = "Test criterion"
    # Add a condition for label=specified_label_name
    webpage_criterion_info = client.get_type(
        "WebpageConditionInfo"
    )  # ad_group_criterion.webpage.conditions.add()
    webpage_criterion_info.argument = label
    webpage_criterion_info.operand = (
        client.enums.WebpageConditionOperandEnum.CUSTOM_LABEL
    )
    ad_group_criterion.webpage.conditions.append(webpage_criterion_info)

    # Retrieve the ad group criterion service.
    ad_group_criterion_service = client.get_service("AdGroupCriterionService")
    response = ad_group_criterion_service.mutate_ad_group_criteria(
        customer_id=customer_id, operations=[ad_group_criterion_operation]
    )
    resource_name = response.results[0].resource_name

    # Display the results.
    print(f"Created ad group criterion with resource_name: '{resource_name}'")
      

Ruby

def add_dsa_targeting(client, customer_id, ad_group_resource_name, label)
  webpage_condition_info = client.resource.webpage_condition_info do |wci|
    wci.operand = :CUSTOM_LABEL
    wci.argument = label
  end

  webpage_criterion = client.resource.webpage_info do |wi|
    wi.criterion_name = "Test criterion"
    wi.conditions << webpage_condition_info
  end

  ad_group_criterion = client.resource.ad_group_criterion do |agc|
    agc.ad_group = ad_group_resource_name
    agc.webpage = webpage_criterion
    agc.cpc_bid_micros = 1_500_000
  end

  op = client.operation.create_resource.ad_group_criterion(ad_group_criterion)

  response = client.service.ad_group_criterion.mutate_ad_group_criteria(
    customer_id: customer_id,
    operations: [op],
  )

  puts "Created ad group criterion with id: #{response.results.first.resource_name}"
end
      

Perl

sub add_dsa_target {
  my ($api_client, $customer_id, $ad_group_id, $dsa_page_url_label) = @_;

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

  # Create the webpage condition info.
  my $web_page_condition_info =
    Google::Ads::GoogleAds::V10::Common::WebpageConditionInfo->new({
      operand  => CUSTOM_LABEL,
      argument => $dsa_page_url_label
    });

  # Create the webpage info.
  my $web_page_info = Google::Ads::GoogleAds::V10::Common::WebpageInfo->new({
      criterionName => "Test Criterion",
      conditions    => [$web_page_condition_info]});

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

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

  my $ad_group_criteria_response =
    $api_client->AdGroupCriterionService()->mutate({
      customerId => $customer_id,
      operations => [$ad_group_criterion_operation]});

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

Legacy: Feed services-based workflow for creating DSA page feeds

To set up a DSA page feed with Feed services:

  1. Create a feed and populate it with page URLs.
  2. Set up the campaign to use the DSA page feed.
  3. Optional, but recommended: Add custom labels to the URLs in your page feed to categorize and organize the targets for your Dynamic Search Ads.

Create a page feed (legacy)

The first step in using DSA page feeds is to create a feed with the field criterion_type of the FeedMapping set as DSA_PAGE_FEED. The procedure is similar to that listed in our feed services guide, except for the following differences.

  1. DSA page feeds use the criterion_type field instead of the placeholder_type field to set the target of the FeedMapping.
  2. You only need to create the feed, populate the items, and map the feed to the DSA page feed criterion fields.
DsaPageFeedCriterionField Description Required? Data Type
PAGE_URL URL of the web page you want to target. Yes URL or URL_LIST
LABEL The labels that will help you target ads within your page feed.

It should not contain the following string patterns: *, >>, ==, &+.

No STRING_LIST

Set up the campaign for page feeds (legacy)

You can set up a DSA campaign to use page feeds by setting the feeds field of its DynamicSearchAdsSetting.

Start by retrieving the DynamicSearchAdSetting for your Dynamic Search Ad campaign.

Java

private static DynamicSearchAdsSetting getDsaSetting(
    GoogleAdsClient googleAdsClient, long customerId, long campaignId) {
  // Creates the query.
  String query =
      String.format(
          "SELECT campaign.id, "
              + " campaign.name, "
              + " campaign.dynamic_search_ads_setting.use_supplied_urls_only "
              + "FROM campaign "
              + "WHERE campaign.id = '%s'",
          campaignId);

  // Creates the request.
  SearchGoogleAdsRequest request =
      SearchGoogleAdsRequest.newBuilder()
          .setCustomerId(Long.toString(customerId))
          .setPageSize(PAGE_SIZE)
          .setQuery(query)
          .build();

  // Creates the service client.
  try (GoogleAdsServiceClient googleAdsServiceClient =
      googleAdsClient.getLatestVersion().createGoogleAdsServiceClient()) {
    // Issues the search request.
    SearchPagedResponse response = googleAdsServiceClient.search(request);

    // Throws an exception if the campaign is not a DSA campaign.
    // The server will return an error when trying to update the campaign with the DSA feed in
    // the following step if the campaign is not a DSA campaign. However, this
    // exception is easier to interpret.
    if (!response
        .getPage()
        .getResponse()
        .getResults(0)
        .getCampaign()
        .hasDynamicSearchAdsSetting()) {
      throw new IllegalArgumentException("Campaign with ID '%s' is not a DSA campaign.");
    }

    // Retrieves and returns the DSA setting.
    return response
        .getPage()
        .getResponse()
        .getResults(0)
        .getCampaign()
        .getDynamicSearchAdsSetting();
  }
}
      

C#

private DynamicSearchAdsSetting GetDsaSetting(GoogleAdsClient client, long customerId,
    long campaignId)
{
    // Get the GoogleAdsService.
    GoogleAdsServiceClient googleAdsService = client.GetService(
        Services.V10.GoogleAdsService);

    // Creates the query.
    // You must request all DSA fields in order to update the DSA settings in the
    // following step.
    string query =
        $@"SELECT
              campaign.id,
              campaign.name,
              campaign.dynamic_search_ads_setting.use_supplied_urls_only
          FROM
              campaign
          WHERE
              campaign.id = {campaignId}";

    GoogleAdsRow result = googleAdsService.Search(
        customerId.ToString(), query).FirstOrDefault();

    if (result == null)
    {
        throw new Exception("No campaign found with ID: " + campaignId);
    }

    // Gets the DSA settings.
    DynamicSearchAdsSetting dynamicSearchAdsSetting =
        result.Campaign.DynamicSearchAdsSetting;

    // Throws an exception if the campaign is not a DSA campaign.
    if (dynamicSearchAdsSetting == null)
    {
        throw new Exception($"Campaign with ID {campaignId} is not a DSA campaign.");
    }

    return dynamicSearchAdsSetting;
}
      

PHP

private static function getDsaSetting(
    GoogleAdsClient $googleAdsClient,
    int $customerId,
    int $campaignId
) {
    // Creates the query.
    $query = "SELECT campaign.id, campaign.name, " .
    "campaign.dynamic_search_ads_setting.use_supplied_urls_only " .
    "FROM campaign where campaign.id = $campaignId";

    $googleAdsServiceClient = $googleAdsClient->getGoogleAdsServiceClient();
    $response = $googleAdsServiceClient->search(
        $customerId,
        $query,
        ['pageSize' => self::PAGE_SIZE, 'returnTotalResultsCount' => true]
    );

    // Throws an exception if a campaign with the provided ID does not exist.
    if ($response->getPage()->getResponseObject()->getTotalResultsCount() === 0) {
        throw new \InvalidArgumentException("No campaign found with ID $campaignId");
    }

    /** @var Campaign $campaign */
    $campaign = $response->getPage()->getResponseObject()->getResults()[0]->getCampaign();
    $dynamicSearchAdsSetting = $campaign->getDynamicSearchAdsSetting();

    // Throws an exception if the campaign is not a DSA campaign.
    if (is_null($dynamicSearchAdsSetting)) {
        throw new \InvalidArgumentException(
            "Campaign with ID $campaignId is not a DSA campaign."
        );
    }

    return $dynamicSearchAdsSetting;
}
      

Python

def _update_campaign_dsa_setting(
    client, customer_id, campaign_id, feed_details
):
    """Updates the given campaign with the given feed details.

    Args:
        client: an initialized GoogleAdsClient instance.
        customer_id: a client customer ID str.
        campaign_id: a campaign ID str;
        feed_details: a FeedDetails instance with feed attribute information.
    """
    query = f"""
        SELECT
            campaign.id,
            campaign.name,
            campaign.dynamic_search_ads_setting.use_supplied_urls_only
        FROM
            campaign
        WHERE
            campaign.id = {campaign_id}
        LIMIT 1
    """

    ga_service = client.get_service("GoogleAdsService")
    search_request = client.get_type("SearchGoogleAdsRequest")
    search_request.customer_id = customer_id
    search_request.query = query

    results = ga_service.search(request=search_request)

    campaign = None
    for row in results:
        campaign = row.campaign
      

Ruby

def update_campaign_dsa_setting(client, customer_id, campaign_id, feed_details)
  query = <<~EOD
    SELECT
      campaign.id,
      campaign.name,
      campaign.dynamic_search_ads_setting.feeds
    FROM
      campaign
    WHERE
      campaign.id = #{campaign_id}
    LIMIT 1000
  EOD
  response = client.service.google_ads.search(
    customer_id: customer_id,
    query: query,
  )

  result = response.first
      

Perl

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

  # Create the query.
  # You must request all DSA fields in order to update the DSA settings in the
  # following step.
  my $search_query =
    "SELECT campaign.id, campaign.name, " .
    "campaign.dynamic_search_ads_setting.use_supplied_urls_only " .
    "FROM campaign where campaign.id = $campaign_id";

  my $search_response = $api_client->GoogleAdsService()->search({
    customerId => $customer_id,
    query      => $search_query,
    pageSize   => PAGE_SIZE
  });

  # Die if a campaign with the provided ID does not exist.
  die "No campaign found with ID $campaign_id.\n"
    if scalar @{$search_response->{results}} == 0;

  my $dynamic_search_ads_setting =
    $search_response->{results}[0]{campaign}{dynamicSearchAdsSetting};

  # Die if the campaign is not a DSA campaign.
  die "Campaign with ID $campaign_id is not a DSA campaign.\n"
    if not $dynamic_search_ads_setting;

  return $dynamic_search_ads_setting;
}
      

Next, set the page feeds by specifying their resource names in the feeds field of your campaign's DynamicSearchAdsSetting. You can optionally use the use_supplied_urls_only field to specify whether or not to use only the specified URLs for your Dynamic Search Ads.

Java

private static void updateCampaignDsaSetting(
    GoogleAdsClient googleAdsClient, long customerId, String feedResourceName, long campaignId) {
  // Retrieves the existing dynamic search ads settings for the campaign.
  DynamicSearchAdsSetting dsaSetting = getDsaSetting(googleAdsClient, customerId, campaignId);
  dsaSetting.toBuilder().addAllFeeds(ImmutableList.of(feedResourceName)).build();

  // Creates the campaign object to update.
  Campaign campaign =
      Campaign.newBuilder()
          .setResourceName(ResourceNames.campaign(customerId, campaignId))
          .setDynamicSearchAdsSetting(dsaSetting)
          .build();

  // Creates the update operation and sets the update mask.
  CampaignOperation operation =
      CampaignOperation.newBuilder()
          .setUpdate(campaign)
          .setUpdateMask(FieldMasks.allSetFieldsOf(campaign))
          .build();

  // Creates the service client.
  try (CampaignServiceClient campaignServiceClient =
      googleAdsClient.getLatestVersion().createCampaignServiceClient()) {
    // Updates the campaign.
    MutateCampaignsResponse response =
        campaignServiceClient.mutateCampaigns(
            Long.toString(customerId), ImmutableList.of(operation));

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

C#

private void UpdateCampaignDsaSetting(GoogleAdsClient client, long customerId,
    string feedResourceName, long campaignId)
{
    // Get the CampaignService.
    CampaignServiceClient campaignService = client.GetService(
        Services.V10.CampaignService);

    DynamicSearchAdsSetting dsaSetting = GetDsaSetting(client, customerId, campaignId);
    dsaSetting.Feeds.Add(feedResourceName);

    // Create the campaign.
    Campaign campaign = new Campaign()
    {
        ResourceName = ResourceNames.Campaign(customerId, campaignId),
        DynamicSearchAdsSetting = dsaSetting
    };

    // Create the operation.
    CampaignOperation operation = new CampaignOperation()
    {
        Update = campaign,
        UpdateMask = FieldMasks.AllSetFieldsOf(campaign)
    };

    // Update the campaign.
    MutateCampaignsResponse response =
        campaignService.MutateCampaigns(customerId.ToString(), new[] { operation });
    // Display the results.
    foreach (MutateCampaignResult mutateCampaignResult in response.Results)
    {
        Console.WriteLine($"Updated campaign with resourceName: " +
            $"'{mutateCampaignResult.ResourceName}'.");
    }
}
      

PHP

private static function updateCampaignDsaSetting(
    GoogleAdsClient $googleAdsClient,
    int $customerId,
    array $feedDetails,
    int $campaignId
) {
    // Retrieves the existing dynamic search ads settings for the campaign.
    $dsaSetting = self::getDsaSetting(
        $googleAdsClient,
        $customerId,
        $campaignId
    );

    $dsaSetting->setFeeds([$feedDetails['resource_name']]);

    // Creates the campaign object to be updated.
    $campaign = new Campaign([
        'resource_name' => ResourceNames::forCampaign($customerId, $campaignId),
        'dynamic_search_ads_setting' => $dsaSetting
    ]);

    // Creates the update operation and sets the update mask.
    $campaignOperation = new CampaignOperation();
    $campaignOperation->setUpdate($campaign);
    $campaignOperation->setUpdateMask(FieldMasks::allSetFieldsOf($campaign));

    // Updates the campaign.
    $campaignServiceClient = $googleAdsClient->getCampaignServiceClient();
    $response = $campaignServiceClient->mutateCampaigns(
        $customerId,
        [$campaignOperation]
    );

    // Displays the results.
    $campaignResourceName = $response->getResults()[0]->getResourceName();
    printf(
        "Updated campaign with resourceName: '%s'.%s",
        $campaignResourceName,
        PHP_EOL
    );
}
      

Python

# Retrieve a new campaign operation
campaign_operation = client.get_type("CampaignOperation")
# Copy the retrieved campaign onto the new campaign operation.
client.copy_from(campaign_operation.update, campaign)
updated_campaign = campaign_operation.update
# Use a page feed to specify precisely which URLs to use with your Dynamic
# Search ads.
updated_campaign.dynamic_search_ads_setting.feeds.append(
    feed_details.resource_name
)
client.copy_from(
    campaign_operation.update_mask,
    protobuf_helpers.field_mask(campaign._pb, updated_campaign._pb),
)

# Retrieve the campaign service.
campaign_service = client.get_service("CampaignService")
# Submit the campaign operation and update the campaign.
response = campaign_service.mutate_campaigns(
    customer_id=customer_id, operations=[campaign_operation]
)
resource_name = response.results[0].resource_name

# Display the results.
print(f"Updated campaign #{resource_name}")
      

Ruby

campaign = result.campaign

op = client.operation.update_resource.campaign(campaign) do
  campaign.dynamic_search_ads_setting.feeds << feed_details.resource_name
end

response = client.service.campaign.mutate_campaigns(
  customer_id: customer_id,
  operations: [op],
)
puts "Updated campaign #{response.results.first.resource_name}"
      

Perl

sub update_campaign_dsa_setting {
  my ($api_client, $customer_id, $feed_details, $campaign_id) = @_;

  # Retrieve the existing dynamic search ads settings for the campaign.
  my $dsa_setting = get_dsa_setting($api_client, $customer_id, $campaign_id);

  my $feed_resource_name = $feed_details->{resourceName};
  $dsa_setting->{feeds} = [$feed_resource_name];

  # Create the campaign object to be updated.
  my $campaign = Google::Ads::GoogleAds::V10::Resources::Campaign->new({
      resourceName =>
        Google::Ads::GoogleAds::V10::Utils::ResourceNames::campaign(
        $customer_id, $campaign_id
        ),
      dynamicSearchAdsSetting => $dsa_setting
    });

  # Create the update operation and set the update mask.
  my $campaign_operation =
    Google::Ads::GoogleAds::V10::Services::CampaignService::CampaignOperation->
    new({
      update     => $campaign,
      updateMask =>
        Google::Ads::GoogleAds::Utils::FieldMasks::all_set_fields_of($campaign)}
    );

  # Update the campaign.
  my $campaigns_response = $api_client->CampaignService()->mutate({
      customerId => $customer_id,
      operations => [$campaign_operation]});

  printf "Updated campaign with resource name: '%s'.\n",
    $campaigns_response->{results}[0]{resourceName};
}
      

These settings map to the Google Ads UI as follows.

use_supplied_urls_only feeds Google Ads UI Setting
false N/A Use Google's index of my website.
false One or more are specified. Use URLs from both Google’s index of my website and my page feed.
true One or more are specified. Use URLs from my page feed only.
true Empty or null. Not supported. The Google Ads API throws a SettingError.DYNAMIC_SEARCH_ADS_SETTING_AT_LEAST_ONE_FEED_ID_MUST_BE_PRESENT.