কর্মক্ষমতা সর্বোচ্চ

সব পারফরম্যান্স সর্বোচ্চ প্রচারাভিযান পুনরুদ্ধার করুন

function getAllPerformanceMaxCampaigns() {
  // AdsApp.performanceMaxCampaigns() will return all campaigns that are not
  // removed by default.
  const performanceMaxCampaignIterator = AdsApp.performanceMaxCampaigns().get();
  console.log(`Total campaigns found : ${performanceMaxCampaignIterator.totalNumEntities()}`);
  return performanceMaxCampaignIterator;
}

এটির নামে একটি পারফরম্যান্স সর্বাধিক প্রচারাভিযান পুনরুদ্ধার করুন৷

function getPerformanceMaxCampaignByName(campaignName) {
  const performanceMaxCampaignIterator = AdsApp.performanceMaxCampaigns()
      .withCondition(`campaign.name = "${campaignName}"`)
      .get();
  if (!performanceMaxCampaignIterator.hasNext()) {
    throw new Error(`No performance max campaign with name ${campaignName} found.`);
  }
  const performanceMaxCampaign = performanceMaxCampaignIterator.next();
  console.log(`Campaign Name: ${performanceMaxCampaign.getName()}`);
  console.log(`Enabled: ${performanceMaxCampaign.isEnabled()}`);
  console.log(`Bidding strategy: ${performanceMaxCampaign.getBiddingStrategyType()}`);
  console.log(`Ad rotation: ${performanceMaxCampaign.getAdRotationType()}`);
  console.log(`Start date: ${formatDate(performanceMaxCampaign.getStartDate())}`);
  console.log(`End date: ${formatDate(performanceMaxCampaign.getEndDate())}`);
  return performanceMaxCampaign;
}

function formatDate(date) {
  function zeroPad(number) { return Utilities.formatString('%02d', number); }
  return (date == null) ? 'None' : zeroPad(date.year) + zeroPad(date.month) +
      zeroPad(date.day);
}

একটি কর্মক্ষমতা সর্বাধিক প্রচারের পরিসংখ্যান পুনরুদ্ধার করুন

function getPerformanceMaxCampaignStats(campaignName) {
  const performanceMaxCampaignIterator = AdsApp.performanceMaxCampaigns()
      .withCondition(`campaign.name = "${campaignName}"`)
      .get();
  if (!performanceMaxCampaignIterator.hasNext()) {
    throw new Error(`No performance max campaign with name ${campaignName} found.`);
  }
  const performanceMaxCampaign = performanceMaxCampaignIterator.next();
  // Fetch stats for the last month. See the DateRangeLiteral section at
  // https://developers.google.com/adwords/api/docs/guides/awql#formal_grammar
  // for a list of all supported pre-defined date ranges.
  // Note: Reports can also be used to fetch stats. See
  // https://developers.google.com/google-ads/scripts/docs/features/reports
  // for more information.
  var stats = performanceMaxCampaign.getStatsFor('LAST_MONTH');
  console.log(`${performanceMaxCampaign.getName()}, ${stats.getImpressions()} impressions, ` +
      `${stats.getViews()} views`);
  return stats;
}

একটি পারফরম্যান্স সর্বোচ্চ প্রচারাভিযান থামান

function pausePerformanceMaxCampaign(campaignName) {
  const performanceMaxCampaignIterator = AdsApp.performanceMaxCampaigns()
      .withCondition(`campaign.name = "${campaignName}"`)
      .get();
  if (performanceMaxCampaignIterator.hasNext()) {
    const performanceMaxCampaign = performanceMaxCampaignIterator.next();
    performanceMaxCampaign.pause();
  }
}

তার নামে একটি সম্পদ গ্রুপ পুনরুদ্ধার করুন

function getAssetGroupByName(campaignName, assetGroupName) {
  // Defined above
  const performanceMaxCampaign = getPerformanceMaxCampaignByName(campaignName);
  if (performanceMaxCampaign == null) {
    return null;
  }
  const assetGroupIterator = performanceMaxCampaign.assetGroups()
      .withCondition(`asset_group.name = "${assetGroupName}"`)
      .get();
  if (!assetGroupIterator.hasNext()) {
    throw new Error(`No asset group found with name ${assetGroupName}.`);
  }
  return assetGroupIterator.next();
}

একটি সম্পদ গ্রুপ বিরতি

function pausePerformanceMaxAssetGroup(campaignName, assetGroupName) {
  // Defined above
  const assetGroup = getAssetGroupByName(campaignName, assetGroupName);
  assetGroup.pause();
  console.log(`AssetGroup with name: ${assetGroup.getName()} ` +
      `has paused status: ${assetGroup.isPaused()}`);
}

একটি সম্পদ গ্রুপে ব্যবহারের জন্য একটি নির্দিষ্ট ভিডিও পুনরুদ্ধার করুন

function getVideoByYouTubeId(youTubeVideoId) {
  // You can filter on the YouTubeVideoId if you already have that video in
  // your account to fetch the exact one you want right away.
  const videos = AdsApp.adAssets().assets()
      .withCondition(`asset.type = YOUTUBE_VIDEO AND ` +
          `asset.youtube_video_asset.youtube_video_id = '${youTubeVideoId}'`)
      .get();
  if (videos.hasNext()) {
    return videos.next();
  }
  return null;
}

একটি সম্পদ গ্রুপে একটি নির্দিষ্ট ভিডিও যোগ করুন

function addVideoToAssetGroup(youTubeVideoId, campaignName, assetGroupName) {
  // Defined above
  const video = getVideoByYouTubeId(youTubeVideoId);
  const assetGroup = getAssetGroupByName(campaignName, assetGroupName);
  assetGroup.addAsset(video, 'YOUTUBE_VIDEO');
}

একটি সম্পদ গ্রুপ থেকে একটি নির্দিষ্ট ভিডিও সরান

function removeVideoFromAssetGroup(youTubeVideoId, campaignName, assetGroupName) {
  // Defined above
  const video = getVideoByYouTubeId(youTubeVideoId);
  const assetGroup = getAssetGroupByName(campaignName, assetGroupName);
  assetGroup.removeAsset(video, 'YOUTUBE_VIDEO');
}