is there a way to bid adjust on time or date?

182 views
Skip to first unread message

Ken Dan Tinio

unread,
Feb 19, 2018, 12:57:38 AM2/19/18
to AdWords API Forum
I know its a weird question. I haven't come across of adjusting bidding on time and date. But do you guys think its possible?

Vincent Racaza (AdWords API Team)

unread,
Feb 19, 2018, 2:39:17 AM2/19/18
to AdWords API Forum
Hi Ken,

Are you referring to adjusting/setting bids based on a certain schedule? For example, if the day is Saturday, and the time is 5 pm to 7 pm, then you need to adjust/increase the bids. Is my assumption to your use-case correct? If so, then scheduling is not yet supported in the AdWords API. This said, you will need to manually implement a scheduling feature to update your bidsAnother recommendation would be to search other forums if there is a possible cron job that you can integrate with the current supported client libraries of the AdWords API.

As an alternative, you can also use AdWords Scripts as scheduling is supported in scripts. If you have clarifications regarding AdWords Scripts, you can post in this forum.

Thanks,
Vincent
AdWords API Team

Ken Dan Tinio

unread,
Feb 19, 2018, 3:02:47 AM2/19/18
to AdWords API Forum
How can I access my scripts via API? The scripts are really interesting. 

Vincent Racaza (AdWords API Team)

unread,
Feb 19, 2018, 3:39:27 AM2/19/18
to AdWords API Forum
Hi Ken,

You cannot access your AdWords Scripts via the AdWords API as they are of completely different implementations. You can run the AdWords Scripts via the AdWords UI only and the AdWords API can be ran via different platforms/applications.

Ken Dan Tinio

unread,
Feb 19, 2018, 4:11:16 AM2/19/18
to AdWords API Forum
is ad schedule available in the API?

Vincent Racaza (AdWords API Team)

unread,
Feb 19, 2018, 5:28:57 AM2/19/18
to AdWords API Forum
Hi Ken,

Yes, AdSchedule is available in the AdWords API in the campaign level only particularly in the CampaignCriterion object. However, ad scheduling is used to show your ad on a particular day and time. So if your goal is to always show your campaigns and just change the bids on a particular day and time, then AdSchedule is not appropriate for your use-case.

However, if your main goal is to show your ads only on a particular schedule and set the bids when your ads will be shown via bidModifier field, then AdSchedule is perfect for your use-case. You can check this example on how to set the bid modifier and you can just change the object being used. 

Ken Dan Tinio

unread,
Feb 19, 2018, 5:58:18 AM2/19/18
to AdWords API Forum
Thank you very much Vincent, I think this is the one that I'm looking for.

we can set startHour, startMinute, dayOfWeek, endHour and endMinute.


Ive check the example, I don't know which one to replace. I know I will be asking too much but, I don't really know how to use it. Can you please provide me an example. Please...

Ken Dan Tinio

unread,
Feb 19, 2018, 11:47:40 PM2/19/18
to AdWords API Forum
So far I have this..



class SetBidModifier {

  const CAMPAIGN_ID = '1010615735';
  // Bid modifiers are float number, not percentages, e.g., 1.5 means 50% more
  // bidding.
  const BID_MODIFIER = '1.5';

  public static function runExample(AdWordsServices $adWordsServices, AdWordsSession $session, $campaignId, $bidModifier) 
  {
    $campaignCriterionService = $adWordsServices->get($session, CampaignCriterionService::class);

    // Create a mobile platform. The ID can be found in the documentation.
    $mobile = new Platform();
    $mobile->setId(30001); // HighEndMobile = 30001

    $adsched = new AdSchedule();
    $adsched->setDayOfWeek(DayOfWeek::MONDAY);
    $adsched->setStartHour(24);
    $adsched->setStartMinute(MinuteOfHour::ZERO);
    $adsched->setEndHour(24);
    $adsched->setEndMinute(MinuteOfHour::ZERO);


    // Create a criterion with modified bid.
    $criterion = new CampaignCriterion();
    $criterion->setCampaignId($campaignId);
    $criterion->setCriterion($mobile);
    $criterion->setBidModifier($bidModifier);

    // Create a campaign criterion operation and add it to the operations list.
    $operation = new CampaignCriterionOperation();
    $operation->setOperator(Operator::SET);
    $operation->setOperand($criterion);
    $operations = [$operation];

    // Update campaign criteria on the server.
    $results = $campaignCriterionService->mutate($operations);

    // Print out some information about the updated campaign criterion.
    foreach ($results->getValue() as $campaignCriterion) {
      printf(
          "Campaign criterion with campaign ID %d, criterion ID %d, "
              . "and type '%s' was modified with bid %.2f.\n",
          $campaignCriterion->getCampaignId(),
          $campaignCriterion->getCriterion()->getId(),
          $campaignCriterion->getCriterion()->getType(),
          $campaignCriterion->getBidModifier());
    }
  }

  public static function main() 
  {
    // Generate a refreshable OAuth2 credential for authentication.
    $oAuth2Credential = (new OAuth2TokenBuilder())
        ->fromFile()
        ->build();

    // Construct an API session configured from a properties file and the OAuth2
    // credentials above.
    $session = (new AdWordsSessionBuilder())
        ->fromFile()
        ->withOAuth2Credential($oAuth2Credential)
        ->build();
    self::runExample(new AdWordsServices(), $session, intval(self::CAMPAIGN_ID), floatval(self::BID_MODIFIER));
  }
}


I just don't know how to pass the ad schedule to mutate.

Vincent Racaza (AdWords API Team)

unread,
Feb 20, 2018, 12:45:49 AM2/20/18
to AdWords API Forum
Hi Ken,

Since your main goal is to add an AdSchedule, then you need to use the ADD operator in your mutate() method as well as setting the criterion as AdSchedule instead of Platform. Also, you cannot set the startHour's value as 24 as this will generate an error since the field accepts 0 -23 values. Below is the code snippet that works on my end that you can use as reference:

$adsched = new AdSchedule();
$adsched
->setDayOfWeek(DayOfWeek::MONDAY);
$adsched->setStartHour(14);

$adsched
->setStartMinute(MinuteOfHour::ZERO);
$adsched
->setEndHour(24);
$adsched
->setEndMinute(MinuteOfHour::ZERO);

// Create a criterion with modified bid.
$criterion
= new CampaignCriterion();
$criterion
->setCampaignId($campaignId);
$criterion->setCriterion($adsched);

$criterion
->setBidModifier($bidModifier);

// Create a campaign criterion operation and add it to the operations list.
$operation
= new CampaignCriterionOperation();
$operation->setOperator(Operator::ADD);

$operation
->setOperand($criterion);
$operations
= [$operation];

Try this on your end and let me know if this works.

Ken Dan Tinio

unread,
Feb 20, 2018, 1:03:10 AM2/20/18
to AdWords API Forum
Thank you so much for providing me this answer. I have just figure it all out as well. We have the same code. Thank you! thank you!
Reply all
Reply to author
Forward
0 new messages