Build Segments
Quick Start
To build a segment:
- Clarify what user group the user wants to isolate
- Select events/metrics and aggregation to compare across segments
- Identify breakdown dimensions and filters from
get_catalog semantic details, list_events, and list_user_traits
- Render the segmentation insight with
render_insight to validate
- Save with
create_insight, or create a discovery when the finding should enter the review/notification workflow
When to Use This Skill
- User asks to define a cohort or audience
- Comparing user groups (e.g., free vs paid, active vs churned)
- Comparing event behavior across properties (e.g., feature usage by plan, region, device)
- Filtering a population for deeper analysis
- Building a segment as input for a funnel, retention, or other insight
Core Workflow
Step 1: Understand the Objective
Ask the user (or infer from context) what group they want to isolate:
- Who are my most valuable users?
- Which users are at risk of churning?
- Who should receive this campaign?
Step 2: Identify Available Dimensions
Use the Altertable MCP server to discover which dimensions and traits are available for filtering:
get_catalog for semantic dimensions, measures, and table columns
list_events for event names and event statistics
list_user_traits for user attributes that can drive segmentation
Match the user's criteria to actual dimension or trait names.
Step 3: Build the Segment Definition
A segmentation setup typically includes:
segment:
name: segment-name
description: Human-readable description
event_definitions:
- event: "event_name"
aggregation_mode: Count
primary_dimension_ref:
source: source-slug
name: dimension-name
breakdowns:
- source: source-slug
name: plan_type
filters:
- dimension: dimension-name
operator: Eq
value: "value"
All filters use AND logic -- every condition must be true.
Step 4: Preview and Validate
Render the segmentation insight via render_insight to check:
- Is the segment size reasonable? (not zero, not everyone)
- Do the results match the user's expectation?
- Are edge cases handled (NULLs, test accounts)?
If the preview looks wrong, adjust filters and preview again.
Step 5: Create the Insight
Once validated:
- Use
create_insight with kind: segmentation to save the segment as a chart
- Use
create_discovery when the validated finding should flow through the review and notification workflow
Filter Operators
| Category |
Operators |
Use for |
| Equality |
Eq, Ne |
Exact match or exclusion |
| Comparison |
Gt, Gte, Lt, Lte |
Numeric ranges, date ranges |
| String |
StartsWith, EndsWith, Contains (and Not variants) |
Partial text matching |
| List |
In, NotIn |
Multiple discrete values |
| Null |
IsNull, IsNotNull |
Checking for missing data |
| IP |
IpMatches, IpNotMatches |
CIDR range filtering |
See Filter operators reference for detailed behavior, type rules, and examples per operator.
Common Pitfalls
- Not previewing before creating -- always preview to catch filter mistakes before saving
- Using wrong operator for the type -- e.g.,
Contains on a numeric dimension, or Gt on a string
- Forgetting NULL handling -- equality operators don't match NULL; use
IsNull/IsNotNull explicitly
- Overly broad segments -- if the segment includes most users, the filters are likely too loose
- Missing exclusion criteria -- always consider whether test accounts, internal users, or bots should be excluded
- Not checking dimension names -- inspect semantic model details and traits to confirm exact names before building filters
Reference Files
- Filter operators - Read for detailed operator behavior, type rules, NULL semantics, and combining patterns
- Dimension references - Read for dimension types, source-qualified references, JSON paths, and join behavior
- Cohort patterns - Read for ready-made segment definitions (lifecycle, value, subscription, behavioral, risk cohorts)
1---2name: build-segments3description: Compares event metrics across cohorts using filters, breakdowns, and dimensions. Use to define an audience or compare groups such as free versus paid. Returns a segmentation insight.4---56# Build Segments78## Quick Start910To build a segment:111. Clarify what user group the user wants to isolate122. Select events/metrics and aggregation to compare across segments133. Identify breakdown dimensions and filters from `get_catalog` semantic details, `list_events`, and `list_user_traits`144. Render the segmentation insight with `render_insight` to validate155. Save with `create_insight`, or create a discovery when the finding should enter the review/notification workflow1617## When to Use This Skill1819- User asks to define a cohort or audience20- Comparing user groups (e.g., free vs paid, active vs churned)21- Comparing event behavior across properties (e.g., feature usage by plan, region, device)22- Filtering a population for deeper analysis23- Building a segment as input for a funnel, retention, or other insight2425## Core Workflow2627### Step 1: Understand the Objective2829Ask the user (or infer from context) what group they want to isolate:30- Who are my most valuable users?31- Which users are at risk of churning?32- Who should receive this campaign?3334### Step 2: Identify Available Dimensions3536Use the Altertable MCP server to discover which dimensions and traits are available for filtering:3738- `get_catalog` for semantic dimensions, measures, and table columns39- `list_events` for event names and event statistics40- `list_user_traits` for user attributes that can drive segmentation4142Match the user's criteria to actual dimension or trait names.4344### Step 3: Build the Segment Definition4546A segmentation setup typically includes:4748```yaml49segment:50 name: segment-name51 description: Human-readable description52 event_definitions:53 - event: "event_name"54 aggregation_mode: Count55 primary_dimension_ref:56 source: source-slug57 name: dimension-name58 breakdowns:59 - source: source-slug60 name: plan_type61 filters:62 - dimension: dimension-name63 operator: Eq64 value: "value"65```6667All filters use AND logic -- every condition must be true.6869### Step 4: Preview and Validate7071Render the segmentation insight via `render_insight` to check:72- Is the segment size reasonable? (not zero, not everyone)73- Do the results match the user's expectation?74- Are edge cases handled (NULLs, test accounts)?7576If the preview looks wrong, adjust filters and preview again.7778### Step 5: Create the Insight7980Once validated:81- Use `create_insight` with `kind: segmentation` to save the segment as a chart82- Use `create_discovery` when the validated finding should flow through the review and notification workflow8384## Filter Operators8586| Category | Operators | Use for |87|----------|-----------|---------|88| Equality | `Eq`, `Ne` | Exact match or exclusion |89| Comparison | `Gt`, `Gte`, `Lt`, `Lte` | Numeric ranges, date ranges |90| String | `StartsWith`, `EndsWith`, `Contains` (and `Not` variants) | Partial text matching |91| List | `In`, `NotIn` | Multiple discrete values |92| Null | `IsNull`, `IsNotNull` | Checking for missing data |93| IP | `IpMatches`, `IpNotMatches` | CIDR range filtering |9495See [Filter operators reference](references/filter-operators.md) for detailed behavior, type rules, and examples per operator.9697## Common Pitfalls9899- **Not previewing before creating** -- always preview to catch filter mistakes before saving100- **Using wrong operator for the type** -- e.g., `Contains` on a numeric dimension, or `Gt` on a string101- **Forgetting NULL handling** -- equality operators don't match NULL; use `IsNull`/`IsNotNull` explicitly102- **Overly broad segments** -- if the segment includes most users, the filters are likely too loose103- **Missing exclusion criteria** -- always consider whether test accounts, internal users, or bots should be excluded104- **Not checking dimension names** -- inspect semantic model details and traits to confirm exact names before building filters105106## Reference Files107108- [Filter operators](references/filter-operators.md) - Read for detailed operator behavior, type rules, NULL semantics, and combining patterns109- [Dimension references](references/dimension-refs.md) - Read for dimension types, source-qualified references, JSON paths, and join behavior110- [Cohort patterns](references/cohort-patterns.md) - Read for ready-made segment definitions (lifecycle, value, subscription, behavioral, risk cohorts)