Parametri di personalizzazione degli annunci
Mantieni tutto organizzato con le raccolte
Salva e classifica i contenuti in base alle tue preferenze.
Crea una sorgente dati dei parametri di personalizzazione degli annunci
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;
}
Trova una sorgente dati dei parametri di personalizzazione degli annunci in base al nome
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;
}
Ricevi gli elementi dei parametri di personalizzazione di una sorgente dati
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;
}
Creare un parametro di personalizzazione degli annunci
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;
}
Creare un annuncio di testo espanso con i parametri di personalizzazione degli annunci
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;
}
Salvo quando diversamente specificato, i contenuti di questa pagina sono concessi in base alla licenza Creative Commons Attribution 4.0, mentre gli esempi di codice sono concessi in base alla licenza Apache 2.0. Per ulteriori dettagli, consulta le norme del sito di Google Developers. Java è un marchio registrato di Oracle e/o delle sue consociate.
Ultimo aggiornamento 2024-09-12 UTC.
[[["Facile da capire","easyToUnderstand","thumb-up"],["Il problema è stato risolto","solvedMyProblem","thumb-up"],["Altra","otherUp","thumb-up"]],[["Mancano le informazioni di cui ho bisogno","missingTheInformationINeed","thumb-down"],["Troppo complicato/troppi passaggi","tooComplicatedTooManySteps","thumb-down"],["Obsoleti","outOfDate","thumb-down"],["Problema di traduzione","translationIssue","thumb-down"],["Problema relativo a esempi/codice","samplesCodeIssue","thumb-down"],["Altra","otherDown","thumb-down"]],["Ultimo aggiornamento 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."]]],[]]