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

转化目标

当您制作效果最大化广告系列时,系统会自动创建一系列与帐号中的 CustomerConversionGoal 匹配的转化目标。您可以通过更新这些素材资源,为每个效果最大化广告系列专门自定义这些设置。

为此,您首先需要获取包含所有客户转化目标的列表。

const searchResults = AdsApp.search(
  `SELECT
     customer_conversion_goal.category,
     customer_conversion_goal.origin
   FROM customer_conversion_goal`
);

然后,您可以遍历获取的所有转化目标,并为当前的效果最大化广告系列创建更新操作,以自定义每个目标的定位。下面的代码将所有这些选项都设置为可出价,但您需要自定义该部分逻辑,使其与您希望从广告系列中获得的匹配内容保持一致。

运行此代码之前,您需要提取效果最大化广告系列的广告系列 ID。

我们建议在与广告系列制作流程其余部分不同的交易中设置转化目标。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"
      }
    }
  }
});