Bidding
Stay organized with collections
Save and categorize content based on your preferences.
Get bidding strategies
function
getBiddingStrategies
()
{
const
bidStrategyIterator
=
AdsApp
.
biddingStrategies
()
.
get
();
return
bidStrategyIterator
;
}
Get bidding strategies by name
function
getBiddingStrategyIteratorByName
(
biddingStrategyName
)
{
const
biddingStrategiesIterator
=
AdsApp
.
biddingStrategies
()
.
withCondition
(
`
bidding_strategy
.
name
=
'${biddingStrategyName}'
`
)
.
get
();
return
biddingStrategiesIterator
;
}
Set campaign bidding strategy
function
set
VariousBiddingStrategies
()
{
//
This
example
snippet
assumes
the
user
has
a
campaign
named
"Online Sales"
.
const
campaignName
=
'Online Sales'
;
const
campaignIterator
=
AdsApp
.
campaigns
()
.
withCondition
(
`campaign.name = '${campaignName}'`
)
.
get
();
if
(
!
campaignIterator
.
hasNext
())
{
throw
new
Error
(
`No Campaign found with name "${campaignName}"`
);
}
if
(
campaignIterator
.
totalNumEntities
()
>
1
)
{
console
.
warn
(
`Found ${campaignIterator.totalNumEntities()} Campaigns with name "${
campaignName}", using just one of them`
);
}
const
campaign
=
campaignIterator
.
next
();
//
Set
the
campaign
's bidding strategy to Manual CPC.
campaign.bidding().setStrategy('
MANUAL_CPC
');
// By default, the Manual CPC strategy enables Enhanced CPC bidding. The user
// can disable ECPC when setting the strategy by providing an extra argument.
campaign.bidding().setStrategy('
MANUAL_CPC
', {enhancedCpcEnabled: false});
// Some standard bidding strategies, such as Target Return on Ad Spend,
// require additional arguments when setting the strategy. Setting the
// strategy to Target Return on Ad Spend without providing the required
// additional arguments will fail.
campaign.bidding().setStrategy('
TARGET_ROAS
', {targetRoas: 1.3});
// Extra arguments can also be specified through the BiddingStrategyArgsBuilder.
const args =
campaign.bidding.argsBuilder().withTargetRoas(1.3).withCpcBidCeiling(2.5);
campaign.bidding().setStrategy('
TARGET_ROAS
', args);
// If the user has defined a flexible bidding strategy for the campaign, then
// this is also valid for `setStrategy`. For this example, assume the user
// has a flexible bidding strategy named "My Shared Bidding Strategy".
const strategyName = '
My
Shared
Bidding
Strategy
';
const strategy =
AdsApp.biddingStrategies()
.withCondition(`bidding_strategy.name = '
$
{
strategyName
}
'`)
.get()
.next();
campaign.bidding().setStrategy(strategy);
}
Set an ad group's default CPC bid
function
setAdGroupDefaultCpcBid
(
campaignName
,
adGroupName
){
const
adGroup
=
AdsApp
.
adGroups
()
.
withCondition
(
`
campaign
.
name
=
'${campaignName}'
`
)
.
withCondition
(
`
ad_group
.
name
=
'${adGroupName}'
`
)
.
get
()
.
next
();
//
This
bid
will
only
be
used
for
auction
if
a
corresponding
cpc
//
bidding
strategy
is
set
to
the
ad
group
.
E
.
g
.
//
//
adGroup
.
bidding
()
.
setStrategy
(
'MANUAL_CPC'
);
adGroup
.
bidding
()
.
setCpc
(
3.0
);
}
Set a keyword's CPC bid
function
setKeywordCpcBid
(
campaignName
,
adGroupName
,
keywordText
,
keywordMaxCpcBid
)
{
const
keyword
=
AdsApp
.
keywords
()
.
withCondition
(
`
campaign
.
name
=
'${campaignName}'
`
)
.
withCondition
(
`
ad_group
.
name
=
'${adGroupName}'
`
)
.
withCondition
(
`
ad_group_criterion
.
keyword
.
text
=
'${keywordText}'
`
)
.
get
()
.
next
();
//
This
bid
will
only
be
used
for
auction
if
a
corresponding
cpc
//
bidding
strategy
is
set
to
the
parent
ad
group
.
E
.
g
.
//
//
adGroup
.
bidding
()
.
setStrategy
(
'MANUAL_CPC'
);
keyword
.
bidding
()
.
setCpc
(
keywordMaxCpcBid
);
}
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\u003eThese Google Ads scripts demonstrate how to manage bidding strategies programmatically, including retrieving, setting, and applying them to campaigns, ad groups, and keywords.\u003c/p\u003e\n"],["\u003cp\u003eYou can retrieve existing bidding strategies and filter them by name to use or modify within your scripts.\u003c/p\u003e\n"],["\u003cp\u003eThe scripts provide examples of setting various bidding strategies for campaigns, like Manual CPC, Target ROAS, and Enhanced CPC, while demonstrating the use of required arguments and bidding strategy builders.\u003c/p\u003e\n"],["\u003cp\u003eIncluded are examples of how to programmatically set default CPC bids for ad groups and specific CPC bids for keywords, empowering granular bid control within your Google Ads campaigns.\u003c/p\u003e\n"],["\u003cp\u003eEnsure the corresponding CPC bidding strategy is set at the ad group level for keyword and ad group CPC bids to be used in auctions.\u003c/p\u003e\n"]]],[],null,["# Bidding\n\nGet bidding strategies\n----------------------\n\n```gdscript\nfunction getBiddingStrategies() {\n const bidStrategyIterator = AdsApp.biddingStrategies().get();\n return bidStrategyIterator;\n}\n```\n\nGet bidding strategies by name\n------------------------------\n\n```gdscript\nfunction getBiddingStrategyIteratorByName(biddingStrategyName) {\n const biddingStrategiesIterator = AdsApp.biddingStrategies()\n .withCondition(`bidding_strategy.name = '${biddingStrategyName}'`)\n .get();\n return biddingStrategiesIterator;\n}\n```\n\nSet campaign bidding strategy\n-----------------------------\n\n```mysql\nfunction setVariousBiddingStrategies() {\n // This example snippet assumes the user has a campaign named \"Online Sales\".\n const campaignName = 'Online Sales';\n const campaignIterator =\n AdsApp.campaigns()\n .withCondition(`campaign.name = '${campaignName}'`)\n .get();\n\n if (!campaignIterator.hasNext()) {\n throw new Error(`No Campaign found with name \"${campaignName}\"`);\n }\n\n if (campaignIterator.totalNumEntities() \u003e 1) {\n console.warn(\n `Found ${campaignIterator.totalNumEntities()} Campaigns with name \"${\n campaignName}\", using just one of them`);\n }\n\n const campaign = campaignIterator.next();\n\n // Set the campaign's bidding strategy to Manual CPC.\n campaign.bidding().setStrategy('MANUAL_CPC');\n\n // By default, the Manual CPC strategy enables Enhanced CPC bidding. The user\n // can disable ECPC when setting the strategy by providing an extra argument.\n campaign.bidding().setStrategy('MANUAL_CPC', {enhancedCpcEnabled: false});\n\n // Some standard bidding strategies, such as Target Return on Ad Spend,\n // require additional arguments when setting the strategy. Setting the\n // strategy to Target Return on Ad Spend without providing the required\n // additional arguments will fail.\n campaign.bidding().setStrategy('TARGET_ROAS', {targetRoas: 1.3});\n\n // Extra arguments can also be specified through the BiddingStrategyArgsBuilder.\n const args =\n campaign.bidding.argsBuilder().withTargetRoas(1.3).withCpcBidCeiling(2.5);\n campaign.bidding().setStrategy('TARGET_ROAS', args);\n\n // If the user has defined a flexible bidding strategy for the campaign, then\n // this is also valid for `setStrategy`. For this example, assume the user\n // has a flexible bidding strategy named \"My Shared Bidding Strategy\".\n const strategyName = 'My Shared Bidding Strategy';\n const strategy =\n AdsApp.biddingStrategies()\n .withCondition(`bidding_strategy.name = '${strategyName}'`)\n .get()\n .next();\n campaign.bidding().setStrategy(strategy);\n}\n```\n\nSet an ad group's default CPC bid\n---------------------------------\n\n```gdscript\nfunction setAdGroupDefaultCpcBid(campaignName, adGroupName){\n const adGroup = AdsApp.adGroups()\n .withCondition(`campaign.name = '${campaignName}'`)\n .withCondition(`ad_group.name = '${adGroupName}'`)\n .get()\n .next();\n\n // This bid will only be used for auction if a corresponding cpc\n // bidding strategy is set to the ad group. E.g.\n //\n // adGroup.bidding().setStrategy('MANUAL_CPC');\n adGroup.bidding().setCpc(3.0);\n}\n```\n\nSet a keyword's CPC bid\n-----------------------\n\n```gdscript\nfunction setKeywordCpcBid(campaignName, adGroupName, keywordText, keywordMaxCpcBid) {\n const keyword = AdsApp.keywords()\n .withCondition(`campaign.name = '${campaignName}'`)\n .withCondition(`ad_group.name = '${adGroupName}'`)\n .withCondition(`ad_group_criterion.keyword.text = '${keywordText}'`)\n .get()\n .next();\n\n // This bid will only be used for auction if a corresponding cpc\n // bidding strategy is set to the parent ad group. E.g.\n //\n // adGroup.bidding().setStrategy('MANUAL_CPC');\n keyword.bidding().setCpc(keywordMaxCpcBid);\n}\n```"]]