Dynamic Ads for Search

Add a PageFeed
Upload of page feed asset data from Google Drive(Specify the file id)
Add a Campaign(Dynamic Ads for Search)

Add a PageFeed


function addPageFeedAssetSet() {
  const accountId = AdsUtilities.getCurrentAccountId();
  const pageFeedAssetSetArray = [
    {
      accountId: accountId,
      pageFeedAssetSetName: "商品listサンプル",
      domain: "http://example.yahoo.co.jp"
    }
  ];//Multiple selections are possible
  const pageFeedAssetSets = Search.PageFeedAssetSetService.add({
    accountId: accountId,
    operand: pageFeedAssetSetArray,
  }).rval;
  for (let i = 0; i < pageFeedAssetSets.values.length; i++) {
    if (pageFeedAssetSets.values[i].operationSucceeded) {
      let pageFeedAssetSet = pageFeedAssetSets.values[i].pageFeedAssetSet;
      Logger.log('pageFeedAssetSetId-> ' + pageFeedAssetSet.pageFeedAssetSetId + ' has been added.');
    } else {
      Logger.log('pageFeedAssetSetName-> ' + pageFeedAssetSetArray[i].pageFeedAssetSetName + ' could not be added.');
    }
  } 
}

Upload of page feed asset data from Google Drive(Specify the file id)


function uploadPageFeedAssetService() {
  const accountId = AdsUtilities.getCurrentAccountId();
  const pageFeedAssetSetId = 111111111;
  const fileId = '11111AAAAAbbbbb_-222222BBBBBccccc';
  const fileData = DriveApp.getFileById(fileId).getBlob().getBytes();
  const pageFeedAssetSets = Search.PageFeedAssetService.upload(
    accountId,
    'NEW_OR_REPLACE',
    pageFeedAssetSetId,
    fileData
  ).rval;
}

Add a Campaign(Dynamic Ads for Search)


function addDasCampaign() {
  const accountId = AdsUtilities.getCurrentAccountId();
  const campaignArray = [
    {
      accountId: accountId,
      biddingStrategyConfiguration: {
        biddingScheme: {
          biddingStrategyType: 'CPC',
        },
      },
      budget: {
        amount: 1000,
      },
      campaignName: 'campaignNameAAA',
      settings: [
        {
          dynamicAdsForSearchSetting: {
            pageFeedAssetSetIds: [
              12345
            ]
          },
          settingType: "DYNAMIC_ADS_FOR_SEARCH_SETTING",
        }
      ],
      userStatus: 'ACTIVE',
      type: "DYNAMIC_ADS_FOR_SEARCH",
    }
  ];//Multiple selections are possible
  const campaigns = Search.CampaignService.add({
    accountId: accountId,
    operand: campaignArray,
  }).rval;
  for (let i = 0; i < campaigns.values.length; i++) {
    if (campaigns.values[i].operationSucceeded) {
      let campaign = campaigns.values[i].campaign;
      Logger.log('campaignId-> ' + campaign.campaignId + ', campaignName-> ' + campaign.campaignName + ' has been added.');
    } else {
      Logger.log('campaignName-> ' + campaignArray[i].campaignName + ' could not be added.');
    }
  }
}