সমস্ত ভিডিও প্রচারাভিযান পুনরুদ্ধার করুন
function getAllVideoCampaigns() {
// AdsApp.videoCampaigns() will return all campaigns that are not
// removed by default.
const videoCampaignIterator = AdsApp.videoCampaigns().get();
console.log(`Total campaigns found : ${videoCampaignIterator.totalNumEntities()}`);
return videoCampaignIterator;
}
ব্যবহার
const videoCampaigns = getAllVideoCampaigns();
for (const videoCampaign of videoCampaigns) {
// Process your campaign.
}
এর নাম দিয়ে একটি ভিডিও প্রচারণা পুনরুদ্ধার করুন
function getVideoCampaignByName(campaignName) {
const videoCampaignIterator = AdsApp.videoCampaigns()
.withCondition(`campaign.name = "${campaignName}"`)
.get();
if (!videoCampaignIterator.hasNext()) {
throw new Error(`No video campaign with name ${campaignName} found.`);
}
const videoCampaign = videoCampaignIterator.next();
console.log(`Campaign Name: ${videoCampaign.getName()}`);
console.log(`Enabled: ${videoCampaign.isEnabled()}`);
console.log(`Bidding strategy: ${videoCampaign.getBiddingStrategyType()}`);
console.log(`Ad rotation: ${videoCampaign.getAdRotationType()}`);
console.log(`Start date: ${formatDate(videoCampaign.getStartDate())}`);
console.log(`End date: ${formatDate(videoCampaign.getEndDate())}`);
return videoCampaign;
}
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 getVideoCampaignStats(campaignName) {
const videoCampaignIterator = AdsApp.videoCampaigns()
.withCondition(`campaign.name = "${campaignName}"`)
.get();
if (!videoCampaignIterator.hasNext()) {
throw new Error(`No video campaign with name ${campaignName} found.`);
}
const videoCampaign = videoCampaignIterator.next();
// Fetch stats for the last month. See the DateRangeLiteral section at
// https://developers.google.com/google-ads/api/docs/query/date-ranges#predefined_date_range
// for possible values.
// 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 = videoCampaign.getStatsFor('LAST_MONTH');
console.log(`${videoCampaign.getName()}, ${stats.getImpressions()} impressions, ` +
`${stats.getViews()} views`);
return stats;
}
একটি ভিডিও প্রচার বিরতি
function pauseVideoCampaign(campaignName) {
const videoCampaignIterator = AdsApp.videoCampaigns()
.withCondition(`campaign.name = "${campaignName}"`)
.get();
if (videoCampaignIterator.hasNext()) {
const videoCampaign = videoCampaignIterator.next();
videoCampaign.pause();
}
}
একটি ভিডিও বিজ্ঞাপন গ্রুপ যোগ করুন
function addVideoAdGroup(campaignName, adGroupName) {
const videoCampaignIterator = AdsApp.videoCampaigns()
.withCondition(`campaign.name = "${campaignName}"`)
.get();
if (videoCampaignIterator.hasNext()) {
const videoCampaign = videoCampaignIterator.next();
const videoAdGroupOperation = videoCampaign.newVideoAdGroupBuilder()
.withName(adGroupName)
// This can also be:
// * VIDEO_EFFICIENT_REACH
// * VIDEO_NON_SKIPPABLE_IN_STREAM
// * VIDEO_RESPONSIVE
// * VIDEO_TRUE_VIEW_IN_DISPLAY
// Some types may only be usable in specific ad group types.
.withAdGroupType('VIDEO_TRUE_VIEW_IN_STREAM')
.withCpv(1.2)
.build();
}
}
একটি ভিডিও বিজ্ঞাপন গ্রুপ আপডেট করুন
function updateAdGroup(adGroupName) {
const videoAdGroupIterator = AdsApp.videoAdGroups()
.withCondition(`ad_group.name = "${adGroupName}"`)
.get();
if (videoAdGroupIterator.hasNext()) {
const videoAdGroup = videoAdGroupIterator.next();
videoAdGroup.bidding().setCpv(1.2);
// update other properties as required here
}
}
সমস্ত ভিডিও বিজ্ঞাপন গ্রুপ পুনরুদ্ধার করুন
function getAllVideoAdGroups() {
// AdsApp.videoAdGroups() will return all ad groups that are not removed by
// default.
const videoAdGroupIterator = AdsApp.videoAdGroups().get();
console.log(`Total adGroups found : ${videoAdGroupIterator.totalNumEntities()}`);
return videoAdGroupIterator;
}
নামের একটি ভিডিও বিজ্ঞাপন গ্রুপ পুনরুদ্ধার করুন
function getVideoAdGroupByName(adGroupName) {
const videoAdGroupIterator = AdsApp.videoAdGroups()
.withCondition(`ad_group.name = "${adGroupName}"`)
.get();
if (!videoAdGroupIterator.hasNext()) {
throw new Error(`No video ad group found with name ${adGroupName}.`);
}
const videoAdGroup = videoAdGroupIterator.next();
console.log('AdGroup Name: ' + videoAdGroup.getName());
console.log('AdGroup Type: ' + videoAdGroup.getAdGroupType());
console.log('Enabled: ' + videoAdGroup.isEnabled());
return videoAdGroup;
}
একটি ভিডিও বিজ্ঞাপন গোষ্ঠীর পরিসংখ্যান পুনরুদ্ধার করুন৷
function getVideoAdGroupStats(adGroupName) {
const videoAdGroupIterator = AdsApp.videoAdGroups()
.withCondition(`ad_group.name = "${adGroupName}"`)
.get();
if (!videoAdGroupIterator.hasNext()) {
throw new Error(`No video ad group found with name ${adGroupName}.`);
}
const videoAdGroup = videoAdGroupIterator.next();
// You can also request reports for pre-defined date ranges. See
// https://developers.google.com/google-ads/api/docs/query/date-ranges#predefined_date_range
// for possible values.
const stats = videoAdGroup.getStatsFor('LAST_MONTH');
console.log(`${videoAdGroup.getName()}, ${stats.getImpressions()}, ${stats.getViews()}`);
return stats;
}
একটি ভিডিও বিজ্ঞাপন গ্রুপ বিরতি
function pauseVideoAdGroup(adGroupName) {
const videoAdGroupIterator = AdsApp.videoAdGroups()
.withCondition(`ad_group.name = "${adGroupName}"`)
.get();
if (!videoAdGroupIterator.hasNext()) {
throw new Error(`No video ad group found with name ${adGroupName}.`);
}
const videoAdGroup = videoAdGroupIterator.next();
videoAdGroup.pause();
console.log(`AdGroup with name: ${videoAdGroup.getName()} ` +
`has paused status: ${videoAdGroup.isPaused()}`);
}
বিজ্ঞাপনে ব্যবহারের জন্য যেকোনো ভিডিও পুনরুদ্ধার করুন
function getVideo() {
// This will just get the first valid YouTube video in the account.
// It demonstrates how to filter to see if a video is valid for video ads.
const videos = AdsApp.adAssets().assets()
.withCondition("asset.type = YOUTUBE_VIDEO")
.get();
for (const video of videos) {
// You have to use a YouTube video for True View ads, so only return if
// the YouTubeVideoId exists.
if(video.getYouTubeVideoId()) {
return video;
}
}
return null;
}
একটি বিজ্ঞাপনে ব্যবহারের জন্য একটি নির্দিষ্ট ভিডিও পুনরুদ্ধার করুন
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 addInStreamVideoAd(adGroupName) {
// If you have multiple adGroups with the same name, this snippet will
// pick an arbitrary matching ad group each time. In such cases, just
// filter on the campaign name as well:
//
// AdsApp.videoAdGroups()
// .withCondition('Name = "INSERT_ADGROUP_NAME_HERE"')
// .withCondition('CampaignName = "INSERT_CAMPAIGN_NAME_HERE"')
const videoAdGroupIterator = AdsApp.videoAdGroups()
.withCondition(`ad_group.name = "${adGroupName}"`)
.get();
const video = getVideo(); // Defined above
if (videoAdGroupIterator.hasNext()) {
const videoAdGroup = videoAdGroupIterator.next();
videoAdGroup.newVideoAd().inStreamAdBuilder()
.withAdName("In Stream Ad")
.withDisplayUrl("http://www.example.com")
.withFinalUrl("http://www.example.com")
.withVideo(video)
.build();
}
}
একটি ইন-ফিড ভিডিও বিজ্ঞাপন যোগ করুন
function addInFeedVideoAd(adGroupName) {
const videoAdGroupIterator = AdsApp.videoAdGroups()
.withCondition(`ad_group.name = "${adGroupName}"`)
.get();
const video = getVideo(); // Defined above
if (videoAdGroupIterator.hasNext()) {
const videoAdGroup = videoAdGroupIterator.next();
videoAdGroup.newVideoAd().inFeedAdBuilder()
.withAdName("In-Feed Video Ad")
.withDescription1("Description line 1")
.withDescription2("Description line 2")
.withHeadline("Headline")
.withThumbnail("DEFAULT_THUMBNAIL")
.withVideo(video)
.build();
}
}
ভিডিও বিজ্ঞাপন গ্রুপে ভিডিও বিজ্ঞাপন বিরাম দিন
function pauseVideoAdsInVideoAdGroup(adGroupName) {
const videoAdGroupIterator = AdsApp.videoAdGroups()
.withCondition(`ad_group.name = "${adGroupName}"`)
.get();
if (videoAdGroupIterator.hasNext()) {
const videoAdGroup = videoAdGroupIterator.next();
const videoAdsIterator = videoAdGroup.videoAds().get();
for (const videoAd of videoAdsIterator) {
videoAd.pause();
}
}
}
ভিডিও বিজ্ঞাপন গোষ্ঠীতে ভিডিও বিজ্ঞাপনগুলি পুনরুদ্ধার করুন৷
function getInStreamAdsInVideoAdGroup(adGroupName) {
const videoAdGroupIterator = AdsApp.videoAdGroups()
.withCondition(`ad_group.name = "${adGroupName}"`)
.get();
if (!videoAdGroupIterator.hasNext()) {
throw new Error(`No video ad group found with name ${adGroupName}.`);
}
const videoAdGroup = videoAdGroupIterator.next();
const videoAdsIterator = videoAdGroup.videoAds()
.withCondition('Type="TRUE_VIEW_IN_STREAM_VIDEO_AD"').get();
console.log(`Total ads found : ${videoAdsIterator.totalNumEntities()}`);
return videoAdsIterator;
}
function logVideoAd(videoAd) {
// Note that not all fields are populated for both video ad types.
console.log('Video ID : ' + videoAd.getVideoId());
console.log('Headline : ' + videoAd.getHeadline());
console.log('Line1 : ' + videoAd.getDescription1());
console.log('Line2 : ' + videoAd.getDescription2());
console.log('Final URL : ' + videoAd.urls().getFinalUrl());
console.log('Display URL : ' + videoAd.getDisplayUrl());
console.log('Destination Page : ' + videoAd.getDestinationPage());
console.log('Approval Status : ' + videoAd.getApprovalStatus());
console.log('Enabled : ' + videoAd.isEnabled());
}
একটি ভিডিও বিজ্ঞাপন গ্রুপ থেকে বিজ্ঞাপন পরিসংখ্যান পুনরুদ্ধার করুন
function getVideoAdGroupAdStats(adGroupName) {
let statsList = [];
const videoAdGroupIterator = AdsApp.videoAdGroups()
.withCondition(`ad_group.name = "${adGroupName}"`)
.get();
if (videoAdGroupIterator.hasNext()) {
const videoAdGroup = videoAdGroupIterator.next();
const videoAdsIterator = videoAdGroup.videoAds().get();
for (const videoAd of videoAdsIterator) {
// You can also request reports for pre-defined date ranges. See
// https://developers.google.com/google-ads/api/docs/query/date-ranges#predefined_date_range
// for possible values.
const stats = videoAd.getStatsFor('LAST_MONTH');
console.log(`${videoAdGroup.getName()}, ${stats.getViews()}, ${stats.getImpressions()}`);
statsList.push(stats);
}
}
return statsList;
}
একটি ভিডিও বিজ্ঞাপন গ্রুপে ইন-মার্কেট দর্শক যোগ করুন
function addInMarketAudienceToVideoAdGroup() {
const ag = AdsApp.videoAdGroups()
.withCondition('campaign.status != REMOVED')
.get()
.next();
console.log(`AdGroup ID ${ag.getId()}, Campaign ID ${ag.getVideoCampaign().getId()}`);
// Get the audience ID from the list here:
// https://developers.google.com/google-ads/api/reference/data/codes-formats#in-market-categories
const audience = ag.videoTargeting()
.newAudienceBuilder()
.withAudienceId(80428)
.withAudienceType('USER_INTEREST')
.build();
console.log('Added Audience ID %s', audience.getResult().getId().toString());
const audiences = ag.videoTargeting().audiences().get();
for (const aud of audiences) {
console.log('Retrieved Audience ID %s', aud.getId().toString());
}
}