사용자 목록

모든 사용자 목록 검색

function getAllUserLists() {
  const userLists = AdsApp.userlists().get();
  console.log(`${userLists.totalNumEntities()} user lists found.`);
  return userLists;
}

각 사용자 목록의 회원 수를 기록합니다.

function logUserListMemberCount() {
  const userlists = AdsApp.userlists().get();
  for (const userlist of userlists) {
    console.log(`${userlist.getName()} has ${userlist.getSizeForSearch()} `
        + `members for Search campaigns and ${userlist.getSizeForDisplay()} `
        + `members for Display campaigns.`);
  }
}

사용자 목록 열기

function openUserList(name) {
  const userlists = AdsApp.userlists()
      .withCondition(`user_list.name = '${name}'`)
      .get();
  if (userlists.totalNumEntities() == 0) {
    throw new Error(`No user list with name '${name}' found.`);
  }
  const userlist = userlists.next();
  userlist.open();
}

사용자 목록으로 타겟팅된 검색 캠페인 검색

function getSearchCampaignsTargetedByUserList(name) {
  const userlists = AdsApp.userlists()
      .withCondition(`user_list.name = '${name}'`)
      .get();
  if (userlists.totalNumEntities() == 0) {
    throw new Error(`No user list with name '${name}' found.`);
  }
  const userlist = userlists.next();
  const campaigns = userlist.targetedCampaigns().get();
  console.log(`Userlist '${name}' is targeting ${campaigns.totalNumEntities()} campaigns.`);
  return campaigns;
}