অবস্থান

একটি দেশের জন্য একটি প্রচারাভিযান লক্ষ্য করুন

function targetFrance(campaignName) {
  const campaignIterator = AdsApp.campaigns()
      .withCondition(`campaign.name = "${campaignName}"`)
      .get();
  if (!campaignIterator.hasNext()) {
    throw new Error(`No campaign with name "${campaignName}" found`);
  }

  const campaign = campaignIterator.next();
  // Target France (location id = 2250) and set a bid modifier of +50%. See
  // https://developers.google.com/google-ads/api/reference/data/geotargets
  // for details.
  campaign.addLocation(2250, 1.5);
}

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

function getTargetedLocations(campaignName) {
  const campaignIterator = AdsApp.campaigns()
      .withCondition(`campaign.name = "${campaignName}"`)
      .get();
  if (!campaignIterator.hasNext()) {
    throw new Error(`No campaign with name "${campaignName}" found`);
  }

  const campaign = campaignIterator.next();
  return campaign.targeting().targetedLocations().get();
}

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

function untargetFrance(campaignName) {
  const campaignIterator = AdsApp.campaigns()
      .withCondition(`campaign.name = "${campaignName}"`)
      .get();
  if (!campaignIterator.hasNext()) {
    throw new Error(`No campaign with name "${campaignName}" found`);
  }

  const campaign = campaignIterator.next();
  // Remove targeting for France (location id = 2250). See
  // https://developers.google.com/google-ads/api/reference/data/geotargets
  // for details.
  const targetedLocationIterator = AdsApp.targeting()
      .targetedLocations()
      .withIds([[campaign.getId(), 2250]]).get();
  if (targetedLocationIterator.hasNext()) {
    targetedLocationIterator.next().remove();
  }
}