I have a bunch of campaigns that I want to bulk edit ad schedule bid adjustments. How can I achieve that using Google Ads Script?
Here is a Google Ads script that takes an array of campaign IDs and sets bid adjustment as +1% for a given list of campaigns:
function main() {
var CAMPAIGN_IDS = [INSERT_YOUR_CAMPAIGN_IDS]; // Replace with your Campaign IDs
// Define time intervals
var timeIntervals = [
{startHour: 0, startMinute: 0, endHour: 4, endMinute: 0}, // 00:00 - 04:00
{startHour: 4, startMinute: 0, endHour: 8, endMinute: 0}, // 04:00 - 08:00
{startHour: 8, startMinute: 0, endHour: 12, endMinute: 0}, // 08:00 - 12:00
{startHour: 12, startMinute: 0, endHour: 16, endMinute: 0}, // 12:00 - 16:00
{startHour: 16, startMinute: 0, endHour: 20, endMinute: 0}, // 16:00 - 20:00
{startHour: 20, startMinute: 0, endHour: 24, endMinute: 0} // 20:00 - 24:00
];
// Define days of the week
var daysOfWeek = [
"MONDAY", "TUESDAY", "WEDNESDAY", "THURSDAY",
"FRIDAY", "SATURDAY", "SUNDAY"
];
// Loop through each campaign ID
for (var campaignIndex = 0; campaignIndex < CAMPAIGN_IDS.length; campaignIndex++) {
var campaignId = CAMPAIGN_IDS[campaignIndex];
// Retrieves the campaign by its ID.
var campaignIterator = AdsApp.campaigns()
.withIds([campaignId])
.get();
if (campaignIterator.hasNext()) {
var campaign = campaignIterator.next();
// Loop through each day of the week
for (var dayIndex = 0; dayIndex < daysOfWeek.length; dayIndex++) {
// Loop through each time interval and set bid adjustment
for (var timeIndex = 0; timeIndex < timeIntervals.length; timeIndex++) {
var timeInterval = timeIntervals[timeIndex];
campaign.addAdSchedule({
dayOfWeek: daysOfWeek[dayIndex],
startHour: timeInterval.startHour,
startMinute: timeInterval.startMinute,
endHour: timeInterval.endHour,
endMinute: timeInterval.endMinute,
bidModifier: 1.01 // 1% bid adjustment
});
}
}
}
}
}
Note: You need to update the bidModifier
value depending on your case.
Once you set the script, you can determine its frequency.