自動入札のスポット調整

自動入札のスポット調整を取得する
自動入札のスポット調整を追加する
自動入札のスポット調整を更新する

自動入札のスポット調整を取得する


function getBiddingSeasonality() {
  const accountId = AdsUtilities.getCurrentAccountId();
  const biddingSeasonality = Search.BiddingSeasonalityAdjustmentService.get({
    accountId: accountId
  }).rval;
  if (biddingSeasonality.totalNumEntries == 0) {
    Logger.log('Seasonality bid adjustment does not exist.');
    return;
  }
  for (let i = 0; i < biddingSeasonality.values.length; i++) {
    let biddingSeasonalityAdjustment = biddingSeasonality.values[i].biddingSeasonalityAdjustment;
    Logger.log('biddingSeasonalityAdjustmentId-> ' + biddingSeasonalityAdjustment.biddingSeasonalityAdjustmentId
      + ', biddingSeasonalityAdjustmentName-> ' + biddingSeasonalityAdjustment.biddingSeasonalityAdjustmentName
      + ', startDateTime-> ' + biddingSeasonalityAdjustment.startDateTime
      + ', endDateTime-> ' + biddingSeasonalityAdjustment.endDateTime);
  }
}

自動入札のスポット調整を追加する


function addBiddingSeasonality() {
  const accountId = AdsUtilities.getCurrentAccountId();
  let operand = [{
    accountId: accountId,
    biddingSeasonalityAdjustmentName: "biddingSeasonalityAdjustmentSetting1",
    devices: ["DESKTOP"],
    startDateTime: '20240712000000',//YYYYMMDDHHmmss
    endDateTime: '20240715000000',//YYYYMMDDHHmmss
    conversionRate: 1.2,//0.1~10
    campaignIds: [123456, 234567]
  }];
  const biddingSeasonality = Search.BiddingSeasonalityAdjustmentService.add({
    accountId: accountId,
    operand: operand
  }).rval;
  for (let i = 0; i < biddingSeasonality.values.length; i++) {
    if (biddingSeasonality.values[i].operationSucceeded) {
      let biddingSeasonalityAdjustment = biddingSeasonality.values[i].biddingSeasonalityAdjustment;
      Logger.log('biddingSeasonalityAdjustmentId-> ' + biddingSeasonalityAdjustment.biddingSeasonalityAdjustmentId
        + ', biddingSeasonalityAdjustmentName-> ' + biddingSeasonalityAdjustment.biddingSeasonalityAdjustmentName
        + ', startDateTime-> ' + biddingSeasonalityAdjustment.startDateTime
        + ',endDateTime-> ' + biddingSeasonalityAdjustment.endDateTime + ' has been added.');
    } else {
      Logger.log('biddingSeasonalityAdjustmentName-> ' + operand[i].biddingSeasonalityAdjustmentName + ' could not be added.');
    }
  }
}

自動入札のスポット調整を更新する


function setBiddingSeasonality() {
  const accountId = AdsUtilities.getCurrentAccountId();
  const biddingSeasonalityAdjustmentName = 'biddingSeasonalityAdjustmentSetting1';
  const newDesctiption = 'New description';
  const newDevices = ['DESKTOP', 'MOBILE', 'TABLET'];
  const newStartDateTime = '20240720000000';//YYYYMMDDHHmmss
  const newEndDateTime = '20240727000000';//YYYYMMDDHHmmss
  const newConversionRate = 0.8;//0.1~10
  const newCampaignIds = [123456, 234567];
  //Since the ID cannot be confirmed on the Campaign Management Tool, identify the ID from the name.
  const biddingSeasonalityMaster = Search.BiddingSeasonalityAdjustmentService.get({
    accountId: accountId
  }).rval;
  if (biddingSeasonalityMaster.totalNumEntries == 0) {
    throw new Error('Seasonality bid adjustment does not exist.');
  }
  let targetBiddingSeasonalityAdjustmentId = 0;
  for (let i = 0; i < biddingSeasonalityMaster.values.length; i++) {
    let biddingSeasonalityAdjustment = biddingSeasonalityMaster.values[i].biddingSeasonalityAdjustment;
    //Identify ID from Name
    if (biddingSeasonalityAdjustment.biddingSeasonalityAdjustmentName == biddingSeasonalityAdjustmentName) {
      targetBiddingSeasonalityAdjustmentId = biddingSeasonalityAdjustment.biddingSeasonalityAdjustmentId;
    }
  }
  if (targetBiddingSeasonalityAdjustmentId == 0) {
    throw new Error('The Seasonality bid adjustment with the specified name does not exist."');
  }
  let operand = [{
    accountId: accountId,
    biddingSeasonalityAdjustmentName: biddingSeasonalityAdjustmentName,
    biddingSeasonalityAdjustmentId: targetBiddingSeasonalityAdjustmentId,
    description: newDesctiption,
    devices: newDevices,
    startDateTime: newStartDateTime,
    endDateTime: newEndDateTime,
    conversionRate: newConversionRate,
    campaignIds: newCampaignIds
  }];
  const biddingSeasonality = Search.BiddingSeasonalityAdjustmentService.set({
    accountId: accountId,
    operand: operand
  }).rval;
  for (let i = 0; i < biddingSeasonality.values.length; i++) {
    if (biddingSeasonality.values[i].operationSucceeded) {
      let biddingSeasonalityAdjustment = biddingSeasonality.values[i].biddingSeasonalityAdjustment;
      Logger.log('biddingSeasonalityAdjustmentId-> ' + biddingSeasonalityAdjustment.biddingSeasonalityAdjustmentId
        + ', biddingSeasonalityAdjustmentName-> ' + biddingSeasonalityAdjustment.biddingSeasonalityAdjustmentName
        + ', startDateTime-> ' + biddingSeasonalityAdjustment.startDateTime
        + ', endDateTime-> ' + biddingSeasonalityAdjustment.endDateTime + ' has been updated.');
    } else {
      Logger.log('biddingSeasonalityAdjustmentName-> ' + operand[i].biddingSeasonalityAdjustmentName + ' could not be updated.');
    }
  }
}