광고 일정
캠페인에 광고 일정 추가
function addAdSchedule(campaignName) {
const campaignIterator = AdsApp.campaigns()
.withCondition(`campaign.name = "${campaignName}"`)
.get();
if (campaignIterator.hasNext()) {
const campaign = campaignIterator.next();
// Add a schedule for Monday, 9AM to 5PM, bid modifier = 1.25.
campaign.addAdSchedule('MONDAY', 9, 0, 17, 0, 1.25);
// The bid modifier is optional, e.g.
// campaign.addAdSchedule('MONDAY', 9, 0, 17, 0);
// You can also add an adSchedule as a JSON object, or using
// an existing AdSchedule object.
// Add a schedule for Saturday, 7AM to 11AM, bid modifier = 1.1.
campaign.addAdSchedule({
dayOfWeek: 'SATURDAY',
startHour: 7,
startMinute: 0,
endHour: 11,
endMinute: 0,
bidModifier: 1.1
});
}
}
캠페인에서 광고 일정 가져오기
function getAdSchedules(campaignName) {
const campaignIterator = AdsApp.campaigns()
.withCondition(`campaign.name = "${campaignName}"`)
.get();
if (!campaignIterator.hasNext()) {
throw new Error(`No campaign with name ${campaignName} found.`);
}
const campaign = campaignIterator.next();
const adScheduleIterator = campaign.targeting().adSchedules().get();
console.log(`Campaign "${campaign.name}" has ${
adScheduleIterator.totalNumEntities()} ad schedules`);
return adScheduleIterator;
}
function formatSchedule(schedule) {
function zeroPad(number) { return Utilities.formatString('%02d', number); }
return schedule.getDayOfWeek() + ', ' +
schedule.getStartHour() + ':' + zeroPad(schedule.getStartMinute()) +
' to ' + schedule.getEndHour() + ':' + zeroPad(schedule.getEndMinute());
}
달리 명시되지 않는 한 이 페이지의 콘텐츠에는 Creative Commons Attribution 4.0 라이선스에 따라 라이선스가 부여되며, 코드 샘플에는 Apache 2.0 라이선스에 따라 라이선스가 부여됩니다. 자세한 내용은 Google Developers 사이트 정책을 참조하세요. 자바는 Oracle 및/또는 Oracle 계열사의 등록 상표입니다.
최종 업데이트: 2024-08-21(UTC)
[null,null,["최종 업데이트: 2024-08-21(UTC)"],[[["The provided code snippets demonstrate how to manage ad schedules for Google Ads campaigns using scripts."],["`addAdSchedule` function enables setting specific time slots and bid modifiers for campaigns, enhancing control over ad delivery."],["`getAdSchedules` function retrieves and displays existing ad schedules associated with a given campaign, aiding in schedule monitoring and management."],["Ad schedules can be defined using either direct parameters or a JSON object, offering flexibility in implementation."]]],[]]