Register for one of our Google Ads API Migration Workshops (October 5, 2021 - October 14, 2021)

Creating the Rule Item Groups

Create the first rule_item_group

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("ecomm_pagetype")
        .setStringRuleItem(
            UserListStringRuleItemInfo.newBuilder()
                .setOperator(UserListStringRuleItemOperator.EQUALS)
                .setValue("checkout")
                .build())
        .build();
      
      

C#

UserListRuleItemInfo checkoutRule = new UserListRuleItemInfo
{
    // 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.
    Name = "ecomm_pagetype",
    StringRuleItem = new UserListStringRuleItemInfo
    {
        Operator = UserListStringRuleItemOperator.Equals,
        Value = "checkout"
    }
};
      
      

PHP

$checkoutRule = new UserListRuleItemInfo([
    // 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.
    'name' => 'ecomm_pagetype',
    'string_rule_item' => new UserListStringRuleItemInfo([
        'operator' => UserListStringRuleItemOperator::EQUALS,
        'value' => 'checkout'
    ])
]);
      
      

Python

checkout_rule = client.get_type("UserListRuleItemInfo")

# 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.
checkout_rule.name = "ecomm_pagetype"
checkout_string_rule_item = checkout_rule.string_rule_item
checkout_string_rule_item.operator = (
    client.enums.UserListStringRuleItemOperatorEnum.EQUALS
)
checkout_string_rule_item.value = "checkout"
      
      

Ruby

g.rule_items << client.resource.user_list_rule_item_info do |rule|
  # 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.
  rule.name = "ecomm_pagetype"
  rule.string_rule_item = client.resource.user_list_string_rule_item_info do |sr|
    sr.operator = :EQUALS
    sr.value = "checkout"
  end
end
      
      

Perl

my $checkout_rule =
  Google::Ads::GoogleAds::V8::Common::UserListRuleItemInfo->new({
    # 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.
    name           => "ecomm_pagetype",
    stringRuleItem =>
      Google::Ads::GoogleAds::V8::Common::UserListStringRuleItemInfo->new({
        operator => EQUALS,
        value    => "checkout"
      })});
      
      

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("cart_size")
        .setNumberRuleItem(
            UserListNumberRuleItemInfo.newBuilder()
                .setOperator(UserListNumberRuleItemOperator.GREATER_THAN)
                .setValue(1.0)
                .build())
        .build();
      
      

C#

UserListRuleItemInfo cartSizeRule = new UserListRuleItemInfo
{
    // The rule variable name must match a corresponding key name fired from a pixel.
    Name = "cart_size",
    NumberRuleItem = new UserListNumberRuleItemInfo
    {
        Operator = UserListNumberRuleItemOperator.GreaterThan,
        Value = 1.0
    }
};
      
      

PHP

$cartSizeRule = new UserListRuleItemInfo([
    // The rule variable name must match a corresponding key name fired from a pixel.
    'name' => 'cart_size',
    'number_rule_item' => new UserListNumberRuleItemInfo([
        'operator' => UserListNumberRuleItemOperator::GREATER_THAN,
        'value' => 1.0
    ])
]);
      
      

Python

cart_size_rule = client.get_type("UserListRuleItemInfo")
# The rule variable name must match a corresponding key name fired from a
# pixel.
cart_size_rule.name = "cart_size"
cart_size_number_rule_item = cart_size_rule.number_rule_item
cart_size_number_rule_item.operator = (
    client.enums.UserListNumberRuleItemOperatorEnum.GREATER_THAN
)
cart_size_number_rule_item.value = 1.0
      
      

Ruby

g.rule_items << client.resource.user_list_rule_item_info do |rule|
  # The rule variable name must match a corresponding key name fired
  # from a pixel.
  rule.name = "cart_size"
  rule.number_rule_item = client.resource.user_list_number_rule_item_info do |nr|
    nr.operator = :GREATER_THAN
    nr.value = 1.0
  end
end
      
      

Perl

my $cart_size_rule =
  Google::Ads::GoogleAds::V8::Common::UserListRuleItemInfo->new({
    # The rule variable name must match a corresponding key name fired from a
    # pixel.
    name           => "cart_size",
    numberRuleItem =>
      Google::Ads::GoogleAds::V8::Common::UserListNumberRuleItemInfo->new({
        # Available UserListNumberRuleItemOperators can be found at
        # https://developers.google.com/google-ads/api/reference/rpc/latest/UserListNumberRuleItemOperatorEnum.UserListNumberRuleItemOperator
        operator => GREATER_THAN,
        value    => 1.0
      })});
      
      

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();
      
      

C#

UserListRuleItemGroupInfo checkoutAndCartSizeRuleGroup =
    new UserListRuleItemGroupInfo();
checkoutAndCartSizeRuleGroup.RuleItems.Add(checkoutRule);
checkoutAndCartSizeRuleGroup.RuleItems.Add(cartSizeRule);
      
      

PHP

$checkoutAndCartSizeRuleGroup = new UserListRuleItemGroupInfo([
    'rule_items' => [$checkoutRule, $cartSizeRule]
]);
      
      

Python

checkout_and_cart_size_rule_group.rule_items.extend(
    [
        checkout_rule,
        cart_size_rule,
    ]
)
      
      

Ruby

info.rule_item_groups << client.resource.user_list_rule_item_group_info do |g|
      
      

Perl

my $checkout_and_cart_size_rule_group =
  Google::Ads::GoogleAds::V8::Common::UserListRuleItemGroupInfo->new(
  {ruleItems => [$checkout_rule, $cart_size_rule]});
      
      

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("checkoutdate")
        .setDateRuleItem(
            UserListDateRuleItemInfo.newBuilder()
                // Available UserListDateRuleItemOperators can be found at
                // https://developers.google.com/google-ads/api/reference/rpc/latest/UserListDateRuleItemOperatorEnum.UserListDateRuleItemOperator
                .setOperator(UserListDateRuleItemOperator.AFTER)
                .setValue("20191031")
                .build())
        .build();
      
      

C#

UserListRuleItemInfo startDateRule = new UserListRuleItemInfo
{
    // The rule variable name must match a corresponding key name fired from a pixel.
    Name = "checkoutdate",
    DateRuleItem = new UserListDateRuleItemInfo
    {
        // Available UserListDateRuleItemOperators can be found at
        // https://developers.google.com/google-ads/api/reference/rpc/latest/UserListDateRuleItemOperatorEnum.UserListDateRuleItemOperator
        Operator = UserListDateRuleItemOperator.After,
        Value = "20191031"
    }
};
      
      

PHP

$startDateRule = new UserListRuleItemInfo([
    // The rule variable name must match a corresponding key name fired from a pixel.
    'name' => 'checkoutdate',
    'date_rule_item' => new UserListDateRuleItemInfo([
        // Available UserListDateRuleItemOperators can be found at
        // https://developers.google.com/google-ads/api/reference/rpc/latest/UserListDateRuleItemOperatorEnum.UserListDateRuleItemOperator
        'operator' => UserListDateRuleItemOperator::AFTER,
        'value' => '20191031'
    ])
]);
      
      

Python

start_date_rule = client.get_type("UserListRuleItemInfo")
start_date_rule.name = "checkoutdate"
start_date_rule_item = start_date_rule.date_rule_item
# Available UserListDateRuleItemOperators can be found at:
# https://developers.google.com/google-ads/api/reference/rpc/latest/UserListDateRuleItemOperatorEnum.UserListDateRuleItemOperator
user_list_data_rule_item_operator_enum = (
    client.enums.UserListDateRuleItemOperatorEnum
)
start_date_rule_item.operator = user_list_data_rule_item_operator_enum.AFTER
start_date_rule_item.value = "20191031"
      
      

Ruby

g.rule_items << client.resource.user_list_rule_item_info do |rule|
  # The rule variable name must match a corresponding key name fired
  # from a pixel.
  rule.name = "checkoutdate"
  rule.date_rule_item = client.resource.user_list_date_rule_item_info do |dr|
    dr.operator = :AFTER
    dr.value = "20191031"
  end
end
      
      

Perl

my $start_date_rule =
  Google::Ads::GoogleAds::V8::Common::UserListRuleItemInfo->new({
    # The rule variable name must match a corresponding key name fired from a
    # pixel.
    name         => "checkoutdate",
    dateRuleItem =>
      Google::Ads::GoogleAds::V8::Common::UserListDateRuleItemInfo->new({
        # Available UserListDateRuleItemOperators can be found at
        # https://developers.google.com/google-ads/api/reference/rpc/latest/UserListDateRuleItemOperatorEnum.UserListDateRuleItemOperator
        operator => AFTER,
        value    => "20191031"
      })});
      
      

Then, the end date:

Java

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

C#

UserListRuleItemInfo endDateRule = new UserListRuleItemInfo
{
    // The rule variable name must match a corresponding key name fired from a pixel.
    Name = "checkoutdate",
    DateRuleItem = new UserListDateRuleItemInfo
    {
        Operator = UserListDateRuleItemOperator.Before,
        Value = "20200101"
    }
};
      
      

PHP

$endDateRule = new UserListRuleItemInfo([
    // The rule variable name must match a corresponding key name fired from a pixel.
    'name' => 'checkoutdate',
    'date_rule_item' => new UserListDateRuleItemInfo([
        'operator' => UserListDateRuleItemOperator::BEFORE,
        'value' => '20200101'
    ])
]);
      
      

Python

end_date_rule = client.get_type("UserListRuleItemInfo")
end_date_rule.name = "checkoutdate"
end_date_rule_item = end_date_rule.date_rule_item
end_date_rule_item.operator = user_list_data_rule_item_operator_enum.BEFORE
end_date_rule_item.value = "20200101"
      
      

Ruby

g.rule_items << client.resource.user_list_rule_item_info do |rule|
  # The rule variable name must match a corresponding key name fired
  # from a pixel.
  rule.name = "checkoutdate"
  rule.date_rule_item = client.resource.user_list_date_rule_item_info do |dr|
    dr.operator = :BEFORE
    dr.value = "20200101"
  end
end
      
      

Perl

my $end_date_rule =
  Google::Ads::GoogleAds::V8::Common::UserListRuleItemInfo->new({
    # The rule variable name must match a corresponding key name fired from a
    # pixel.
    name         => "checkoutdate",
    dateRuleItem =>
      Google::Ads::GoogleAds::V8::Common::UserListDateRuleItemInfo->new({
        operator => BEFORE,
        value    => "20200101"
      })});
      
      

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();
      
      

C#

UserListRuleItemGroupInfo checkoutDateRuleGroup = new UserListRuleItemGroupInfo();
checkoutDateRuleGroup.RuleItems.Add(startDateRule);
checkoutDateRuleGroup.RuleItems.Add(endDateRule);
      
      

PHP

$checkoutDateRuleGroup = new UserListRuleItemGroupInfo([
    'rule_items' => [$startDateRule, $endDateRule]
]);
      
      

Python

checkout_date_rule_group.rule_items.extend(
    [
        start_date_rule,
        end_date_rule,
    ]
)
      
      

Ruby

info.rule_item_groups << client.resource.user_list_rule_item_group_info do |g|
      
      

Perl

my $checkout_date_rule_group =
  Google::Ads::GoogleAds::V8::Common::UserListRuleItemGroupInfo->new(
  {ruleItems => [$start_date_rule, $end_date_rule]});