To generate a new Search campaign from scratch, you must at the minimum create the following:
The campaign and budget are useful for creating all sorts of campaign types, while some settings within the ad group ads will be specifically useful for creating Search campaigns. Visit the Search assets guide to see how assets can be created using scripts.
Make sure you're familiar with the mutate strategy , as this guide will only provide the JavaScript objects to be used in the mutates.
Budget
The budget must not be shared, and must have a unique name in your account. Use
a CampaignBudgetOperation
to create
your budget.
const
budgetOperation
=
{
"campaignBudgetOperation"
:
{
"create"
:
{
"resourceName"
:
`customers/
${
customerId
}
/campaignBudgets/
${
getNextTempId
()
}
`
,
"name"
:
"Search campaign budget"
,
"amountMicros"
:
"10000000"
,
"deliveryMethod"
:
"STANDARD"
,
"explicitlyShared"
:
false
}
}
}
operations
.
push
(
budgetOperation
);
Campaign
The campaign must reference a budget, so you will need the exact budget resource
name you created in the previous step to identify and use that specific budget
object. Use a CampaignOperation
. In this
example we also set the AiMaxSetting
to
enable AI Max for Search, and the NetworkSettings
.
const
campaignOperation
=
{
"campaignOperation"
:
{
"create"
:
{
"resourceName"
:
`customers/
${
customerId
}
/campaigns/
${
getNextTempId
()
}
`
,
"name"
:
"Search campaign"
,
"status"
:
"PAUSED"
,
"advertisingChannelType"
:
"SEARCH"
,
"campaignBudget"
:
budgetOperation
.
campaignBudgetOperation
.
create
.
resourceName
,
"biddingStrategyType"
:
"MANUAL_CPC"
,
"startDate"
:
"20240314"
,
"endDate"
:
"20250313"
,
"manualCpc"
:
{
"enhancedCpcEnabled"
:
true
},
"aiMaxSetting"
:
{
"enableAiMax"
:
true
},
"networkSettings"
:
{
"targetGoogleSearch"
:
true
,
"targetSearchNetwork"
:
true
},
"containsEuPoliticalAdvertising"
:
"DOES_NOT_CONTAIN_EU_POLITICAL_ADVERTISING"
}
}
}
operations
.
push
(
campaignOperation
);
Ad group
The ad group must reference the previously created campaign, so you will need
the exact resource name you set in the previous step to identify the campaign
previously created in this request. You will also need a temp ID for the ad
group itself, which is best stored as a new variable so it can be used when
creating keywords and ad group ads. Use an AdGroupOperation
.
const
adGroupId
=
getNextTempId
();
const
adGroupOperation
=
{
"adGroupOperation"
:
{
"create"
:
{
"resourceName"
:
`customers/
${
customerId
}
/adGroups/
${
adGroupId
}
`
,
"name"
:
"Search ad group"
,
"status"
:
"PAUSED"
,
"campaign"
:
campaignOperation
.
campaignOperation
.
create
.
resourceName
,
"type"
:
"SEARCH_STANDARD"
}
}
}
operations
.
push
(
adGroupOperation
);
Keywords
Keywords are required to trigger your ads on search results. They are added as
criteria to an ad group using AdGroupCriterionOperation
. You need
to reference the ad group created in the previous step.
const
keywordOperation
=
{
"adGroupCriterionOperation"
:
{
"create"
:
{
"adGroup"
:
adGroupOperation
.
adGroupOperation
.
create
.
resourceName
,
"status"
:
"ENABLED"
,
"keyword"
:
{
"text"
:
"flowers"
,
"matchType"
:
"BROAD"
}
}
}
}
operations
.
push
(
keywordOperation
);
Ad group ad with ad
This step creates an ad group ad, which joins an ad group with an ad. The ad
group ad must reference the ad group, so you will need the exact resource name
you set in the previous step. You can create an ad within the same operation,
and use either previously created text assets or create them within the same
operation as well. The example shown here creates a Responsive Search Ad using ResponsiveSearchAdInfo
. This requires
text assets for headlines and descriptions to have been created, as shown in the Assets
guide.
To create the ad group ad, use an AdGroupAdOperation
.
const
adGroupAdOperation
=
{
"adGroupAdOperation"
:
{
"create"
:
{
"resourceName"
:
`customers/
${
customerId
}
/adGroupAds/
${
adGroupId
}
~
${
getNextTempId
()
}
`
,
"adGroup"
:
adGroupOperation
.
adGroupOperation
.
create
.
resourceName
,
"status"
:
"PAUSED"
,
"ad"
:
{
"name"
:
"Search RSA ad"
,
"finalUrls"
:
[
"http://www.example.com"
],
"responsiveSearchAd"
:
{
"headlines"
:
[
{
"text"
:
textAsset
.
assetOperation
.
create
.
resourceName
},
{
"text"
:
"Headline 2"
},
{
"text"
:
"Headline 3"
}
],
"descriptions"
:
[
{
"text"
:
"Description 1"
},
{
"text"
:
"Description 2"
}
]
}
}
}
}
}
operations
.
push
(
adGroupAdOperation
);

