建立使用者名單
透過集合功能整理內容
你可以依據偏好儲存及分類內容。
如果是 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: FlexibleRuleUserListInfo = (
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: FlexibleRuleOperandInfo = 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)
小茹
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::V21::Common::FlexibleRuleUserListInfo->new({
inclusiveRuleOperator => AND,
inclusiveOperands => [
Google::Ads::GoogleAds::V21::Common::FlexibleRuleOperandInfo->new({
rule => Google::Ads::GoogleAds::V21::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 => []});
在名單中加入過去的使用者
您也可以將過去的使用者納入以規則為準的使用者名單,方法是將使用者名單的 prepopulation_status
設為 REQUESTED
,並定期檢查這個欄位的狀態,監控非同步預先填入程序的進度。
系統只會加入過去 30 天內的使用者,具體取決於名單的效期和加入再行銷代碼的日期。要求處理完成後,狀態會更新為 FINISHED
,如果要求失敗,則會更新為 FAILED
。
除非另有註明,否則本頁面中的內容是採用創用 CC 姓名標示 4.0 授權,程式碼範例則為阿帕契 2.0 授權。詳情請參閱《Google Developers 網站政策》。Java 是 Oracle 和/或其關聯企業的註冊商標。
上次更新時間:2025-08-31 (世界標準時間)。
[null,null,["上次更新時間:2025-08-31 (世界標準時間)。"],[[["\u003cp\u003eGoogle Ads uses "disjunctive normal form" (OR of ANDs) by default, requiring every rule item in at least one rule item group to match for a visitor to be added to the list.\u003c/p\u003e\n"],["\u003cp\u003eYou can configure the list to use "conjunctive normal form" (AND of ORs) where at least one rule item in each rule item group must match, but this is not applicable to date-specific rule user lists.\u003c/p\u003e\n"],["\u003cp\u003ePast users (within the last 30 days) can be included in the list by setting the \u003ccode\u003eprepopulation_status\u003c/code\u003e to \u003ccode\u003eREQUESTED\u003c/code\u003e and monitoring its progress.\u003c/p\u003e\n"]]],[],null,["# Creating the User List\n\nFor [`expression_rule_user_list`](/google-ads/api/reference/rpc/v21/RuleBasedUserListInfo#expression_rule_user_list),\nthere's an additional distinction to make. By\ndefault, Google Ads will `AND` together all rule items in a rule item\ngroup. This means that **every rule item** in **at least one rule item group**\nmust match in order for the rule to add a visitor to the list. This is called\n\"disjunctive normal form\", or [`OR_OF_ANDS`](/google-ads/api/reference/rpc/v21/UserListRuleTypeEnum.UserListRuleType#or_of_ands).\n\nAlternatively, you could set up your list to only add a visitor to the list if\n**at least one rule item** in **each rule item group** matches. This\nis called \"conjunctive normal form\", or\n[`AND_OF_ORS`](/google-ads/api/reference/rpc/v21/UserListRuleTypeEnum.UserListRuleType#and_of_ors),\nand is available for [`expression_rule_user_list`](/google-ads/api/reference/rpc/v21/RuleBasedUserListInfo#expression_rule_user_list)\nby using the\n[`rule_type`](/google-ads/api/reference/rpc/v21/UserListRuleInfo#rule_type) field. Trying to\nuse `AND_OF_ORS` for a\n[`date_specific_rule_user_list`](/google-ads/api/reference/rpc/v21/RuleBasedUserListInfo#date_specific_rule_user_list)\nwill result in an error.\n\nAll that's left is to combine the rule item groups above into a new user\nlist. In this case, we'll leave the default `OR_OF_ANDS` functionality in place,\nsince that's what we built these rules for.\n\n\n### Java\n\n```java\nFlexibleRuleUserListInfo flexibleRuleUserListInfo =\n FlexibleRuleUserListInfo.newBuilder()\n .setInclusiveRuleOperator(UserListFlexibleRuleOperator.AND)\n .addInclusiveOperands(\n FlexibleRuleOperandInfo.newBuilder()\n .setRule(\n // The default rule_type for a UserListRuleInfo object is OR of ANDs\n // (disjunctive normal form). That is, rule items will be ANDed together\n // within rule item groups and the groups themselves will be ORed together.\n UserListRuleInfo.newBuilder()\n .addRuleItemGroups(checkoutDateRuleGroup)\n .addRuleItemGroups(checkoutAndCartSizeRuleGroup))\n // Optional: includes a lookback window for this rule, in days.\n .setLookbackWindowDays(7L))\n .build();https://github.com/googleads/google-ads-java/blob/3c3c1041c2a0ab81553e3b2a79876256649397ed/google-ads-examples/src/main/java/com/google/ads/googleads/examples/remarketing/SetUpAdvancedRemarketing.java#L196-L210\n \n```\n\n### C#\n\n```c#\nFlexibleRuleUserListInfo flexibleRuleUserListInfo = new FlexibleRuleUserListInfo();\nFlexibleRuleOperandInfo flexibleRuleOperandInfo = new FlexibleRuleOperandInfo() {\n Rule = new UserListRuleInfo()\n};\nflexibleRuleOperandInfo.Rule.RuleItemGroups.Add(checkoutAndCartSizeRuleGroup);\nflexibleRuleOperandInfo.Rule.RuleItemGroups.Add(checkoutDateRuleGroup);\nflexibleRuleUserListInfo.InclusiveOperands.Add(flexibleRuleOperandInfo);https://github.com/googleads/google-ads-dotnet/blob/ada966e1983b655e82172b6c3e7d9b091b522377/Google.Ads.GoogleAds/examples/Remarketing/SetUpAdvancedRemarketing.cs#L179-L185\n \n```\n\n### PHP\n\n```php\n$flexibleRuleUserListInfo = new FlexibleRuleUserListInfo([\n 'inclusive_rule_operator' =\u003e UserListFlexibleRuleOperator::PBAND,\n 'inclusive_operands' =\u003e [\n new FlexibleRuleOperandInfo([\n 'rule' =\u003e new UserListRuleInfo([\n // The default rule_type for a UserListRuleInfo object is OR of ANDs\n // (disjunctive normal form). That is, rule items will be ANDed together\n // within rule item groups and the groups themselves will be ORed together.\n 'rule_item_groups' =\u003e [\n $checkoutAndCartSizeRuleGroup,\n $checkoutDateRuleGroup\n ]\n ]),\n // Optionally add a lookback window for this rule, in days.\n 'lookback_window_days' =\u003e 7\n ])\n ],\n 'exclusive_operands' =\u003e []\n]); \nhttps://github.com/googleads/google-ads-php/blob/be0249c30c27b4760387bec6682b82c9f4167761/examples/Remarketing/SetUpAdvancedRemarketing.php#L198-L216\n\n \n```\n\n### Python\n\n```python\n# Create a FlexibleRuleUserListInfo object, or a flexible rule\n# representation of visitors with one or multiple actions.\n# FlexibleRuleUserListInfo wraps UserListRuleInfo in a\n# FlexibleRuleOperandInfo object that represents which user lists to\n# include or exclude.\nflexible_rule_user_list_info: FlexibleRuleUserListInfo = (\n rule_based_user_list_info.flexible_rule_user_list\n)\nflexible_rule_user_list_info.inclusive_rule_operator = (\n client.enums.UserListFlexibleRuleOperatorEnum.AND\n)\n# The default rule_type for a UserListRuleInfo object is OR of\n# ANDs (disjunctive normal form). That is, rule items will be\n# ANDed together within rule item groups and the groups\n# themselves will be ORed together.\nrule_operand: FlexibleRuleOperandInfo = client.get_type(\n \"FlexibleRuleOperandInfo\"\n)\nrule_operand.rule.rule_item_groups.extend(\n [\n checkout_and_cart_size_rule_group,\n checkout_date_rule_group,\n ]\n)\nrule_operand.lookback_window_days = 7\nflexible_rule_user_list_info.inclusive_operands.append(rule_operand)https://github.com/googleads/google-ads-python/blob/d0595698b8a7de6cc00684b467462601037c9db9/examples/remarketing/set_up_advanced_remarketing.py#L191-L216\n \n```\n\n### Ruby\n\n```ruby\nr.flexible_rule_user_list = client.resource.flexible_rule_user_list_info do |frul|\n frul.inclusive_rule_operator = :AND\n frul.inclusive_operands \u003c\u003c client.resource.flexible_rule_operand_info do |froi|\n froi.rule = client.resource.user_list_rule_info do |info|\n info.rule_item_groups += [checkout_date_rule_group, checkout_and_cart_size_rule_group]\n end\n # Optionally include a lookback window for this rule, in days.\n froi.lookback_window_days = 7\n end\nend \nhttps://github.com/googleads/google-ads-ruby/blob/2752563c7ffd15a4d2238116869f64aea3011cc3/examples/remarketing/set_up_advanced_remarketing.rb#L126-L135\n\n \n```\n\n### Perl\n\n```perl\nmy $flexible_rule_user_list_info =\n Google::Ads::GoogleAds::V21::Common::FlexibleRuleUserListInfo-\u003enew({\n inclusiveRuleOperator =\u003e AND,\n inclusiveOperands =\u003e [\n Google::Ads::GoogleAds::V21::Common::FlexibleRuleOperandInfo-\u003enew({\n rule =\u003e Google::Ads::GoogleAds::V21::Common::UserListRuleInfo-\u003enew({\n # The default rule_type for a UserListRuleInfo object is OR of\n # ANDs (disjunctive normal form). That is, rule items will be\n # ANDed together within rule item groups and the groups\n # themselves will be ORed together.\n ruleItemGroups =\u003e [\n $checkout_date_rule_group, $checkout_and_cart_size_rule_group\n ]}\n ),\n # Optionally include a lookback window for this rule, in days.\n lookback_window_days =\u003e 7\n })\n ],\n exclusiveOperands =\u003e []});https://github.com/googleads/google-ads-perl/blob/9abffd69cd856633dfdcee5c636fe9cd0eb4b5ed/examples/remarketing/set_up_advanced_remarketing.pl#L151-L169\n \n```\n\n\u003cbr /\u003e\n\nInclude past users in the list\n------------------------------\n\nYou can also include past users in a rule-based user list by setting the\n[`prepopulation_status`](/google-ads/api/reference/rpc/v21/RuleBasedUserListInfo#prepopulation_status)\nof the user list to\n[`REQUESTED`](/google-ads/api/reference/rpc/v21/UserListPrepopulationStatusEnum.UserListPrepopulationStatus#requested),\nand monitor the progress of the asynchronous prepopulation process by\nperiodically checking the status of this field.\n\nThis will only add past users from within the last 30 days, depending on the\nlist's membership duration and the date when the remarketing tag is added. The\nstatus will be updated to\n[`FINISHED`](/google-ads/api/reference/rpc/v21/UserListPrepopulationStatusEnum.UserListPrepopulationStatus#finished)\nonce the request is processed, or\n[`FAILED`](/google-ads/api/reference/rpc/v21/UserListPrepopulationStatusEnum.UserListPrepopulationStatus#failed)\nif the request fails."]]