To generate a new Demand Gen campaign from scratch, you must at the minimum create the following:
- Account-level assets
- The campaign itself
- A budget
- An ad group
- An ad group ad
- An ad
- Account-level assets
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 Demand Gen campaigns. Visit the Demand Gen 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. For
conversion-based bidding, the best practice would be to set a daily budget
greater than 15 times your expected CPA. For value-based bidding, set a daily
budget greater than 20 times your expected average conversion value/tROAS. Use
a CampaignBudgetOperation to create your budget.
const budgetOperation = {
"campaignBudgetOperation": {
"create": {
"resourceName": `customers/${customerId}/campaignBudgets/${getNextTempId()}`,
"name": "Demand Gen campaign budget",
"amountMicros": "50000000",
"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.
const campaignOperation = {
"campaignOperation": {
"create": {
"resourceName": `customers/${customerId}/campaigns/${getNextTempId()}`,
"name": "Demand Gen campaign",
"status": "PAUSED",
"advertisingChannelType": "DEMAND_GEN",
"campaignBudget": budgetOperation.campaignBudgetOperation.create.resourceName,
"biddingStrategyType": "TARGET_CPA",
"startDate": "20240314",
"endDate": "20250313",
"urlExpansionOptOut": false,
"targetCpa": {
"targetCpaMicros": 1000000
},
"containsEuPoliticalAdvertising": "DOES_NOT_CONTAIN_EU_POLITICAL_ADVERTISING"
}
}
}
operations.push(campaignOperation);
Ad group
The ad group must reference a campaign, so you will need the exact campaign resource name created in the previous step to identify and use that campaign object. 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 an ad group ad.
When creating an ad group for a Demand Gen campaign, you can also configure
channel controls to decide where your ads will be shown. Unlike some other
campaign types, multiple ad groups per campaign are recommended for Demand Gen,
since the system allocates budget according to ad group performance. For now,
you can just create one ad group using a AdGroupOperation.
const adGroupId = getNextTempId();
const adGroupOperation = {
"adGroupOperation": {
"create": {
"resourceName": `customers/${customerId}/adGroups/${adGroupId}`,
"name": "Demand Gen ad group",
"status": "PAUSED",
"campaign": campaignOperation.campaignOperation.create.resourceName,
"demand_gen_ad_group_settings": {
"channel_controls": {
"selected_channels": {
"gmail": false,
"discover": false,
"display": false,
"youtube_in_feed": true,
"youtube_in_stream": true,
"youtube_shorts": true
}
}
}
}
}
}
operations.push(adGroupOperation);
Ad group ad with nested 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.
The example shown here creates a Demand Gen video responsive ad using
DemandGenVideoResponsiveAdInfo, or you can adapt the example to create a
multi asset ad using DemandGenMultiAssetAdInfo, a carousel ad using
DemandGenCarouselAdInfo, or a product ad using
DemandGenProductAdInfo.
To create the ad group ad, use an AdGroupAdOperation with the same ad
group ID variable created in the previous step.
const adGroupAdOperation = {
"adGroupAdOperation": {
"create": {
"resourceName": `customers/${customerId}/adGroupAds/${adGroupId}~${getNextTempId()}`,
"adGroup": adGroupOperation.adGroupOperation.create.resourceName,
"status": "PAUSED",
"ad": {
"name": "Demand Gen video responsive ad",
"finalUrls": [
"http://www.example.com"
],
"demandGenVideoResponsiveAd": {
"businessName": {
"text": "Demand Gen business"
},
"videos": [
{ "asset": videoAsset.assetOperation.create.resourceName }
],
"logoImages": [
{ "asset": imageAsset.assetOperation.create.resourceName }
],
"headlines": [
{ "text": "Demand Gen responsive video" }
],
"longHeadlines": [
{ "text": "Make a Demand Gen video responsive ad today" }
],
"description": [
{ "text": "This is an example of a Demand Gen video responsive ad"}
]
}
}
}
}
}
operations.push(adGroupAdOperation);