> 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/standard-segment-builder/audience-features.md).

# Audience features

The parametric OTQL queries that turn schema knowledge into business selectors in the Standard Segment Builder.

## What one looks like

An **audience feature** is a pre-created, parametric OTQL query that appears in the interface as a user-friendly selector. It is built to match a business need, so the person building a segment picks "marital situation" and a date range rather than writing a query.

Take this query:

```sql
SELECT @count{} FROM UserPoint WHERE
events {
    nature = "$transaction_confirmed" and
    date >= $date
    and products {brand in $brand and name in $name}
    }
```

Technically it is an OTQL query against your schema, with parameters registered in it. Functionally it is a business feature your users will reach for regularly: *Users who made a transaction in a date range, for particular products*. In the builder they see three selectors - date, brand, name - and no OTQL at all.

By combining audience features, users create most of their segments in business terminology.

## Writing the query behind one

Parameters use the `$parameter_name` syntax. The field in the audience feature takes the name you write after the `$`, spaces are not allowed in it, and the type of selector is chosen automatically from the field's type.

```sql
// The gender will be selectable by the user
SELECT @count{} FROM UserPoint
where  profiles {gender in $gender}

// The date will be selectable by the user,
// but the nature will always be $transaction_confirmed
SELECT @count{} FROM UserPoint
where events { nature = "$transaction_confirmed" and date >= $date }
```

### One value or several

The operator decides whether the selector is single- or multi-valued. Use `in` rather than `==` to let the user pick more than one value.

```sql
// User will only be able to select one gender
SELECT @count{} FROM UserPoint
where  profiles {gender == $gender}

// User will be able to select multiple gender values
SELECT @count{} FROM UserPoint
where  profiles {gender in $gender}
```

### Frequency as a parameter

The `@ScoreSum` directive turns a frequency into a selector:

```sql
// User will be able to select the minimum number of transactions
SELECT @count{} FROM UserPoint
WHERE events@ScoreSum(min: $frequency) {
    purchase in $user_purchase
}
```

## Creating one

{% stepper %}
{% step %}

### Open the audience features panel

Go to **Settings** > **Datamart** > **Datamarts**, click the datamart, then **Audience Features** > **New Audience Feature**.
{% endstep %}

{% step %}

### Name and place it

Enter a name and a description, and select the folder to store it in. Without a folder, it goes to the root folder.
{% endstep %}

{% step %}

### Write the query

Click **Edit Query**, enter your OTQL query in the query tool, and click **Update** to save it. A preview of the audience feature appears on the right.

Click **Run query** if you want to check the result - it will not work while parametric fields are present.
{% endstep %}

{% step %}

### Save

Click **Save**. The feature appears in the audience features list, and in **Audience** > **Builders** > **Standard**.
{% endstep %}
{% endstepper %}

## How many to create

You can create a maximum of 21,000 audience features. That ceiling is not a target.

| Stage          | Recommendation                                               |
| -------------- | ------------------------------------------------------------ |
| To begin       | About 20 features, representing your main business concepts. |
| With more time | More, but keep the total around 100.                         |

{% hint style="info" %}
To decide which features to create, brainstorm the characteristics of your users that you collect and most often segment on. Common examples: demographics (age, gender, location), and activity (interest, intent, purchase - on a product or a page, over a period, with a frequency).
{% endhint %}

A user gets access to the Standard Segment Builder as soon as one audience feature exists, but one feature creates no value. Good knowledge of the schema, and of the queries your datamart actually gets asked, is what makes the feature set useful. A workable process:

1. Know your schema. What is it optimised for? Which queries are created regularly? What are your current segments, and what are their queries?
2. Set up audience features, in the interface or by script.
3. Monitor usage, and update the features regularly.

## Folders

Audience features can be stored in folders. Create one from **Settings** > **Datamart** > **Datamarts**, click the datamart, then **Audience Features** > **Add folder**. Any feature without a folder is assigned to the root folder.

## Edition and deletion protection

The platform deliberately makes it hard to break segments that depend on a feature.

<table data-search="false"><thead><tr><th width="240">Action</th><th>Allowed?</th></tr></thead><tbody><tr><td>Updating a feature's <strong>query</strong></td><td><strong>Allowed but not recommended.</strong> It affects every segment using the feature. Prefer creating a new feature - the popup offers a link to do so.</td></tr><tr><td><strong>Deleting</strong> a feature</td><td><strong>Not allowed</strong> while it is used. Remove the feature from the segments first.</td></tr><tr><td><strong>Deleting a folder</strong> that contains features</td><td><strong>Not allowed.</strong> Delete every feature inside it first.</td></tr></tbody></table>

## 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>Standard Segment Builder</strong></td><td>Where audience features are consumed.</td><td><a href="/audience-and-activation/build-your-audiences/segment-reference/segment-builders/standard-segment-builder.md">Standard Segment Builder</a></td></tr><tr><td><strong>Use contextual targeting in segments</strong></td><td>Contextual criteria need extra configuration to reach this builder.</td><td><a href="/audience-and-activation/target-contextually/use-contextual-targeting-in-segments.md">Use contextual targeting in segments</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/standard-segment-builder/audience-features.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.
