创建用户名单

对于 expression_rule_user_list,还需要进行其他区分。默认情况下,Google Ads 会对规则项目组中的所有规则项目一并进行 AND 操作。这意味着,至少一个规则项目组中的每个规则项目必须都匹配,才能使该规则将访问者添加到列表中。这称为“析取范式”或 OR_OF_ANDS

或者,如果各个规则项目组至少一个规则项目符合条件,您可以将列表设置为仅向其中添加一位访问者。这称为“合取范式”或 AND_OF_ORS,通过 rule_type 字段可用于 expression_rule_user_list。尝试将 AND_OF_ORS 用于 date_specific_rule_user_list 会导致错误。

现在,只要将上述规则项目组合并成新的用户列表即可。在本示例中,我们将保留默认的 OR_OF_ANDS 功能,因为这是我们构建这些规则的目的所在。

Java

FlexibleRuleUserListInfo flexibleRuleUserListInfo =
    FlexibleRuleUserListInfo.newBuilder()
        .setInclusiveRuleOperator(UserListFlexibleRuleOperator.AND)
        .addInclusiveOperands(
            FlexibleRuleOperandInfo.newBuilder()
                .setRule(
                    // The default rule_type for a UserListRuleInfo object is OR of ANDs
                    // (disjunctive normal form). That is, rule items will be ANDed together
                    // within rule item groups and the groups themselves will be ORed together.
                    UserListRuleInfo.newBuilder()
                        .addRuleItemGroups(checkoutDateRuleGroup)
                        .addRuleItemGroups(checkoutAndCartSizeRuleGroup))
                // Optional: includes a lookback window for this rule, in days.
                .setLookbackWindowDays(7L))
        .build();
      

C#

FlexibleRuleUserListInfo flexibleRuleUserListInfo = new FlexibleRuleUserListInfo();
FlexibleRuleOperandInfo flexibleRuleOperandInfo = new FlexibleRuleOperandInfo() {
    Rule = new UserListRuleInfo()
};
flexibleRuleOperandInfo.Rule.RuleItemGroups.Add(checkoutAndCartSizeRuleGroup);
flexibleRuleOperandInfo.Rule.RuleItemGroups.Add(checkoutDateRuleGroup);
flexibleRuleUserListInfo.InclusiveOperands.Add(flexibleRuleOperandInfo);
      

PHP

$flexibleRuleUserListInfo = new FlexibleRuleUserListInfo([
    'inclusive_rule_operator' => UserListFlexibleRuleOperator::PBAND,
    'inclusive_operands' => [
        new FlexibleRuleOperandInfo([
            'rule' => new UserListRuleInfo([
                // The default rule_type for a UserListRuleInfo object is OR of ANDs
                // (disjunctive normal form). That is, rule items will be ANDed together
                // within rule item groups and the groups themselves will be ORed together.
                'rule_item_groups' => [
                    $checkoutAndCartSizeRuleGroup,
                    $checkoutDateRuleGroup
                ]
            ]),
            // Optionally add a lookback window for this rule, in days.
            'lookback_window_days' => 7
        ])
    ],
    'exclusive_operands' => []
]);
      

Python

# Create a FlexibleRuleUserListInfo object, or a flexible rule
# representation of visitors with one or multiple actions.
# FlexibleRuleUserListInfo wraps UserListRuleInfo in a
# FlexibleRuleOperandInfo object that represents which user lists to
# include or exclude.
flexible_rule_user_list_info = (
    rule_based_user_list_info.flexible_rule_user_list
)
flexible_rule_user_list_info.inclusive_rule_operator = (
    client.enums.UserListFlexibleRuleOperatorEnum.AND
)
# The default rule_type for a UserListRuleInfo object is OR of
# ANDs (disjunctive normal form). That is, rule items will be
# ANDed together within rule item groups and the groups
# themselves will be ORed together.
rule_operand = client.get_type("FlexibleRuleOperandInfo")
rule_operand.rule.rule_item_groups.extend(
    [
        checkout_and_cart_size_rule_group,
        checkout_date_rule_group,
    ]
)
rule_operand.lookback_window_days = 7
flexible_rule_user_list_info.inclusive_operands.append(rule_operand)
      

Ruby

r.flexible_rule_user_list = client.resource.flexible_rule_user_list_info do |frul|
  frul.inclusive_rule_operator = :AND
  frul.inclusive_operands << client.resource.flexible_rule_operand_info do |froi|
    froi.rule = client.resource.user_list_rule_info do |info|
      info.rule_item_groups += [checkout_date_rule_group, checkout_and_cart_size_rule_group]
    end
    # Optionally include a lookback window for this rule, in days.
    froi.lookback_window_days = 7
  end
end
      

Perl

my $flexible_rule_user_list_info =
  Google::Ads::GoogleAds::V16::Common::FlexibleRuleUserListInfo->new({
    inclusiveRuleOperator => AND,
    inclusiveOperands     => [
      Google::Ads::GoogleAds::V16::Common::FlexibleRuleOperandInfo->new({
          rule => Google::Ads::GoogleAds::V16::Common::UserListRuleInfo->new({
              # The default rule_type for a UserListRuleInfo object is OR of
              # ANDs (disjunctive normal form). That is, rule items will be
              # ANDed together within rule item groups and the groups
              # themselves will be ORed together.
              ruleItemGroups => [
                $checkout_date_rule_group, $checkout_and_cart_size_rule_group
              ]}
          ),
          # Optionally include a lookback window for this rule, in days.
          lookback_window_days => 7
        })
    ],
    exclusiveOperands => []});
      

通过网站访问日期范围加以限制

上述 expression_rule_user_list 可以满足您的需求,但如果您只希望捕获符合该列表中规则并在 10 月 1 日至 12 月 31 日期间访问您的网站的用户,该怎么办?使用 date_specific_rule_user_list

date_specific_rule_user_list 的创建过程与 expression_rule_user_list 的创建过程相同。请使用 DateSpecificRuleUserListInfo 对象设置 date_specific_rule_user_list 字段,而不是设置 RuleBasedUserListInfo 对象的 expression_rule_user_list 字段。此对象将包含 start_dateend_date 的字段。

DateSpecificRuleUserListInfo dateSpecificRuleUserListInfo =
    DateSpecificRuleUserListInfo.newBuilder()
        .setRule(
            UserListRuleInfo.newBuilder()
                .addAllRuleItemGroups(
                    ImmutableList.of(checkoutAndCartSizeRuleGroup, checkoutDateRuleGroup)))
        .setStartDate(StringValue.of("2019-10-01"))
        .setEndDate(StringValue.of("2019-12-31"))
        .build();

新列表将包含与上一个列表满足相同规则,但仅限在 start_date(含)和 end_date(含)之间访问您的网站的所有用户。

在列表中加入过往用户

您还可以通过将用户列表的 prepopulation_status 设置为 REQUESTED,将过往用户添加到基于规则的用户列表中,并通过定期检查此字段的状态来监控异步预填充过程的进度。

此操作仅会添加过去 30 天内的过往用户,具体取决于名单的成员资格有效期和添加再营销代码的日期。请求处理完毕后,状态将更新为 FINISHED;如果请求失败,状态将更新为 FAILED