Creating the Rule Item Groups

Create the first rule_item_group

Let's start by creating the first rule_item_group which consists of two rule_item fields, or UserListRuleItemInfo objects:

  1. Users who visited the checkout page.
  2. Users with more than one item in their shopping cart.

The first rule item uses the ecomm_pagetype parameter which has string values, so you must create a string_rule_item first.

Java

UserListRuleItemInfo checkoutRule =
    UserListRuleItemInfo.newBuilder()
        // The rule variable name must match a corresponding key name fired from a pixel.
        // To learn more about setting up remarketing tags, visit
        // https://support.google.com/google-ads/answer/2476688.
        // To learn more about remarketing events and parameters, visit
        // https://support.google.com/google-ads/answer/7305793.
        .setName(StringValue.of("ecomm_pagetype"))
        .setStringRuleItem(
            UserListStringRuleItemInfo.newBuilder()
                .setOperator(UserListStringRuleItemOperator.EQUALS)
                .setValue(StringValue.of("checkout"))
                .build())
        .build();

The second rule item uses the cartsize parameter which has numeric values, so now you'll need a number_rule_item.

Java

UserListRuleItemInfo cartSizeRule =
    UserListRuleItemInfo.newBuilder()
        // The rule variable name must match a corresponding key name fired from a pixel.
        .setName(StringValue.of("cart_size"))
        .setNumberRuleItem(
            UserListNumberRuleItemInfo.newBuilder()
                .setOperator(UserListNumberRuleItemOperator.GREATER_THAN)
                .setValue(DoubleValue.of(1.0))
                .build())
        .build();

Next, combine the two rule items into a UserListRuleItemGroupInfo object. By default, when items are combined into an item group, Google Ads will AND their rules together. Creating the User List has more details.

Java

UserListRuleItemGroupInfo checkoutAndCartSizeRuleGroup =
    UserListRuleItemGroupInfo.newBuilder()
        .addAllRuleItems(ImmutableList.of(checkoutRule, cartSizeRule))
        .build();

Create the second rule_item_group

The second rule_item_group also consists of two rule_item fields, or UserListRuleItemInfo objects:

  1. Users who checked out after October 31st.
  2. Users who checked out before January 1st.

Both of these rule items use the checkoutdate parameter which has date values, so this time you'll populate the date_rule_item fields with UserListDateRuleItemInfo objects.

First the start date:

Java

UserListRuleItemInfo startDateRule =
    UserListRuleItemInfo.newBuilder()
        // The rule variable name must match a corresponding key name fired from a pixel.
        .setName(StringValue.of("checkoutdate"))
        .setDateRuleItem(
            UserListDateRuleItemInfo.newBuilder()
                // Available UserListDateRuleItemOperators can be found at
                // https://developers.google.com/google-ads/api/reference/rpc/google.ads.googleads.v3.enums#google.ads.googleads.v3.enums.UserListDateRuleItemOperatorEnum.UserListDateRuleItemOperator
                .setOperator(UserListDateRuleItemOperator.AFTER)
                .setValue(StringValue.of("20191031"))
                .build())
        .build();

Then, the end date:

Java

UserListRuleItemInfo endDateRule =
    UserListRuleItemInfo.newBuilder()
        // The rule variable name must match a corresponding key name fired from a pixel.
        .setName(StringValue.of("checkoutdate"))
        .setDateRuleItem(
            UserListDateRuleItemInfo.newBuilder()
                .setOperator(UserListDateRuleItemOperator.BEFORE)
                .setValue(StringValue.of("20200101"))
                .build())
        .build();

As with the first rule item group, combine these two rule_item fields into a UserListRuleItemGroupInfo object to AND them together.

Java

UserListRuleItemGroupInfo checkoutDateRuleGroup =
    UserListRuleItemGroupInfo.newBuilder()
        .addAllRuleItems(ImmutableList.of(startDateRule, endDateRule))
        .build();