Yahoo!広告 スクリプト | Developer Center
English自動入札の学習データ除外
・自動入札の学習データ除外を取得する・自動入札の学習データ除外を追加する
・自動入札の学習データ除外を更新する
自動入札の学習データ除外を取得する
function getLearningDataExclusion() {
const accountId = AdsUtilities.getCurrentAccountId();
const learningDataExclusionMaster = Search.LearningDataExclusionService.get({
accountId: accountId
}).rval;
if (learningDataExclusionMaster.totalNumEntries == 0) {
Logger.log('Learning data exclusion for autobidding does not exist.');
return;
}
for (let i = 0; i < learningDataExclusionMaster.values.length; i++) {
let learningDataExclusion = learningDataExclusionMaster.values[i].learningDataExclusion;
Logger.log('learningDataExclusionId-> ' + learningDataExclusion.learningDataExclusionId
+ ', learningDataExclusionName-> ' + learningDataExclusion.learningDataExclusionName
+ ', startDateTime-> ' + learningDataExclusion.startDateTime
+ ', endDateTime-> ' + learningDataExclusion.endDateTime);
}
}
自動入札の学習データ除外を追加する
function addLearningDataExclusion() {
const accountId = AdsUtilities.getCurrentAccountId();
const operand = [{
accountId: accountId,
learningDataExclusionName: 'learningDataExclusionSetting1',
description:'description1',
devices: ['DESKTOP'],
startDateTime: '20240701000000',
endDateTime: '20240702000000',
campaignIds: [123456]
}]
const addedLearningDataExclusion = Search.LearningDataExclusionService.add({
accountId: accountId,
operand: operand
}).rval;
for (let i = 0; i < addedLearningDataExclusion.values.length; i++) {
if (addedLearningDataExclusion.values[i].operationSucceeded) {
let learningDataExclusion = addedLearningDataExclusion.values[i].learningDataExclusion;
Logger.log('learningDataExclusionId-> ' + learningDataExclusion.learningDataExclusionId
+ ', learningDataExclusionName-> ' + learningDataExclusion.learningDataExclusionName
+ ', startDateTime-> ' + learningDataExclusion.startDateTime
+ ', endDateTime-> ' + learningDataExclusion.endDateTime + ' has been added.');
} else {
Logger.log('learningDataExclusionName-> ' + operand[i].learningDataExclusionName + ' could not be added.');
}
}
}
自動入札の学習データ除外を更新する
function setLearningDataExclusion() {
const accountId = AdsUtilities.getCurrentAccountId();
const learningDataExclusionName = 'learningDataExclusionSetting1';
const newDesctiption = 'New description';
const newDevices = ['DESKTOP', 'MOBILE', 'TABLET'];
const newStartDateTime = '20240720000000';//YYYYMMDDHHmmss
const newEndDateTime = '20240721000000';//YYYYMMDDHHmmss
const newCampaignIds = [123456, 234567];
//Since the ID cannot be confirmed on the Campaign Management Tool, identify the ID from the name.
const learningDataExclusionMaster = Search.LearningDataExclusionService.get({
accountId: accountId
}).rval;
if (learningDataExclusionMaster.totalNumEntries == 0) {
Logger.log('Learning data exclusion for autobidding does not exist.');
return;
}
let targetLearningDataExclusionId = 0;
for (let i = 0; i < learningDataExclusionMaster.values.length; i++) {
let learningDataExclusion = learningDataExclusionMaster.values[i].learningDataExclusion;
//Identify ID from Name
if (learningDataExclusion.learningDataExclusionName == learningDataExclusionName) {
targetLearningDataExclusionId = learningDataExclusion.learningDataExclusionId;
}
}
if (targetLearningDataExclusionId == 0) {
throw new Error('The Learning data exclusion for autobidding with the specified name does not exist.');
}
const operand = [{
accountId: accountId,
learningDataExclusionId: targetLearningDataExclusionId,
learningDataExclusionName: learningDataExclusionName,
description: newDesctiption,
devices: newDevices,
startDateTime: newStartDateTime,
endDateTime: newEndDateTime,
campaignIds: newCampaignIds
}]
const setLearningDataExclusion = Search.LearningDataExclusionService.set({
accountId: accountId,
operand: operand
}).rval;
for (let i = 0; i < setLearningDataExclusion.values.length; i++) {
if (setLearningDataExclusion.values[i].operationSucceeded) {
let learningDataExclusion = setLearningDataExclusion.values[i].learningDataExclusion;
Logger.log('learningDataExclusionId-> ' + learningDataExclusion.learningDataExclusionId
+ ', learningDataExclusionName-> ' + learningDataExclusion.learningDataExclusionName
+ ', startDateTime-> ' + learningDataExclusion.startDateTime
+ ', endDateTime-> ' + learningDataExclusion.endDateTime + ' has been updated.');
} else {
Logger.log('learningDataExclusionName-> ' + operand[i].learningDataExclusionName + ' could not be updateed.');
}
}
}