Segment
Requires access scope. Also: The user must not have restricted access.
A group of customers that meet specific criteria defined through ShopifyQL query conditions. Common use cases for segments include customer analytics, targeted marketing campaigns, and automated discount eligibility.
The segment's query field contains ShopifyQL conditions that determine membership, such as purchase history, location, or engagement patterns. Tracks when the segment was created with and when it was last modified with .
Anchor to FieldsFields
- Anchor to creationDatecreation•Date
Date Time! non-null The date and time when the segment was added to the store.
- •ID!non-null
A globally-unique ID.
- Anchor to lastEditDatelast•Date
Edit Date Time! non-null The date and time when the segment was last updated.
- Anchor to namename•String!non-null
The name of the segment.
- Anchor to queryquery•String!non-null
A precise definition of the segment. The definition is composed of a combination of conditions on facts about customers.
Anchor to QueriesQueries
- •query
Retrieves a customer
Segmentby ID. Segments are dynamic groups of customers that meet specific criteria defined through ShopifyQL queries.Use segments for targeted marketing campaigns, analyzing customer behavior, or creating personalized experiences. Each segment includes its name, creation date, and the query that defines which
Customerobjects belong to it.- •ID!required
Find a segment by ID.
Arguments
- •ID!
- •query
Returns a paginated list of
Segmentobjects for the shop. Segments are dynamic groups of customers that meet specific criteria defined through ShopifyQL queries. You can filter segments by search query and sort them by creation date or other criteria.The query supports standard pagination arguments and returns a
containing segment details including names, creation dates, and the query definitions that determine segment membership.- Anchor to firstfirst•Int
The first
nelements from the paginated list.- Anchor to afterafter•String
The elements that come after the specified cursor.
- Anchor to lastlast•Int
The last
nelements from the paginated list.- Anchor to beforebefore•String
The elements that come before the specified cursor.
- Anchor to reversereverse•BooleanDefault:false
Reverse the order of the underlying list.
- Anchor to sortKeysort•Segment
Key Sort Keys Default:CREATION_DATE Sort the underlying list by the given key.
- Anchor to queryquery•String
A filter made up of terms, connectives, modifiers, and comparators. You can apply one or more filters to a query. Learn more about Shopify API search syntax.
Arguments
Anchor to MutationsMutations
- •mutation
Creates a segment.
- Anchor to namename•String!required
The name of the segment to be created. Segment names must be unique.
- Anchor to queryquery•String!required
A precise definition of the segment. The definition is composed of a combination of conditions on facts about customers such as
with this syntax.
Arguments
- •mutation
Updates a segment.
- •ID!required
Specifies the segment to be updated.
- Anchor to namename•String
The new name for the segment.
- Anchor to queryquery•String
A precise definition of the segment. The definition is composed of a combination of conditions on facts about customers such as
with this syntax.
Arguments
- •ID!