Audience features
An audience feature is a pre-created OTQL query fragment. Your users can leverage the audience features you create to run complex queries without OTQL knowledge. Each audience feature will turn into a user-friendly selector in the UI.
Audience features you create are available in the navigator, in Audience > Builders > Standard.
Let's take the following query as an example:
1
SELECT @count{} FROM UserPoint WHERE
2
events {
3
nature = "$transaction_confirmed" and
4
date >= $date
5
and products {brand in $brand and name in $name}
6
}
Copied!
It is technically an OTQL query based on your schema in which you registered parameters. In this case, it represents a business feature that may be used regularly by your users: selecting user points that perform a transaction in a particular date range and for specific products.
Users will see this selector in the builder instead of an OTQL query.
This audience feature will automatically be combined with other audience features, which the user can select to create segments.

The process

Users will have access to the standard segment builder if at least one audience feature is set up. But you need multiple ones to create value for users.
Good knowledge of the schema and the queries that are usually created in your datamart is important for the success of this feature.
Here is a sample process to follow to enable audience features and create value for your users:
  1. 1.
    Know your schema. What is it optimized for? Which queries are regularly created? What are your actual segments and what are their queries? You should be able to create a list of useful audience features with these pieces of information.
  2. 2.
    Set up audience features, in the UI and/or by script.
  3. 3.
    Monitor usage and update audience features regularly!

Folders

You can store audience features in folders. Any audience feature without a folder will be assigned to the root folder. Here are some examples.
get
https://api.mediarithmics.com
/v1/datamarts/{datamart_id}/audience_feature_folders
List folders
get
https://api.mediarithmics.com
/v1/datamarts/{datamart_id}/audience_feature_folders/{audience_feature_folders_id}
List one folder
post
https://api.mediarithmics.com
/v1/datamarts/{datamart_id}/audience_feature_folders
Create a folder
1
// Create a folder payload
2
{
3
"children_ids": [
4
"string"
5
],
6
"audience_features_ids": [
7
"string"
8
],
9
"parent_id": "string",
10
"datamart_id": "string",
11
"name": "string"
12
}
Copied!
put
https://api.mediarithmics.com
/v1/datamarts/{datamart_id}/audience_feature_folders/{audience_feature_folders}
Edit a folder
1
// Editing a folder payload
2
{
3
"children_ids": [
4
"string"
5
],
6
"audience_features_ids": [
7
"string"
8
],
9
"parent_id": "string",
10
"datamart_id": "string",
11
"name": "string"
12
}
Copied!

Audience features

get
https://api.mediarithmics.com
/v1/datamarts/{datamart_id}/audience_features
List audience features
get
https://api.mediarithmics.com
/v1/datamarts/{datamart_id}/audience_features/{audience_feature_id}
Get an audience feature
post
https://api.mediarithmics.com
/v1/datamarts/{datamart_id}/audience_features
Create an audience feature
1
// Creating an audience feature payload
2
{
3
"object_tree_expression": "string",
4
"description": "string",
5
"datamart_id": "string",
6
"addressable_object": "string",
7
"name": "string",
8
"folder_id": "string"
9
}
Copied!
put
https://api.mediarithmics.com
/v1/datamarts/{datamart_id}/audience_features/{audience_feature_id}
Edit an audience feature
1
// Editing an audience feature payload
2
{
3
"object_tree_expression": "string",
4
"description": "string",
5
"datamart_id": "string",
6
"addressable_object": "string",
7
"name": "string",
8
"folder_id": "string"
9
}
Copied!

OTQL query rules

Parameters

Create query parameters using the $parameter_namesyntax. Example:
1
// The gender will be selectable by the user
2
SELECT @count{} FROM UserPoint
3
where profiles {gender in $gender}
4
5
// The date will be selectable by the user,
6
// but the nature will always be $transaction_confirmed
7
SELECT @count{} FROM UserPoint
8
where events { nature = "$transaction_confirmed" and date >= $date }
9
Copied!
The field in the audience feature will have the name you enter after the $ . Spaces in field name are not authorized. The type of selector in the audience feature is automatically chosen based on the field type
If you want to be able to select several values in a field, use keyword in instead of the classic ==.
1
// User will only be able to select one gender
2
SELECT @count{} FROM UserPoint
3
where profiles {gender == $gender}
4
5
// User will be able to select multiple gender values
6
SELECT @count{} FROM UserPoint
7
where profiles {gender in $gender}
Copied!
You can create parameters for frequency requests with the @ScoreSum directive:
1
// User will be able to select the minimum number of transactions
2
SELECT @count{} FROM UserPoint
3
WHERE events@ScoreSum(min: $frequency) {
4
purchase in $user_purchase
5
}
Copied!