नकारात्मक कीवर्ड सूचियां

नाम के आधार पर नकारात्मक कीवर्ड सूची पाएं

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();
  }
}