Personalizadores de anúncios
Mantenha tudo organizado com as coleções Salve e categorize o conteúdo com base nas suas preferências.
Criar uma origem de dados do personalizador de anúncios
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; }
Encontrar uma origem de dados do personalizador de anúncios pelo 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; }
Ver os itens do personalizador de uma origem de dados
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; }
Criar um item do personalizador de anúncios
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; }
Criar anúncio de texto expandido com personalizadores de anúncios
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; }
Exceto em caso de indicação contrária, o conteúdo desta página é licenciado de acordo com a Licença de atribuição 4.0 do Creative Commons, e as amostras de código são licenciadas de acordo com a Licença Apache 2.0. Para mais detalhes, consulte as políticas do site do Google Developers. Java é uma marca registrada da Oracle e/ou afiliadas.
Última atualização 2025-08-21 UTC.
[[["Fácil de entender","easyToUnderstand","thumb-up"],["Meu problema foi resolvido","solvedMyProblem","thumb-up"],["Outro","otherUp","thumb-up"]],[["Não contém as informações de que eu preciso","missingTheInformationINeed","thumb-down"],["Muito complicado / etapas demais","tooComplicatedTooManySteps","thumb-down"],["Desatualizado","outOfDate","thumb-down"],["Problema na tradução","translationIssue","thumb-down"],["Problema com as amostras / o código","samplesCodeIssue","thumb-down"],["Outro","otherDown","thumb-down"]],["Última atualização 2025-08-21 UTC."],[[["\u003cp\u003eThe provided code snippets demonstrate how to manage Ad Customizer data sources and items within Google Ads scripts.\u003c/p\u003e\n"],["\u003cp\u003eYou can create, find, and retrieve items from an Ad Customizer data source using dedicated functions.\u003c/p\u003e\n"],["\u003cp\u003eAd Customizer items can be associated with specific keywords for targeted ad delivery.\u003c/p\u003e\n"],["\u003cp\u003eThe code showcases how to build Expanded Text Ads that dynamically insert data from Ad Customizer sources using placeholders like \u003ccode\u003e{=Mixers.Model}\u003c/code\u003e.\u003c/p\u003e\n"],["\u003cp\u003eThese snippets use a 'Mixers' example source with attributes like Model, Capacity, and Sale_ends to illustrate the functionality.\u003c/p\u003e\n"]]],[],null,["Create an ad customizer data source \n\n```mysql\nfunction createMixersAdCustomizerSource() {\n // This example snippet creates an ad customizer source named \"Mixers\", modeled after\n // the example data shown at https://support.google.com/google-ads/answer/6072565.\n const sourceName = 'Mixers';\n\n // Ad Customizer attributes can be added one at a time with `addAttribute` or all at\n // once with `addAttributes`.\n const mixersSourceOperation = AdsApp.newAdCustomizerSourceBuilder()\n .withName(sourceName)\n .addAttribute('Model', 'text')\n .addAttributes({\n 'Capacity': 'number',\n 'Type': 'text',\n 'Start_price': 'price',\n 'Sale_ends': 'date',\n })\n .build();\n\n return mixersSourceOperation;\n}\n```\n\nFind an ad customizer data source by name \n\n```perl6\nfunction getAdCustomizerSourceByName(sourceName) {\n let sourceCount = 0;\n let foundSource = null;\n\n for (const source of AdsApp.adCustomizerSources()) {\n if (source.getName() === sourceName) {\n foundSource = source;\n sourceCount += 1;\n }\n }\n\n if (foundSource === null) {\n throw new Error(`No Ad Customizer Source found with name \"${sourceName}\"`);\n }\n\n if (sourceCount \u003e 1) {\n console.warn(`Found ${sourceCount} Ad Customizer Sources with name \"${sourceName}\", returning just one of them`);\n }\n\n console.log(`Source \"${foundSource.getName()}\" has attributes ${foundSource.getAttributes()}`);\n return foundSource;\n}\n```\n\nGet a data source's customizer items \n\n```perl6\nfunction getAdCustomizerItems(sourceName) {\n let sourceCount = 0;\n let foundSource = null;\n\n for (const source of AdsApp.adCustomizerSources()) {\n if (source.getName() === sourceName) {\n foundSource = source;\n sourceCount += 1;\n }\n }\n\n if (foundSource === null) {\n throw new Error(`No Ad Customizer Source found with name \"${sourceName}\"`);\n }\n\n if (sourceCount \u003e 1) {\n console.warn(`Found ${sourceCount} Ad Customizer Sources with name \"${sourceName}\", using just one of them`);\n }\n\n const itemIterator = foundSource.items().get();\n console.log(`Source \"${foundSource.getName()}\" has ${itemIterator.totalNumEntities()} items`);\n return itemIterator;\n}\n```\n\nCreate an ad customizer item \n\n```mysql\nfunction createMixersAdCustomizerItem() {\n // This example snippet creates an ad customizer item in the source named \"Mixers\",\n // modeled after the example data shown at\n // https://support.google.com/google-ads/answer/6072565.\n const sourceName = 'Mixers';\n\n let sourceCount = 0;\n let mixersSource = null;\n\n for (const source of AdsApp.adCustomizerSources()) {\n if (source.getName() === sourceName) {\n mixersSource = source;\n sourceCount += 1;\n }\n }\n\n if (mixersSource === null) {\n throw new Error(`No Ad Customizer Source found with name \"${sourceName}\"`);\n }\n\n if (sourceCount \u003e 1) {\n console.warn(`Found ${sourceCount} Ad Customizer Sources with name \"${sourceName}\", using just one of them`);\n }\n\n // Item values can be specified one at a time with `withAttributeValue` or all at once\n // with `withAttributeValues`.\n const mixersItemOperation = mixersSource.adCustomizerItemBuilder()\n .withAttributeValue('Model', 'ProWhip 300')\n .withAttributeValues({\n 'Capacity': 5,\n 'Type': 'tilt-head',\n 'Start_price': '$199',\n 'Sale_ends': '20150515 200000',\n })\n .withTargetKeyword('prowhip 300')\n .build();\n\n return mixersItemOperation;\n}\n```\n\nCreate expanded text ad with ad customizers \n\n```gdscript\nfunction createCustomizedMixersExpandedTextAd() {\n // This example snippet creates an ad in the ad group named \"Kitchen Store\" that\n // shows details based on the data in the ad customizer named \"Mixers\". This\n // example is modeled after https://support.google.com/google-ads/answer/6072565.\n const adGroupName = 'Kitchen Store';\n const adGroupIterator = AdsApp.adGroups()\n .withCondition(`ad_group.name = \"${adGroupName}\"`)\n .get();\n\n if (!adGroupIterator.hasNext()) {\n throw new Error(`No Ad Group found with name \"${adGroupName}\"`);\n }\n\n if (adGroupIterator.totalNumEntities() \u003e 1) {\n console.warn(`Found ${adGroupIterator.totalNumEntities()} Ad Groups with name \"${adGroupName}\", using just one of them`);\n }\n\n const adGroup = adGroupIterator.next();\n const mixersAdOperation = adGroup.newAd().expandedTextAdBuilder()\n .withHeadlinePart1('{=Mixers.model}')\n .withHeadlinePart2('Stand Mixer')\n .withDescription1('{=Mixers.Capacity} quart {=Mixers.Type} stand mixer.')\n .withDescription2('{=Mixers.Start_price} - sale ends in {=COUNTDOWN(Mixers.Sale_ends)}.')\n .withFinalUrl('http://www.example.com')\n .build();\n\n return mixersAdOperation;\n}\n```"]]