Visitors to Specific Pages

You can target people who have visited specific pages or sections of your website using an expression_rule_user_list targeted to more specific URLs, not just your website's domain.

See Rule-based remarketing for an example and more details.

Visitors of a page who did visit another page

You can target people who visited more than one page using a combined_rule_user_list. The targeting would be done the same way as in the previous example. Only the first step changes, where you use a combined_rule_user_list rather than an expression_rule_user_list.

First, create two rules. Then, combine the rules with the combined_rule_user_list.

Java

private void runExample(GoogleAdsClient googleAdsClient, long customerId) {
  String urlString = "url__";

  // Creates a rule targeting any user that visited a url that equals
  // http://example.com/example1'.
  UserListRuleItemInfo userVisitedSite1Rule =
      UserListRuleItemInfo.newBuilder()
          // Uses a built-in parameter to create a domain URL rule.
          .setName(StringValue.of(urlString))
          .setStringRuleItem(
              UserListStringRuleItemInfo.newBuilder()
                  .setOperator(UserListStringRuleItemOperator.EQUALS)
                  .setValue(StringValue.of("http://example.com/example1"))
                  .build())
          .build();

  // Creates a UserListRuleInfo object containing the first rule.
  UserListRuleInfo userVisitedSite1RuleInfo =
      UserListRuleInfo.newBuilder()
          .addRuleItemGroups(
              UserListRuleItemGroupInfo.newBuilder().addRuleItems(userVisitedSite1Rule).build())
          .build();

  // Creates a rule targeting any user that visited a url that equals
  // http://example.com/example2'.
  UserListRuleItemInfo userVisitedSite2Rule =
      UserListRuleItemInfo.newBuilder()
          // Uses a built-in parameter to create a domain URL rule.
          .setName(StringValue.of(urlString))
          .setStringRuleItem(
              UserListStringRuleItemInfo.newBuilder()
                  .setOperator(UserListStringRuleItemOperator.EQUALS)
                  .setValue(StringValue.of("http://example.com/example2"))
                  .build())
          .build();

  // Creates a UserListRuleInfo object containing the second rule.
  UserListRuleInfo userVisitedSite2RuleInfo =
      UserListRuleInfo.newBuilder()
          .addRuleItemGroups(
              UserListRuleItemGroupInfo.newBuilder().addRuleItems(userVisitedSite2Rule).build())
          .build();

  // Creates the user list where "Visitors of a page who did visit another page". To create a user
  // list where "Visitors of a page who did not visit another page", change the
  // UserListCombinedRuleOperator from AND to AND_NOT.
  CombinedRuleUserListInfo combinedRuleUserListInfo =
      CombinedRuleUserListInfo.newBuilder()
          .setLeftOperand(userVisitedSite1RuleInfo)
          .setRightOperand(userVisitedSite2RuleInfo)
          .setRuleOperator(UserListCombinedRuleOperator.AND)
          .build();

  // Defines a representation of a user list that is generated by a rule.
  RuleBasedUserListInfo ruleBasedUserListInfo =
      RuleBasedUserListInfo.newBuilder()
          // Optional: To include past users in the user list, set the prepopulation_status to
          // REQUESTED.
          .setPrepopulationStatus(UserListPrepopulationStatus.REQUESTED)
          .setCombinedRuleUserList(combinedRuleUserListInfo)
          .build();

  // Creates a user list.
  UserList userList =
      UserList.newBuilder()
          .setName(
              StringValue.of(
                  "All visitors to http://example.com/example1 AND http://example.com/example2 #"
                      + System.currentTimeMillis()))
          .setDescription(
              StringValue.of(
                  "Visitors of both http://example.com/example1 AND http://example.com/example2"))
          .setMembershipStatus(UserListMembershipStatus.OPEN)
          .setMembershipLifeSpan(Int64Value.of(365))
          .setRuleBasedUserList(ruleBasedUserListInfo)
          .build();

  // Creates the operation.
  UserListOperation operation = UserListOperation.newBuilder().setCreate(userList).build();

  // Creates the user list service client.
  try (UserListServiceClient userListServiceClient =
      googleAdsClient.getLatestVersion().createUserListServiceClient()) {
    // Adds the user list.
    MutateUserListsResponse response =
        userListServiceClient.mutateUserLists(
            Long.toString(customerId), ImmutableList.of(operation));
    String userListResourceName = response.getResults(0).getResourceName();
    // Prints the result.
    System.out.printf("Created user list with resource name '%s'.%n", userListResourceName);
  }
}

Visitors of a page who did not visit another page

You can target people who visited one page but not another page by using combined_rule_user_list. The only change that would have to be made to the previous example is that the rule_operator needs to change from AND to AND_NOT.