创建“推荐活动”商品详情组

为推荐活动广告组创建产品信息组时,遵循与酒店广告产品信息组相同的结构层次和树形构建流程。

如需对推荐活动广告资源进行划分,请使用 ListingDimensionInfo 中提供的专用活动维度:

  • ActivityCountryInfo:使用地理位置定位常量资源名称(geoTargetConstants/{criterion_id},例如美国的 "geoTargetConstants/2840")按目标国家/地区 (value) 进行过滤。
  • ActivityStateInfo:使用地理位置定位目标常量资源名称 (geoTargetConstants/{criterion_id}) 按目的地州/省 或地区 (value) 进行过滤。
  • ActivityCityInfo:使用地理位置定位目标常量资源名称(geoTargetConstants/{criterion_id},例如纽约市的 "geoTargetConstants/1023191")按目的地城市 (value) 进行过滤。
  • ActivityRatingInfo:按活动星级或房客评分(value,1 到 5 之间的整数,其中 5 为最高分)过滤。
  • ActivityIdInfo:按 Things to do Center Feed (value) 中定义的特定活动 ID 进行过滤。

维度层次结构规则

构建推荐活动产品信息组树时,请遵循以下规则:

  1. 根节点:每个产品信息组树都必须以单个根 AdGroupCriterion 开头,其 listing_group.type 为 SUBDIVISION(如果您希望使用单个包罗万象的节点,则为 UNIT),并且其 case_value 未设置。
  2. 细分和单位:中间分支必须将 type 设置为 SUBDIVISION,而叶节点必须将 type 设置为 UNIT。对于推荐活动广告系列,您可以选择是否在 UNIT 节点上设置 cpc_bid_micros,因为出价由广告系列的 MaximizeConversionValue 策略自动管理。如需从投放中排除叶单元,请在其 AdGroupCriterion 上设置 negative = true。
  3. 后备(“其他所有”)节点:每个细分都必须完全分区。细分的所有直接子级都必须使用相同的 ListingDimensionInfo 子类型,并且其中一个子级必须是该子类型的空实例,以捕获所有剩余商品。

以下树状图展示了按国家/地区、城市和活动 ID 划分的有效层次结构:

Root (SUBDIVISION)
 ├── ActivityCountryInfo: "geoTargetConstants/2840" (US, SUBDIVISION)
 │    ├── ActivityCityInfo: "geoTargetConstants/1023191" (New York, SUBDIVISION)
 │    │    ├── ActivityIdInfo: "activity_123" (UNIT, biddable)
 │    │    └── ActivityIdInfo: <empty> (UNIT, "Everything else in New York")
 │    └── ActivityCityInfo: <empty> (UNIT, "Everything else in US")
 └── ActivityCountryInfo: <empty> (UNIT, negative=true, excluded)

代码示例

以下 Python 示例使用临时 ID (-1) 创建根 SUBDIVISION,并按 ActivityCountryInfo 将其划分为针对美国 ("geoTargetConstants/2840") 的定位单元和针对所有其他国家/地区的排除后备单元:

ad_group_service = client.get_service("AdGroupService")
ad_group_criterion_service = client.get_service("AdGroupCriterionService")
ad_group_resource_name = ad_group_service.ad_group_path(
    customer_id, ad_group_id
)
operations = []

# 1. Create the root SUBDIVISION node with temporary criterion ID -1.
root_op = client.get_type("AdGroupCriterionOperation")
root = root_op.create
root.resource_name = ad_group_criterion_service.ad_group_criterion_path(
    customer_id, ad_group_id, -1
)
root.status = client.enums.AdGroupCriterionStatusEnum.ENABLED
root.listing_group.type_ = client.enums.ListingGroupTypeEnum.SUBDIVISION
operations.append(root_op)

# 2. Create a child UNIT node targeting activities in the US.
us_op = client.get_type("AdGroupCriterionOperation")
us_unit = us_op.create
us_unit.ad_group = ad_group_resource_name
us_unit.status = client.enums.AdGroupCriterionStatusEnum.ENABLED
us_unit.listing_group.type_ = client.enums.ListingGroupTypeEnum.UNIT
us_unit.listing_group.parent_ad_group_criterion = root.resource_name
us_unit.listing_group.case_value.activity_country.value = "geoTargetConstants/2840"
operations.append(us_op)

# 3. Create the required fallback ("Everything else") UNIT node.
other_op = client.get_type("AdGroupCriterionOperation")
other_unit = other_op.create
other_unit.ad_group = ad_group_resource_name
other_unit.negative = True
other_unit.listing_group.type_ = client.enums.ListingGroupTypeEnum.UNIT
other_unit.listing_group.parent_ad_group_criterion = root.resource_name
client.copy_from(
    other_unit.listing_group.case_value.activity_country,
    client.get_type("ActivityCountryInfo"),
)
operations.append(other_op)

response = ad_group_criterion_service.mutate_ad_group_criteria(
    customer_id=customer_id, operations=operations
)

后续步骤