একটি বিজ্ঞাপন কাস্টমাইজার ডেটা উৎস তৈরি করুন
function createMixersAdCustomizerSource() {
// This example snippet creates an ad customizer source named "Mixers", modeled after
// the example data shown at https://support.google.com/google-ads/answer/6072565.
const sourceName = 'Mixers';
// Ad Customizer attributes can be added one at a time with `addAttribute` or all at
// once with `addAttributes`.
const mixersSourceOperation = AdsApp.newAdCustomizerSourceBuilder()
.withName(sourceName)
.addAttribute('Model', 'text')
.addAttributes({
'Capacity': 'number',
'Type': 'text',
'Start_price': 'price',
'Sale_ends': 'date',
})
.build();
return mixersSourceOperation;
}
নাম অনুসারে একটি বিজ্ঞাপন কাস্টমাইজার ডেটা উৎস খুঁজুন
function getAdCustomizerSourceByName(sourceName) {
let sourceCount = 0;
let foundSource = null;
for (const source of AdsApp.adCustomizerSources()) {
if (source.getName() === sourceName) {
foundSource = source;
sourceCount += 1;
}
}
if (foundSource === null) {
throw new Error(`No Ad Customizer Source found with name "${sourceName}"`);
}
if (sourceCount > 1) {
console.warn(`Found ${sourceCount} Ad Customizer Sources with name "${sourceName}", returning just one of them`);
}
console.log(`Source "${foundSource.getName()}" has attributes ${foundSource.getAttributes()}`);
return foundSource;
}
একটি ডেটা উৎসের কাস্টমাইজার আইটেম পান
function getAdCustomizerItems(sourceName) {
let sourceCount = 0;
let foundSource = null;
for (const source of AdsApp.adCustomizerSources()) {
if (source.getName() === sourceName) {
foundSource = source;
sourceCount += 1;
}
}
if (foundSource === null) {
throw new Error(`No Ad Customizer Source found with name "${sourceName}"`);
}
if (sourceCount > 1) {
console.warn(`Found ${sourceCount} Ad Customizer Sources with name "${sourceName}", using just one of them`);
}
const itemIterator = foundSource.items().get();
console.log(`Source "${foundSource.getName()}" has ${itemIterator.totalNumEntities()} items`);
return itemIterator;
}
একটি বিজ্ঞাপন কাস্টমাইজার আইটেম তৈরি করুন
function createMixersAdCustomizerItem() {
// This example snippet creates an ad customizer item in the source named "Mixers",
// modeled after the example data shown at
// https://support.google.com/google-ads/answer/6072565.
const sourceName = 'Mixers';
let sourceCount = 0;
let mixersSource = null;
for (const source of AdsApp.adCustomizerSources()) {
if (source.getName() === sourceName) {
mixersSource = source;
sourceCount += 1;
}
}
if (mixersSource === null) {
throw new Error(`No Ad Customizer Source found with name "${sourceName}"`);
}
if (sourceCount > 1) {
console.warn(`Found ${sourceCount} Ad Customizer Sources with name "${sourceName}", using just one of them`);
}
// Item values can be specified one at a time with `withAttributeValue` or all at once
// with `withAttributeValues`.
const mixersItemOperation = mixersSource.adCustomizerItemBuilder()
.withAttributeValue('Model', 'ProWhip 300')
.withAttributeValues({
'Capacity': 5,
'Type': 'tilt-head',
'Start_price': '$199',
'Sale_ends': '20150515 200000',
})
.withTargetKeyword('prowhip 300')
.build();
return mixersItemOperation;
}
বিজ্ঞাপন কাস্টমাইজার দিয়ে প্রসারিত পাঠ্য বিজ্ঞাপন তৈরি করুন
function createCustomizedMixersExpandedTextAd() {
// This example snippet creates an ad in the ad group named "Kitchen Store" that
// shows details based on the data in the ad customizer named "Mixers". This
// example is modeled after https://support.google.com/google-ads/answer/6072565.
const adGroupName = 'Kitchen Store';
const adGroupIterator = AdsApp.adGroups()
.withCondition(`ad_group.name = "${adGroupName}"`)
.get();
if (!adGroupIterator.hasNext()) {
throw new Error(`No Ad Group found with name "${adGroupName}"`);
}
if (adGroupIterator.totalNumEntities() > 1) {
console.warn(`Found ${adGroupIterator.totalNumEntities()} Ad Groups with name "${adGroupName}", using just one of them`);
}
const adGroup = adGroupIterator.next();
const mixersAdOperation = adGroup.newAd().expandedTextAdBuilder()
.withHeadlinePart1('{=Mixers.model}')
.withHeadlinePart2('Stand Mixer')
.withDescription1('{=Mixers.Capacity} quart {=Mixers.Type} stand mixer.')
.withDescription2('{=Mixers.Start_price} - sale ends in {=COUNTDOWN(Mixers.Sale_ends)}.')
.withFinalUrl('http://www.example.com')
.build();
return mixersAdOperation;
}