Anzeigenanpassungen
Datenquelle für Anzeigenanpassungen erstellen
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;
}
Datenquelle für Anzeigenanpassungen anhand des Namens suchen
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;
}
Anpassungselemente einer Datenquelle abrufen
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;
}
Anzeigenanpassungselement erstellen
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;
}
Erweiterte Textanzeige mit Anzeigenanpassungen erstellen
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;
}
Sofern nicht anders angegeben, sind die Inhalte dieser Seite unter der Creative Commons Attribution 4.0 License und Codebeispiele unter der Apache 2.0 License lizenziert. Weitere Informationen finden Sie in den Websiterichtlinien von Google Developers. Java ist eine eingetragene Marke von Oracle und/oder seinen Partnern.
Zuletzt aktualisiert: 2024-09-12 (UTC).
[null,null,["Zuletzt aktualisiert: 2024-09-12 (UTC)."],[[["The provided code snippets demonstrate how to manage Ad Customizer data sources and items within Google Ads scripts."],["You can create, find, and retrieve items from an Ad Customizer data source using dedicated functions."],["Ad Customizer items can be associated with specific keywords for targeted ad delivery."],["The code showcases how to build Expanded Text Ads that dynamically insert data from Ad Customizer sources using placeholders like `{=Mixers.Model}`."],["These snippets use a 'Mixers' example source with attributes like Model, Capacity, and Sale_ends to illustrate the functionality."]]],[]]