> For the complete documentation index, see [llms.txt](https://docs.mediarithmics.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.mediarithmics.io/audience-and-activation/build-your-audiences/segment-reference/segment-builders/advanced-segment-builder.md).

# Advanced Segment Builder

Build OTQL queries visually from your schema, with AND / OR groups and no query language to write.

## What it is

The Advanced Segment Builder is a graphical interface for exploring your data and producing OTQL queries from your schema. It needs no setup, but it does assume you know your schema, which makes it the natural tool for a data-literate user building ad hoc segments.

Reach it from the side menu: **Audience > Builders > Advanced segment builder**.

## Reading the criteria panel

Every criterion in the panel on the right is an attribute of a user. Criteria are grouped into objects, and you pick from those objects to assemble an audience - "Users that visited my site in the last 30 days and bought a mobile phone".

There are seven standard objects. Depending on your use case you may need all of them or only a few.

<table data-search="false"><thead><tr><th width="150">Object</th><th>What you find in it</th></tr></thead><tbody><tr><td><strong>Accounts</strong></td><td>Information about the CRM id.</td></tr><tr><td><strong>Activities</strong></td><td>One activity corresponds to several events.</td></tr><tr><td><strong>Agents</strong></td><td>Devices.</td></tr><tr><td><strong>Emails</strong></td><td>Information about the email identifier.</td></tr><tr><td><strong>Events</strong></td><td>A custom object built at the start of your project, and liable to evolve with your needs. Holds every action taken on your site, app, newsletter, offsite, and so on. Depending on your integration, you can tell sites and apps apart with the <code>channel_id</code> attribute.</td></tr><tr><td><strong>Profiles</strong></td><td>A custom object built at the start of your project. Holds CRM data. Depending on your integration, you can tell sites and apps apart with the <code>compartment_id</code> attribute.</td></tr><tr><td><strong>Segments</strong></td><td>Segment names - how many users a segment holds, how to cross a segment with other attributes, and how one segment overlaps another.</td></tr></tbody></table>

## Objects, frequency, field conditions

Start a segment by adding an **Object** or a **Group**.

An object is one audience criterion, directly linked to your schema. On it you can add:

* **A frequency.** Tick the check box and enter the minimum number of occurrences.
* **Field conditions.** Click **Add a Field Condition** to narrow the object further.

{% hint style="info" %}
The frequency check box is how you express "at least three times": an `Activities` object with a minimum frequency of 3 selects users who visited the website at least three times.
{% endhint %}

When the object's conditions are right, click **Update** to apply them and see the resulting query. Click the **Refresh** symbol over the user count to check the volume in real time.

{% hint style="warning" %}
`Update` applies the change to the query. It does not save the segment - see [Creating the segment](#creating-the-segment).
{% endhint %}

### Pasting many values at once

You can paste multiple values into a segment filter instead of adding them one at a time. Supported separators are a **comma** - except inside double quotes - and a **line break**.

| Input                                                                                                          | Result                                               |
| -------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------- |
| `element1, element2, element3`                                                                                 | 3 separate entries                                   |
| <p><code>element1</code><br><code>element2</code><br><code>element3</code></p>                                 | 3 separate entries                                   |
| `element1, "data, with, commas", element3`                                                                     | 3 separate entries - the quoted content stays intact |
| <p><code>element1, element2</code><br><code>element3, "data, with, commas"</code><br><code>element5</code></p> | 5 separate entries                                   |

### Filtering the schema

A filter box at the top of the schema panel narrows the list of fields. The better you know your schema, the more useful it is.

### Drag and drop

Once you are comfortable, you can drag any object or property from the criteria panel straight into the query to add a filter on it.

## Groups

Click **+** and then **Group** to add group conditions. Groups let you include, exclude, and manage `and` / `or` relationships between blocks of audience - and let you combine several standard objects in one condition, for example `Profiles` AND `Events`.

## Creating the segment

Click **Save as**, name the audience, and save it. You can optionally fill in the [advanced fields](/audience-and-activation/build-your-audiences/segment-reference.md#advanced-fields): technical name, default lifetime, persisted, paused.

The new segment is immediately available in **Audience > Segments**.

## Where else this interface appears

The **If** node of an automation uses this same interface to evaluate its condition, which is why the automations documentation points here rather than re-explaining it. See [Flow control](/audience-and-activation/automate/automations-reference/flow-control.md).

## Related pages

<table data-view="cards" data-search="false"><thead><tr><th></th><th></th><th data-hidden data-card-target data-type="content-ref"></th></tr></thead><tbody><tr><td><strong>Use contextual targeting in segments</strong></td><td>A worked segment built in this builder, on contextual criteria.</td><td><a href="/audience-and-activation/target-contextually/use-contextual-targeting-in-segments.md">Use contextual targeting in segments</a></td></tr><tr><td><strong>Segment builders</strong></td><td>The other two tools.</td><td><a href="/audience-and-activation/build-your-audiences/segment-reference/segment-builders.md">Segment builders</a></td></tr></tbody></table>


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.mediarithmics.io/audience-and-activation/build-your-audiences/segment-reference/segment-builders/advanced-segment-builder.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
