নেতিবাচক কীওয়ার্ড

একটি প্রচারাভিযানে নেতিবাচক শব্দ যোগ করুন

function addNegativeKeywordToCampaign(keyword, campaignName) {
  const campaignIterator = AdsApp.campaigns()
        .withCondition(`campaign.name = "${campaignName}"`)
        .get();
  if (campaignIterator.hasNext()) {
    const campaign = campaignIterator.next();
    campaign.createNegativeKeyword(keyword);
  } else {
    throw new Error(`Cannot find campaign with the name '${campaignName}'`);
  }
}

একটি প্রচারাভিযানে নেতিবাচক কীওয়ার্ড পান

function getNegativeKeywordsForCampaign(campaignName) {
  const campaignIterator = AdsApp.campaigns()
      .withCondition(`campaign.name = "${campaignName}"`)
      .get();
  if (campaignIterator.hasNext()) {
    const campaign = campaignIterator.next();
    const negativeKeywordIterator = campaign.negativeKeywords().get();
    console.log(`Found ${negativeKeywordIterator.totalNumEntities()} negative keywords.`);
    return negativeKeywordIterator;
  } else {
    throw new Error(`Cannot find campaign with the name '${campaignName}'`);
  }
}

একটি বিজ্ঞাপন গ্রুপে একটি নেতিবাচক কীওয়ার্ড যোগ করুন

function addNegativeKeywordToAdGroup(keyword, adGroupName) {
  const adGroupIterator = AdsApp.adGroups()
      .withCondition(`ad_group.name = "${adGroupName}"`)
      .get();
  if (!adGroupIterator.hasNext()) {
    throw new Error(`Cannot find ad group with the name '${adGroupName}'`);
  }
  if (adGroupIterator.totalNumEntities() > 1) {
    console.warn(`Found more than one ad group named '${adGroupName}', using the first one.`);
  }
  const adGroup = adGroupIterator.next();
  adGroup.createNegativeKeyword(keyword);
}

একটি বিজ্ঞাপন গ্রুপে নেতিবাচক কীওয়ার্ড পান

function getNegativeKeywordsForAdGroup(adGroupName) {
  const adGroupIterator = AdsApp.adGroups()
      .withCondition(`ad_group.name = "${adGroupName}"`)
      .get();
  if (!adGroupIterator.hasNext()) {
    throw new Error(`Cannot find ad group with the name '${adGroupName}'`);
  }
  if (adGroupIterator.totalNumEntities() > 1) {
    console.warn(`Found more than one ad group named '${adGroupName}', using the first one.`);
  }
  const adGroup = adGroupIterator.next();
  const negativeKeywordIterator = adGroup.negativeKeywords().get();
  if (negativeKeywordIterator.hasNext()) {
    const negativeKeyword = negativeKeywordIterator.next();
    console.log(`Found ${negativeKeywordIterator.totalNumEntities()} negative keywords.`);
    return negativeKeywordIterator;
  }
}