Ad Customizers
Stay organized with collections
Save and categorize content based on your preferences.
Create an ad customizer data source
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
;
}
Find an ad customizer data source by name
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
;
}
Get a data source's customizer items
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
;
}
Create an ad customizer item
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
;
}
Create expanded text ad with ad customizers
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
;
}
Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License
, and code samples are licensed under the Apache 2.0 License
. For details, see the Google Developers Site Policies
. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2025-08-20 UTC.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-08-20 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,["# Ad Customizers\n\nCreate an ad customizer data source\n-----------------------------------\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\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\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\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\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```"]]