লেবেল

ব্যবহারকারীর অ্যাকাউন্ট থেকে সমস্ত লেবেল পান

function getAllLabels() {
  const labelIterator = AdsApp.labels().get();
  console.log(`Total labels found: ${labelIterator.totalNumEntities()}`);
  return labelIterator;
}

নামের একটি লেবেল পান

function getLabelByName(name) {
  const labelIterator = AdsApp.labels()
      .withCondition(`label.name = "${name}"`)
      .get();
  if (labelIterator.hasNext()) {
    const label = labelIterator.next();
    console.log(`Name: ${label.getName()}`);
    console.log(`Description: ${label.getDescription()}`);
    console.log(`Color: ${label.getColor()}`);
    console.log(`Number of campaigns: ${label.campaigns().get().totalNumEntities()}`);
    console.log(`Number of ad groups: ${label.adGroups().get().totalNumEntities()}`);
    console.log(`Number of ads: ${label.ads().get().totalNumEntities()}`);
    console.log(`Number of keywords: ${label.keywords().get().totalNumEntities()}`);
    return label;
  }
  return null;
}

প্রচারে একটি লেবেল প্রয়োগ করুন

function applyLabel(labelName, campaignName) {
  // Retrieve a campaign, and apply a label to it. Applying labels to other
  // object types is similar.
  const campaignIterator = AdsApp.campaigns()
      .withCondition(`campaign.name = "${campaignName}"`)
      .get();
  if (campaignIterator.hasNext()) {
    const campaign = campaignIterator.next();
    campaign.applyLabel(labelName);
  }
}

একটি প্রচারাভিযান থেকে একটি লেবেল সরান

function removeLabel(labelName, campaignName) {
   // Removing labels from other object types is similar.
   const campaignIterator = AdsApp.campaigns()
       .withCondition(`campaign.name = "${campaignName}"`)
       .get();
  if (campaignIterator.hasNext()) {
    const campaign = campaignIterator.next();
    campaign.removeLabel(labelName);
  }
}

ব্যবহারকারীর অ্যাকাউন্ট থেকে একটি লেবেল মুছুন

function deleteLabel(labelName) {
  const labelIterator = AdsApp.labels()
      .withCondition(`label.name = "${labelName}"`)
      .get();
  if (labelIterator.hasNext()) {
    const label = labelIterator.next();
    label.remove();
  }
}