User Lists

Retrieve all user lists

function getAllUserLists() {
  var userlistIt = AdWordsApp.userlists().get();
  while (userlistIt.hasNext()){
    var userList = userlistIt.next();
    Logger.log('Name: ' + userList.getName() +
        ' Type: ' + userList.getType() +
        ' ID: ' + userList.getId());
    Logger.log(' Desc: ' + userList.getDescription() +
        ' IsOpen: ' + userList.isOpen() +
        ' MembershipLifeSpan: ' + userList.getMembershipLifeSpan());
    Logger.log(' SizeForDisplay: ' + userList.getSizeForDisplay() +
        ' SizeRangeForDisplay: ' + userList.getSizeRangeForDisplay());
    Logger.log(' SizeForSearch: ' + userList.getSizeForSearch() +
        ' SizeRangeForSearch: ' + userList.getSizeRangeForSearch());
    Logger.log(' IsReadOnly: ' + userList.isReadOnly() +
        ' IsEligibleForSearch: ' + userList.isEligibleForSearch() +
        ' IsEligibleForDisplay: ' + userList.isEligibleForDisplay());
    Logger.log(' ');
  }
}

Get the number of members in a user list

function getUserListMemberCount() {
  var iterator = AdWordsApp.userlists().get();
  while (iterator.hasNext()) {
    var userlist = iterator.next();
    Logger.log('User List [' + userlist.getName() + ']  has ' +
        userlist.getSizeForDisplay() +
        ' members for Search campaigns and  ' +
        userlist.getSizeRangeForDisplay() +
        ' members for Display campaigns.');
  }
}

Open a user list

function openUserLists() {
  var iterator = AdWordsApp.userlists().get();
  while (iterator.hasNext()) {
    var userlist = iterator.next();
    if (userlist.isClosed()) {
       userlist.open();
    }
  }
}

Retrieve search campaigns targeted by a user list

function getSearchCampaignsTargetedByUserList() {
  var userlistIterator = AdWordsApp.userlists().get();
  while (userlistIterator.hasNext()) {
    var userList = userlistIterator.next();
    var campaignIterator = userList.targetedCampaigns().get();
    var campaignNames = [];

    while (campaignIterator.hasNext()) {
      var campaign = campaignIterator.next();
      campaignNames.push(campaign.getName());
    }

    Logger.log("User List [" + userList.getName() +
        "]  is targeting [ " +
        campaignNames.join(',') + "]");
  }
}

发送以下问题的反馈:

此网页
AdWords Scripts
AdWords Scripts
需要帮助?请访问我们的支持页面