動的検索連動型広告

ページフィードを新規追加する
Googleドライブからページフィードアセット情報をアップロード(ファイルIDを指定)
キャンペーンを新規追加する(動的検索連動型広告)

ページフィードを新規追加する


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.');
    }
  } 
}

Googleドライブからページフィードアセット情報をアップロード(ファイル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;
}

キャンペーンを新規追加する(動的検索連動型広告)


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.');
    }
  }
}