Hide

Ad Scheduling

Advertising, as is the case with most things in life, is all about timing. A lot of businesses have special advertising needs during certain times of day, and they'd like their customers to know about them at the right time.

Scheduling Ads with AdWords

There are mechanisms built into AdWords and the AdWords API to allow you to decide when to run your ads, automatically, without requiring you to manually enable and disable them; this is called Ad Scheduling.

Scheduling works at the campaign level, so it applies to all active ad groups and ads inside it. This is handled by CampaignCriterionService as one of its criterion types, AdSchedule.

Each AdScheduleCriterion not only allows you to define a number of properties such as day of week and starting/ending times, but also a bid modifier (formerly handled through CampaignTargetService's bid_multiplier). With bid modifiers you can increase or decrease your bids at certain times.

Code examples

To make sure the ads run mostly during opening hours, we would set displaying of ads to start a bit before opening and to end a little bit before closing:

// Obtain a campaignId you want to configure
Long campaignId =  Long.valueOf("INSERT_CAMPAIGN_ID_HERE");

// Closed on Sunday, so we don't configure an AdSchedule for Sunday.
DayOfWeek[] days = new DayOfWeek[] {DayOfWeek.MONDAY,
    DayOfWeek.TUESDAY,
    DayOfWeek.WEDNESDAY,
    DayOfWeek.THURSDAY,
    DayOfWeek.FRIDAY,
    DayOfWeek.SATURDAY};

List<CampaignCriterionOperation> operations = new ArrayList<CampaignCriterionOperation>();
for (int i = 0; i < 6; i++) {
  AdSchedule schedule = new AdSchedule();
  schedule.setDayOfWeek(days[i]);
  // Start at 8:45 am...
  schedule.setStartHour(8);
  schedule.setStartMinute(MinuteOfHour.FORTY_FIVE);
  // ... and end at 7:45 pm
  schedule.setEndHour(19);
  schedule.setEndMinute(MinuteOfHour.FORTY_FIVE);
  CampaignCriterionOperation operation = new CampaignCriterionOperation();
  CampaignCriterion campaignCriterion = new CampaignCriterion();

  campaignCriterion.setCampaignId(campaignId);
  campaignCriterion.setCriterion(schedule);
  // Run at normal bid rates
  campaignCriterion.setBidModifier(1.0);
  operation.setOperand(campaignCriterion);
  operation.setOperator(Operator.ADD);
  operations.add(operation);
}

CampaignCriterionReturnValue result =
    campaignCriterionService.mutate(operations
        .toArray(new CampaignCriterionOperation[operations.size()]));

In order to give customers fair warning about a special lunchtime deal, advertising would start early in the morning and increase significantly during the promotion hours:

// Obtain a campaignId you want to configure
Long campaignId = Long.valueOf("INSERT_CAMPAIGN_ID_HERE");

List<CampaignCriterionOperation> operations = new ArrayList<CampaignCriterionOperation>();
AdSchedule early = new AdSchedule();
AdSchedule peak = new AdSchedule();
CampaignCriterionOperation operationEarly = new CampaignCriterionOperation();
CampaignCriterion campaignCriterionEarly = new CampaignCriterion();
CampaignCriterionOperation operationPeak = new CampaignCriterionOperation();
CampaignCriterion campaignCriterionPeak = new CampaignCriterion();

// Sample schedule for Monday
early.setDayOfWeek(DayOfWeek.MONDAY);
peak.setDayOfWeek(DayOfWeek.MONDAY);
// Start at 8:00 am...
early.setStartHour(8);
early.setStartMinute(MinuteOfHour.ZERO);
// ... and run until promotion starts
early.setEndHour(12);
early.setEndMinute(MinuteOfHour.ZERO);
// Run at normal bid rates
campaignCriterionEarly.setBidModifier(1.0);

// Start higher bidding at noon...
peak.setStartHour(12);
peak.setStartMinute(MinuteOfHour.ZERO);
// ... and run until promotion ends...
peak.setEndHour(14);
peak.setEndMinute(MinuteOfHour.ZERO);
// ... at double the bid!
campaignCriterionPeak.setBidModifier(2.0);

campaignCriterionEarly.setCampaignId(campaignId);
campaignCriterionEarly.setCriterion(early);
campaignCriterionPeak.setCampaignId(campaignId);
campaignCriterionPeak.setCriterion(peak);

operationEarly.setOperand(campaignCriterionEarly);
operationEarly.setOperator(Operator.ADD);
operationPeak.setOperand(campaignCriterionPeak);
operationPeak.setOperator(Operator.ADD);
operations.add(operationEarly);
operations.add(operationPeak);

CampaignCriterionReturnValue result =
    campaignCriterionService.mutate(operations
        .toArray(new CampaignCriterionOperation[operations.size()]));

This example shows how you stop ads showing at a certain day. You need to send an AdSchedule with the same Id as the existing AdSchedule.

// Suppose you already have a schedule of 8:45 am to 7:45 pm for Monday to Saturday

// Obtain the campaignId and criterionId you want to configure
Long campaignId = Long.valueOf("INSERT_CAMPAIGN_ID_HERE");
Long criterionIdForSaturday = Long.valueOf("INSERT_CRITERION_ID_HERE");

List<CampaignCriterionOperation> removeOperations = new ArrayList<CampaignCriterionOperation>();

// Remove a schedule for Saturday
AdSchedule removeScheduleForSaturday = new AdSchedule();
removeScheduleForSaturday.setId(criterionIdForSaturday);

CampaignCriterionOperation removeOperation = new CampaignCriterionOperation();
CampaignCriterion removeCampaignCriterion = new CampaignCriterion();

removeCampaignCriterion.setCampaignId(campaignId);
removeCampaignCriterion.setCriterion(removeScheduleForSaturday);

removeOperation.setOperand(removeCampaignCriterion);
removeOperation.setOperator(Operator.REMOVE);
removeOperations.add(removeOperation);

CampaignCriterionReturnValue removeResult = campaignCriterionService.mutate(
    removeOperations.toArray(new CampaignCriterionOperation[removeOperations.size()]));

This example shows how you change the time ads are showing. You need to remove the existing AdSchedule first, then send a new one.

// Suppose you already have a schedule of 8:45 am to 7:45 pm for Monday to Saturday

// Obtain the campaignId and criterionId you want to configure
Long campaignId = Long.valueOf("INSERT_CAMPAIGN_ID_HERE");
Long criterionIdForFriday = Long.valueOf("INSERT_CRITERION_ID_HERE");

List<CampaignCriterionOperation> operations = new ArrayList<CampaignCriterionOperation>();

// Remove a schedule for Friday first
AdSchedule removeScheduleForFriday = new AdSchedule();
removeScheduleForFriday.setId(criterionIdForFriday);

CampaignCriterionOperation removeOperationForFriday = new CampaignCriterionOperation();
CampaignCriterion removeCampaignCriterionForFriday = new CampaignCriterion();

removeCampaignCriterionForFriday.setCampaignId(campaignId);
removeCampaignCriterionForFriday.setCriterion(removeScheduleForFriday);

removeOperationForFriday.setOperand(removeCampaignCriterionForFriday);
removeOperationForFriday.setOperator(Operator.REMOVE);
operations.add(removeOperationForFriday);

// Create a new schedule for Friday
AdSchedule addScheduleForFriday = new AdSchedule();
addScheduleForFriday.setDayOfWeek(DayOfWeek.FRIDAY);
// Start at 3:00 pm...
addScheduleForFriday.setStartHour(15);
addScheduleForFriday.setStartMinute(MinuteOfHour.ZERO);
// ... and end at 7:45 pm
addScheduleForFriday.setEndHour(19);
addScheduleForFriday.setEndMinute(MinuteOfHour.FORTY_FIVE);
CampaignCriterionOperation addOperationForFriday = new CampaignCriterionOperation();
CampaignCriterion campaignAddCriterionForFriday = new CampaignCriterion();

campaignAddCriterionForFriday.setCampaignId(campaignId);
campaignAddCriterionForFriday.setCriterion(addScheduleForFriday);
// Run at normal bid rates
campaignAddCriterionForFriday.setBidModifier(1.0);
addOperationForFriday.setOperand(campaignAddCriterionForFriday);
addOperationForFriday.setOperator(Operator.ADD);
operations.add(addOperationForFriday);

CampaignCriterionReturnValue result = campaignCriterionService.mutate(
    removeOperations.toArray(new CampaignCriterionOperation[operations.size()]));

You can check the code samples or the examples on your client library of choice to see how to use the CampaignCriterionService to add a target to an existing campaign.

Conclusion

By incorporating ad scheduling in your campaigns, you should be able to make the most out of your ads by having them show at the right time. That likely means better, more focused targeting and with higher returns.

Send feedback about...

AdWords API