You can use user lists in your remarketing campaigns to re-engage with users who
have performed specific actions on your website or app. The Google Ads API supports
several types of user lists. This guide focuses on creating rule-based user
lists using the rule item groups defined in
[Create rule item groups](https://developers.google.com/google-ads/api/docs/remarketing/audience-segments/scenario/rule-item-groups.md.txt).

## Rule-based user lists

Rule-based user lists built with
[`flexible_rule_user_list`](https://developers.google.com/google-ads/api/reference/rpc/v26/RuleBasedUserListInfo.md.txt#flexible_rule_user_list) can contain multiple rules
(`inclusive_rule` and `exclusive_rule`, joined by
[`inclusive_rule_operator`](https://developers.google.com/google-ads/api/reference/rpc/v26/FlexibleRuleUserListInfo.md.txt#inclusive_rule_operator)). Each rule is represented
by a [`UserListRuleInfo`](https://developers.google.com/google-ads/api/reference/rpc/v26/UserListRuleInfo.md.txt) message, which has a
[`rule_type`](https://developers.google.com/google-ads/api/reference/rpc/v26/UserListRuleInfo.md.txt#rule_type) field that dictates how rule items within rule item
groups are combined.

Although [`UserListRuleTypeEnum`](https://developers.google.com/google-ads/api/reference/rpc/v26/UserListRuleTypeEnum.UserListRuleType.md.txt) defines both
[`OR_OF_ANDS`](https://developers.google.com/google-ads/api/reference/rpc/v26/UserListRuleTypeEnum.UserListRuleType.md.txt#or_of_ands) (disjunctive normal form) and
[`AND_OF_ORS`](https://developers.google.com/google-ads/api/reference/rpc/v26/UserListRuleTypeEnum.UserListRuleType.md.txt#and_of_ors) (conjunctive normal form), **`OR_OF_ANDS` is the only
supported `rule_type` for [`FlexibleRuleUserListInfo`](https://developers.google.com/google-ads/api/reference/rpc/v26/FlexibleRuleUserListInfo.md.txt)**
(setting `AND_OF_ORS` returns
[`UserListError.RULE_TYPE_IS_NOT_SUPPORTED`](https://developers.google.com/google-ads/api/reference/rpc/v26/UserListErrorEnum.UserListError.md.txt#rule_type_is_not_supported)). With
`OR_OF_ANDS`, Google Ads `AND`s together all rule items in a rule item group, which
means that for a given rule, **every rule item** in **at least one rule item
group** must match for the rule to be satisfied.

After defining the two `UserListRuleItemGroupInfo` objects in
[Create rule item groups](https://developers.google.com/google-ads/api/docs/remarketing/audience-segments/scenario/rule-item-groups.md.txt), combine them into a new user list.
The following code example leaves the default `OR_OF_ANDS` rule type in place,
adds both rule item groups to a [`FlexibleRuleOperandInfo`](https://developers.google.com/google-ads/api/reference/rpc/v26/FlexibleRuleOperandInfo.md.txt) on
[`FlexibleRuleUserListInfo`](https://developers.google.com/google-ads/api/reference/rpc/v26/FlexibleRuleUserListInfo.md.txt), and mutates the user list:


### Java

```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#

```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

```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

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

### Ruby

```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

```perl
my $flexible_rule_user_list_info =
  Google::Ads::GoogleAds::V26::Common::FlexibleRuleUserListInfo->new({
    inclusiveRuleOperator => AND,
    inclusiveOperands     => [
      Google::Ads::GoogleAds::V26::Common::FlexibleRuleOperandInfo->new({
          rule => Google::Ads::GoogleAds::V26::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 => []});
      
```

### curl

> [!NOTE]
> **Note:** While a direct REST code sample for this step isn't provided here, you can achieve this using a manual REST request.   
>
> Refer to the Google Ads API REST interface documentation and the method-specific reference pages. You will need to construct the JSON payload based on the proto definitions.   
>
> Key Resources:
>
> - [Using REST](https://developers.google.com/google-ads/api/rest/overview.md.txt)
> - [REST Interface Structure](https://developers.google.com/google-ads/api/rest/design/overview.md.txt)
> - [JSON Field Mappings](https://developers.google.com/google-ads/api/rest/design/json-mappings.md.txt)
> - Consult the [REST API Reference](https://developers.google.com/google-ads/api/reference/rpc/latest/overview) for the specific service and method.

<br />

## Include past users in a rule-based list

You can also include past website visitors or app users in a rule-based user
list (supported on the **Display Network only** ) by setting the
[`prepopulation_status`](https://developers.google.com/google-ads/api/reference/rpc/v26/RuleBasedUserListInfo.md.txt#prepopulation_status) of the user list to
[`REQUESTED`](https://developers.google.com/google-ads/api/reference/rpc/v26/UserListPrepopulationStatusEnum.UserListPrepopulationStatus.md.txt#requested), and monitor the progress of the asynchronous
prepopulation process by periodically checking the status of this field.

Prepopulation only adds past users from within the last 30 days, depending on
the list's [`membership_life_span`](https://developers.google.com/google-ads/api/reference/rpc/v26/UserList.md.txt#membership_life_span) (from 1 to 540 days)
and the date when the remarketing tag was added. The status updates to
[`FINISHED`](https://developers.google.com/google-ads/api/reference/rpc/v26/UserListPrepopulationStatusEnum.UserListPrepopulationStatus.md.txt#finished) once the request is processed, or
[`FAILED`](https://developers.google.com/google-ads/api/reference/rpc/v26/UserListPrepopulationStatusEnum.UserListPrepopulationStatus.md.txt#failed) if the request fails.

> [!NOTE]
> **Note:** Prepopulation applies only to the Display Network and requires an active Google tag on your website firing the custom parameters referenced in your rules. If `prepopulation_status` changes to `FAILED`, verify that your Google tag is properly installed and collecting parameter data, then submit a new update setting `prepopulation_status` to `REQUESTED`.

## Target the user list and adjust bids

Once you have created your `UserList`, attach its resource name to an
[`AdGroupCriterion`](https://developers.google.com/google-ads/api/reference/rpc/v26/AdGroupCriterion.md.txt) or
[`CampaignCriterion`](https://developers.google.com/google-ads/api/reference/rpc/v26/CampaignCriterion.md.txt) and set `bid_modifier` (for example,
`1.25` for a 25% bid increase). For code examples demonstrating how to target a
user list and modify bids, see
[Target the list](https://developers.google.com/google-ads/api/docs/remarketing/audience-segments/website-visitors.md.txt#target-the-list).