Bidding

Get bidding strategies

function getBiddingStrategies() {
  var biddingStrategies = AdWordsApp.biddingStrategies().get();
  while (biddingStrategies.hasNext()) {
    var biddingStrategy = biddingStrategies.next();

    Logger.log('Bidding strategy with id = %s, name = %s and type = ' +
        '%s was found.', biddingStrategy.getId().toFixed(0),
        biddingStrategy.getName(), biddingStrategy.getType());
  }
}

Get bidding strategy by name

function getBiddingStrategyByName() {
  var biddingStrategies = AdWordsApp.biddingStrategies().withCondition(
      'Name="INSERT_BIDDING_STRATEGY_NAME_HERE"').get();
  while (biddingStrategies.hasNext()) {
    var biddingStrategy = biddingStrategies.next();

    var stats = biddingStrategy.getStatsFor('LAST_MONTH');

    Logger.log('Bidding strategy with id = %s, name = %s and type = ' +
        '%s was found.', biddingStrategy.getId().toFixed(0),
         biddingStrategy.getName(), biddingStrategy.getType());
    Logger.log('Clicks: %s, Impressions: %s, Cost: %s.',
        stats.getClicks(), stats.getImpressions(), stats.getCost());
  }
}

Set campaign bidding strategy

function setCampaignBiddingStrategy() {
  var campaign = AdWordsApp.campaigns()
      .withCondition('Name="INSERT_CAMPAIGN_NAME_HERE"')
      .get()
      .next();

  // You may also set a flexible bidding strategy for the campaign
  // using the setStrategy() method. Use the
  // AdWordsApp.biddingStrategies() method to retrieve flexible bidding
  // strategies in your account.
  campaign.bidding().setStrategy('MANUAL_CPM');
}

Clear ad group bidding strategy

function clearAdGroupBiddingStrategy() {
  var adGroup = AdWordsApp.adGroups()
      .withCondition('CampaignName = "INSERT_CAMPAIGN_NAME_HERE"')
      .withCondition('Name = "INSERT_ADGROUP_NAME_HERE"')
      .get()
      .next();
  adGroup.bidding().clearStrategy();
}

Set an ad group's default CPC bid

function setAdGroupDefaultCpcBid() {
  var adGroup = AdWordsApp.adGroups()
      .withCondition('CampaignName = "INSERT_CAMPAIGN_NAME_HERE"')
      .withCondition('Name = "INSERT_ADGROUP_NAME_HERE"')
      .get()
      .next();

  // This bid will only be used for auction if a corresponding cpc
  // bidding strategy is set to the ad group. E.g.
  //
  // adGroup.bidding().setStrategy('MANUAL_CPC');
  adGroup.bidding().setCpc(3.0);
}

Set a keyword's CPC bid

function setKeywordCpcBid() {
  var keyword = AdWordsApp.keywords()
    .withCondition('CampaignName = "INSERT_CAMPAIGN_NAME_HERE"')
    .withCondition('AdGroupName = "INSERT_ADGROUP_NAME_HERE"')
    .withCondition('KeywordText = "INSERT_KEYWORD_TEXT_HERE"')
    .get()
    .next();

  // This bid will only be used for auction if a corresponding cpc
  // bidding strategy is set to the parent ad group. E.g.
  //
  // adGroup.bidding().setStrategy('MANUAL_CPC');
  keyword.bidding().setCpc(3.0);
}

Оставить отзыв о...

Текущей странице
AdWords Scripts
AdWords Scripts
Нужна помощь? Обратитесь в службу поддержки.