Optional components of Performance Max

Conversion goals

When you create a Performance Max campaign, a series of conversion goals are automatically created that match the CustomerConversionGoals in the account. You can customize these specifically for each of your Performance Max campaigns by updating them.

To do so, you need to fetch the campaign ID of your Performance Max campaign(s) and a list of all the customer conversion goals first. Here is an example of changing one campaign's goals, though you can also set up your code to loop through multiple Performance Max campaigns.

// Query for a campaign by name. Update this logic to pull the campaigns you'd
// like to edit
const campaignName = "My PMax campaign";
let campaignId = "";

const search = AdsApp.search(`SELECT campaign.id FROM campaign WHERE campaign.name = "${campaignName}"`);
if (search.hasNext()) {
  campaignId = search.next().campaign.id;
  console.log(`Updating conversion goals for ${campaignName}: ${campaignId}`);
}
else
{
  console.log(`No campaign named "${campaignName}" found`);
  // Perform further error handling here
}

// Query for a list of 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 the conversion goals you got back and create an update operation for the current Performance Max campaign to customize the targeting for each goal. The code example shown later in this section sets all of the goals to biddable, but you'll want to customize that portion of the logic to match what you want to get out of your 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 allowed 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 next code example 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. 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 in 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"
      }
    }
  }
});