Conversion Goals
When you create a Performance Max campaign, a series of conversion
goals are automatically
created that match the
CustomerConversionGoal
s in the account. You
can customize these specifically for each of your Performance Max campaigns by
updating them.
To do so, first you need to fetch a list of all the customer conversion goals.
const searchResults = AdsApp.search(
`SELECT
customer_conversion_goal.category,
customer_conversion_goal.origin
FROM customer_conversion_goal`
);
Then you can iterate through all of the conversion goals you got back and create an update operation for our current Performance Max campaign to customize the targeting for each goal. The code below sets all of them to biddable, but you'll want to customize that portion of the logic to match what you want to get out of your campaign.
Before running this code, you'll need to fetch the campaign ID for your Performance Max campaign.
We recommend setting up conversion goals in a separate transaction from the
rest of the campaign creation process.
CampaignConversionGoalOperation
requires that partialFailure
for the request be set to false
. If you want
to run this code in the same transaction where you first make the campaign, you
must set the entire set of operations to have partial failure turned off. This
example code demonstrates how to perform this operation in a separate
transaction.
operations = [];
while (searchResults.hasNext()) {
const row = searchResults.next();
const conversionGoal = row.customerConversionGoal;
operations.push({
"campaignConversionGoalOperation": {
"update": {
"resourceName": `customers/${customerId}/campaignConversionGoals/${campaignId}~${conversionGoal.category}~${conversionGoal.origin}`,
// Insert your logic here to determine whether you want this particular
// campaign conversion goal to be biddable or not.
// This code will just default everything to being biddable, but that
// is not necessarily best for your use case.
"biddable": true
},
"updateMask": "biddable"
}
});
}
AdsApp.mutateAll(operations, {partialFailure: false});
Campaign Targeting
For campaign targeting in Performance Max, make sure to check out the API guide for a complete list of allowable criteria types.
Additional criteria are not required to make a Performance Max campaign, but
can be useful to help restrict targeting based on your use case. The code
example below shows how to set up a geo location target. You can reference the
CampaignCriterion
documentation
for the format for other criteria types.
You can create these criteria along with the campaign itself as part of the
same call to mutateAll
, and this code example assumes that that's how you're
structuring your code.
operations.push({
"campaignCriterionOperation": {
"create": {
"campaign": campaignOperation.campaignOperation.create.resourceName,
"negative": false,
"location": {
// 1023191 represents New York City
"geoTargetConstant": "geoTargetConstants/1023191"
}
}
}
});
Asset Group Signals
Read about asset group
signals on the API
documentation before getting started. These are set up by linking an asset
group to either an existing AudienceInfo
or
SearchThemeInfo
criterion. If you want to
use an audience instead, specify the audience
field instead of the
searchTheme
field with the audience's resource name.
operations.push({
"assetGroupSignalOperation": {
"create": {
"assetGroup": assetGroupOperation.assetGroupOperation.create.resourceName,
"searchTheme": {
"text": "mars cruise"
}
}
}
});