Display

Add a placement to an existing ad group


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

  // Other display criteria can be built in a similar manner using the
  // corresponding builder method in the AdWordsApp.Display,
  // AdWordsApp.CampaignDisplay or AdWordsApp.AdGroupDisplay class.
  var placementOperation = adGroup.display()
      .newPlacementBuilder()
      .withUrl('http://www.site.com')  // required
      .withCpc(0.50)                   // optional
      .build();
  var placement = placementOperation.getResult();
  Logger.log('Placement with id = %s and url = %s was created.',
      placement.getId(), placement.getUrl());
}

Retrieve all topics in an existing ad group


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

  // Other display criteria can be retrieved in a similar manner using
  // the corresponding selector methods in the AdWordsApp.Display,
  // AdWordsApp.CampaignDisplay or AdWordsApp.AdGroupDisplay class.
  var topicIterator = AdWordsApp.display()
      .topics()
      .withCondition('Impressions > 100')
      .forDateRange('LAST_MONTH')
      .orderBy('Clicks DESC')
      .get();

  while (topicIterator.hasNext()) {
    var topic = topicIterator.next();

    // The list of all topic IDs can be found on
    // https://developers.google.com/adwords/api/docs/appendix/verticals
    Logger.log('Topic with criterion id = %s and topic id = %s was ' +
        'found.', topic.getId().toFixed(0),
         topic.getTopicId().toFixed(0));
  }
}

Get stats for all audiences in an existing ad group


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

  // Other display criteria can be retrieved in a similar manner using
  // the corresponding selector methods in the AdWordsApp.Display,
  // AdWordsApp.CampaignDisplay or AdWordsApp.AdGroupDisplay class.
  var audienceIterator = adGroup.display()
      .audiences()
      .get();

  Logger.log('ID, Audience ID, Clicks, Impressions, Cost');

  while (audienceIterator.hasNext()) {
    var audience = audienceIterator.next();
    var stats = audience.getStatsFor('LAST_MONTH');

    // User List IDs (List IDs) are available on the details page of
    // a User List (found under the Audiences section of the Shared
    // Library)
    Logger.log('%s, %s, %s, %s, %s', audience.getId().toFixed(0),
       audience.getAudienceId(), stats.getClicks(),
       stats.getImpressions(), stats.getCost());
  }
}

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

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