---
title: "Create and add rules to a segment in Sitecore CDP"
slug: "create-and-add-rules-to-a-segment-in-sitecore-cdp"
abstract: "How to create a segment and add rules (Sitecore CDP)."
---
# Create and add rules to a segment in Sitecore CDP

You can create a segment to [use within Sitecore CDP](https://doc.sitecore.com/cdp/en/users/sitecore-cdp/introduction-to-batch-segmentation/using-segments-within-sitecore-cdp.html "Using segments within Sitecore CDP") or to interrogate your organization's data. After you create a segment, you must [schedule the segment](https://doc.sitecore.com/cdp/en/users/sitecore-cdp/introduction-to-batch-segmentation/managing-segment-status-in-sitecore-cdp/schedule-a-segment-in-sitecore-cdp.html "Schedule a segment in Sitecore CDP") to be included in your organization's nightly segment build. You do not need to schedule the segment if you are just interrogating your organization's data.

## Create a segment

To create a segment:

1. On the navigation menu, click **Batch segments** > **Batch segments**.
2. Click **Create Segment**.
3. In the **Title of Segment** dialog, enter an intuitive name for the segment and click **Create**.
4. In the segment builder, to view the available fields and attributes that you can add to your segment rule, click one of the following entities and the related entity type that displays in **Segment rules**:
    - **[Guest](https://doc.sitecore.com/cdp/en/users/sitecore-cdp/data-availability-in-sitecore-cdp/available-data-types/guest-data.html "Guest data")**
    - **[Session](https://doc.sitecore.com/cdp/en/users/sitecore-cdp/data-availability-in-sitecore-cdp/available-data-types/sessions-data.html "Sessions data")**
    - **[Event](https://doc.sitecore.com/cdp/en/users/sitecore-cdp/data-availability-in-sitecore-cdp/available-data-types/event-data.html "Event data")**
    - **[Order](https://doc.sitecore.com/cdp/en/users/sitecore-cdp/data-availability-in-sitecore-cdp/available-data-types/order-data.html "Order data")**
    - **[Order Item](https://doc.sitecore.com/cdp/en/users/sitecore-cdp/data-availability-in-sitecore-cdp/available-data-types/order-item-data.html "Order item data")**

        > [!note]
        > The entities that display depend on the data your organization has passed to Sitecore CDP using the Sitecore CDP APIs. For example, if your organization has not passed orders and order items to Sitecore CDP yet, you will not see the **Order** and **Order Item** entities.

5. To add a field or attribute to the rule, click **\+ Add**. To [see an instant number](https://doc.sitecore.com/cdp/en/users/sitecore-cdp/introduction-to-batch-segmentation/create-and-add-rules-to-a-segment-in-sitecore-cdp/interrogating-your-organization-s-data-in-sitecore-cdp.html "Interrogating your organization's data in Sitecore CDP") of guests that have a specific attribute, hover over the chart ![seg_cdp_charticon.png](https://doc.sitecore.com/api/markdown-image/cdp/en/users/sitecore-cdp/images/seg_cdp_charticon.png) icon next to the attribute, as shown in the following screenshot.

    > [!warning]
    > Data availability in segments
    >
    > Sitecore CDP runs a nightly processing service that provides the most recent guest data to segments. The service runs at `00:00` UTC. This means that any data used to create a segment is based on data up to the last time the service ran. For example, if you create a segment of customers with abandoned carts, Sitecore CDP will include customers with abandoned carts up to `00:00` UTC. Any customers with abandoned carts after this time will be available for segments when the service runs again at `00:00` UTC.
    >
    > The daily processing service can also affect when certain values display in the segment builder for selection. For example, if you want to create a segment that uses a new event type named `ADD_TO_WISHLIST`, it won't display as a value for selection in the UI until you have at least one guest with an `ADD_TO_WISHLIST` event that was raised before the last processing service ran, `00:00` UTC.

    ![Viewing embedded analytics in batch segmentation.](https://doc.sitecore.com/api/markdown-image/cdp/en/users/sitecore-cdp/images/Segment_builder_hover.png)

6. Click a comparator to use in the rule from the drop-down list. Comparators are based on the following data types:
    - **[String](https://doc.sitecore.com/cdp/en/users/sitecore-cdp/introduction-to-batch-segmentation/create-and-add-rules-to-a-segment-in-sitecore-cdp/using-comparators-in-a-segment/using-string-comparators-in-a-segment.html "Using string comparators in a segment")**
    - **[Number](https://doc.sitecore.com/cdp/en/users/sitecore-cdp/introduction-to-batch-segmentation/create-and-add-rules-to-a-segment-in-sitecore-cdp/using-comparators-in-a-segment/using-number-comparators-in-a-segment.html "Using number comparators in a segment")**
    - **[Boolean](https://doc.sitecore.com/cdp/en/users/sitecore-cdp/introduction-to-batch-segmentation/create-and-add-rules-to-a-segment-in-sitecore-cdp/using-comparators-in-a-segment/using-boolean-comparators-in-a-segment.html "Using Boolean comparators in a segment")**
    - **[Date](https://doc.sitecore.com/cdp/en/users/sitecore-cdp/introduction-to-batch-segmentation/create-and-add-rules-to-a-segment-in-sitecore-cdp/using-comparators-in-a-segment/using-date-comparators-in-a-segment.html "Using date comparators in a segment")**
    - **[Other](https://doc.sitecore.com/cdp/en/users/sitecore-cdp/introduction-to-batch-segmentation/create-and-add-rules-to-a-segment-in-sitecore-cdp/using-comparators-in-a-segment/using-other-comparators-in-a-segment.html "Using other comparators in a segment")**
7. Enter or select the related value from the drop-down list then click ![Add_rule.png](https://doc.sitecore.com/api/markdown-image/cdp/en/users/sitecore-cdp/images/Add_rule.png) to save the rule. The list includes values based on guest data from the last 24 hours of interaction. Data from ongoing guest interactions will display in the list after 24 hours.

    ![Selecting a value for the field and comparator within a rule group in a Sitecore CDP segment.](https://doc.sitecore.com/api/markdown-image/cdp/en/users/sitecore-cdp/images/Segment_builder_select_value.png)

8. To add another rule to the same filter group, click **Add rule**, complete the additional fields that display, and click ![Add_rule.png](https://doc.sitecore.com/api/markdown-image/cdp/en/users/sitecore-cdp/images/Add_rule.png) to enable the rule operator drop-down list.

    > [!note]
    > It's best practice to [calculate the audience size](https://doc.sitecore.com/cdp/en/users/sitecore-cdp/introduction-to-batch-segmentation/create-and-add-rules-to-a-segment-in-sitecore-cdp/calculate-segment-audience-size-in-sitecore-cdp.html "Calculate segment audience size in Sitecore CDP") when you build your rule.

9. In the rule operator drop-down list, click the rule operator you want to use to join the two rules:
    - **And** - combines conditions in the same filter group. Guests must have all the conditions in the preceding and subsequent rules to be included in the segment.
    - **Or** - guests can have either of the conditions in the preceding or subsequent rules to be included in the segment.

        > [!note]
        > If you are familiar with SQL and the Sitecore CDP data model, you can click **Advanced Mode** to [write SQL queries](https://doc.sitecore.com/cdp/en/users/sitecore-cdp/introduction-to-batch-segmentation/write-an-sql-query-in-sitecore-cdp.html "Write an SQL query in Sitecore CDP") to create a segment.

    You can add segment rules from different filter groups or [schedule the segment](https://doc.sitecore.com/cdp/en/users/sitecore-cdp/introduction-to-batch-segmentation/managing-segment-status-in-sitecore-cdp/schedule-a-segment-in-sitecore-cdp.html "Schedule a segment in Sitecore CDP") to be included in your organization's nightly segment build.

## Add a segment rule from a different filter group

To add a rule from a different filter group:

1. In the segment builder, in **Segment rules**, click **Add Filter Group** and repeat steps 5-7 from the previous procedure.
2. In the **Combine with next group** drop-down list, click one of the following group operators:
    - **And** - combines conditions between filter groups. Guests must have all the conditions in the preceding and subsequent filter groups to be included in the segment.
    - **Or** - guests can have either of the conditions in the preceding or subsequent filter groups to be included in the segment.
    - **Not** - excludes guests from the segment that have the condition in the subsequent filter group.

You can continue to add rules to the current group, or add new filter groups, as required. Sitecore CDP automatically saves the segment each time you click ![Add_rule.png](https://doc.sitecore.com/api/markdown-image/cdp/en/users/sitecore-cdp/images/Add_rule.png).