제외 키워드 목록

이름별로 제외 키워드 목록 가져오기

function getNegativeKeywordList(name) {   const negativeKeywordLists = AdsApp.negativeKeywordLists()       .withCondition(`shared_set.name = "${name}"`)       .get();   if (!negativeKeywordLists.hasNext()) {     throw new Error(`Cannot find negative keyword list with name "${name}"`);   }    return negativeKeywordLists.next(); }

제외 키워드 목록을 새로 구성하여 캠페인에 추가

function addNegativeKeywordListToCampaign(campaignName, negativeKeywordListName) {   const negativeKeywordLists = AdsApp.negativeKeywordLists()       .withCondition(`shared_set.name = "${negativeKeywordListName}"`)       .get();   if (!negativeKeywordLists.hasNext()) {     throw new Error(`Cannot find negative keyword list with name "${negativeKeywordListName}"`);   }   const negativeKeywordList = negativeKeywordLists.next();    const campaigns = AdsApp.campaigns()       .withCondition(`campaign.name = "${campaignName}"`)       .get();   if (!campaigns.hasNext()) {     throw new Error(`Cannot find campaign with the name "${campaignName}"`);   }   const campaign = campaigns.next();   campaign.addNegativeKeywordList(negativeKeywordList); }

제외 키워드 목록에서 공유된 제외 키워드 모두 삭제

function removeAllNegativeKeywordsFromList(name) {   const negativeKeywordLists = AdsApp.negativeKeywordLists()       .withCondition(`shared_set.name = "${name}"`)       .get();   if (!negativeKeywordLists.hasNext()) {     throw new Error(`Cannot find negative keyword list with name "${name}"`);   }   const negativeKeywordList = negativeKeywordLists.next();    for (const negativeKeyword of negativeKeywordList.negativeKeywords()) {     negativeKeyword.remove();   } }