效果最大化广告系列的可选组件

转化目标

创建效果最大化广告系列时,系统会自动创建一系列与账号中的 CustomerConversionGoals 匹配的转化目标 。您可以更新这些目标,以便专门针对每个效果最大化广告系列进行自定义。

为此,您需要先提取效果最大化广告系列的广告系列 ID,以及所有客户转化目标的列表。以下示例展示了如何更改一个广告系列的目标,但您也可以设置代码,以便遍历多个效果最大化广告系列。

// 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`
);

然后,您可以迭代所有返回的转化目标,并为当前效果最大化广告系列创建更新操作,以便自定义每个目标的定位。本部分稍后显示的代码示例会将所有目标都设置为可出价,但您需要自定义该部分逻辑,以匹配您希望从广告系列中获得的结果。

我们建议您在与广告系列创建过程的其余部分分开的事务中设置转化目标。CampaignConversionGoalOperation 要求将请求的 partialFailure 设置为 false。如果您想在首次制作广告系列的同一事务中运行此代码,则必须将整套操作都设置为关闭部分失败。此示例代码演示了如何在单独的事务中执行此操作。

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});

广告系列定位

如需了解效果最大化广告系列中的广告系列定位,请务必查看 API 指南,以获取允许的条件类型的完整列表。

制作效果最大化广告系列不需要其他条件,但这些条件有助于根据您的使用情形限制定位。下一个代码示例展示了如何设置地理位置目标。您可以参考 CampaignCriterion 文档,了解其他条件类型的格式。

您可以创建这些条件,并将其与广告系列本身一起作为对 mutateAll 的同一调用的组成部分。此代码示例假定您就是这样构建代码的。

operations.push({
  "campaignCriterionOperation": {
    "create": {
      "campaign": campaignOperation.campaignOperation.create.resourceName,
      "negative": false,
      "location": {
        // 1023191 represents New York City
        "geoTargetConstant": "geoTargetConstants/1023191"
      }
    }
  }
});

素材资源组信号

在开始之前,请先阅读 API 文档中的素材资源组信号。这些信号是通过将素材资源组与现有 AudienceInfoSearchThemeInfo条件相关联来设置的。如果您想改用受众群体,请指定 audience 字段,而不是 searchTheme 字段,并使用受众群体的资源名称。

operations.push({
  "assetGroupSignalOperation": {
    "create": {
      "assetGroup": assetGroupOperation.assetGroupOperation.create.resourceName,
      "searchTheme": {
        "text": "mars cruise"
      }
    }
  }
});