Cohorts

  • Updated

In Optimizely Analytics, a cohort is a specific group within a dataset, defined by a condition that determines which records are included. In the catalog, a cohort appears as a boolean property connected to the dataset. Only records with this property marked as True are considered part of the cohort.

For example, consider a Users dataset with one record per user and a Page views dataset with records of each user's page view events. You can use cohorts to select users with 10 or more page views in the last week.

A cohort can involve complex computations if the outcome applies to each record in the target dataset, such as joins with other datasets, filters, and aggregations.

You can use a cohort wherever the catalog is available or in the segments section of any exploration template. It functions like any other dataset column, and its configuration is stored in analytics and accessed through the catalog.

A cohort has the following configuration:

  • Dataset – Associate your cohort with one dataset when defining the cohort. Your cohort displays in the catalog just like any other column of that dataset and can be used in any analysis with access to the catalog. You cannot move a cohort from one dataset to another.
  • Name – Ensure the name of your cohort is unique across all columns for that dataset.
  • Definition – Specify the computation for your cohort using the Block Editor.

Create a cohort

Create a saved cohort

  1. Click + and select Cohort.
  2. Select one of the following template options:
      • Behavioral – Determine a cohort of actors based on their attributes or behaviors.
      • Formula – Calculate a cohort of values based on arithmetic and logical operators.
      • Conditional on property – Create a cohort using and/or logic based on dataset properties.
      • Custom – Calculate a cohort of values by composing several blocks.
      • Conditional on Aggregate – Calculate an aggregated quantity per actor to decide inclusion in the cohort.
      • Conditional on intervals engaged – Calculate how many distinct time intervals each actor engaged in some behavior.
  3. (Optional) Click Unnamed Cohort, and enter a name and description.
  4. Select a dataset in the Cohort of field.
  5. Define the computation for your cohort in the block editor.
  6. Click Run to preview the computed values.
  7. Click Save.

You can now use the cohort anywhere, such as inside exploration templates, block editor, and so on. You can also access it in any Exploration templates under the Segment by Cohort section.

Create cohort

Define an inline cohort

  1. Go to the Segment by Cohort section inside an Exploration template. Learn more about Explorations.
  2. Select + > New cohort.
  3. Set the condition for your cohort and click Apply.
  4. (Optional) Define additional blocks to complete the definition.
  5. Click Run to view segmented results.
Create inline cohort

Audience

An audience is a cohort that is published to the warehouse. There are two types of audiences:

  1. Table – Publishes the current snapshot of audience members as a physical table.
  2. View – Publishes audience definition as a logical view with audience members live.

Publish cohorts to the warehouse

  1. Create a cohort or choose an existing one.
  2. Click More (⋮) > Publish Audience.
  3. Enter the following details:
      • Audience Name – Enter the name of the cohort published in the warehouse.
      • Audience Description – Describe the cohort published in the warehouse.
      • Type – Select whether the cohort is saved as a View or Table in the warehouse depending on the Table or View option.
      • Sync – Configure the cron job that updates the table periodically. The audience membership can be refreshed periodically when published as a table or a view.
  4. Click Save. You can see published audiences under the Audiences tab inside the Cohorts section.

After saving, you have options like Run now and Resume sync.

audience

Inside the Audiences section, click More (⋮) corresponding to each published cohort. The following options are displayed:

  • Edit – Update the schedule for previously scheduled audience updates (relevant only for tables and not for views).
  • Refresh – Re-populate the audience based on the updated definition of the cohort or data (relevant only for tables and not for views).
  • Delete – Delete the table or view in the data warehouse.
audience menu
Remember to configure details about your warehouse database and schema where the data needs to be published. Learn more about Application settings.

Types of cohorts

Analytics offers a range of cohort templates that let you get started. Choosing a template is the first step in creating a cohort. You can change this at any time without losing any work.

Behavioral

The Behavioral template lets you create a cohort of actors based on their attributes or behavior. This template's advantage is that you can create cohorts tailored to user behavior specific to your business rather than general user behavior.

  1. Go to + > Cohorts > Behavioral.
  2. Select a dataset in the Cohort of field. For example, choose the Users dataset.
  3. (Optional) Click Unnamed Cohort, and enter a name and description.
  4. Set the condition in the Blocks section. Choose did from the drop-down list and select the event, such as Make Purchase from Product Events, then click Apply.
  5. Set the time range. For example, choose Within 7 days after timestamp and select the Sign Up Date derived column.
  6. Add an aggregate filter and set the count to >= 1.
  7. Click Apply and select Run.
  8. Click Save.
Behavioral

Formula

The formula template in Analytics lets you create a cohort of values based on arithmetic and logical operators. For example, you can create a cohort of users using the dot com domain.

  1. Go to + > Cohorts > Formula.
  2. Select a dataset in the Cohort of field. For example, choose the Users dataset.
  3. (Optional) Click Unnamed Cohort, and enter a name and description.
  4.  Enter the formula in the Blocks section:
     regexp_substr(Data.Users.id, '[^\ .] $') == 'com'
  5. Click Run.
  6. Click Save.
Formula

Conditional on property

This template lets you create a cohort using and/or logic based on dataset properties. As an example, you can create a cohort of Active users.

  1. Go to + > Cohorts > Conditional on property.
  2. Select a dataset in the Cohort of field. For example, choose the Users dataset.
  3. (Optional) Click Unnamed Cohort, and enter a name and description.
  4. Choose the Purchased in Last 30 Days cohort in the And/Or block and set the value to True.
  5. Choose the Viewed Similar Content - L30D cohort and set the value to True.
  6. Click + > Add a Condition, choose the Total Time Viewed metric, and set the value to 500.
  7. Click Run.
  8. Click Save.
Conditional on property

Custom

The custom template lets you calculate a cohort of values by composing several blocks. For example, you can create a cohort for Regular Subscriptions. A regular subscription is one for which at least half its users are regular watchers. A regular watcher is a user who has played content on at least five distinct days in the last 30 days.

  1. Go to + > Cohorts > Custom.
  2. Select a dataset in the Cohort of field. For example, choose the Subscriptions dataset.
  3. (Optional) Click Unnamed Cohort, and enter a name and description.
  4. Add a new Aggregate block in the Blocks section. Set the aggregator to count and choose the Users dataset. You can call this the Overall Users block.
  5. Add another Aggregate block to calculate the number of Regular Users.
  6. Set the aggregator to count and choose the Users dataset.
  7. Add a filter where Regular Watchers is True. This creates the Regular Watchers cohort. See how the Regular Watchers cohort is created.
  8. Add a Formula block to calculate regular subscriptions. Enter the following formula: 
    "Regular Users" / "Overall Users" >= 0.5.
  9. Click Run.
  10. Click Save.
Custom

Conditional on aggregate

This template lets you calculate an aggregated quantity per actor to decide on inclusion in the cohort. For example, you can create a cohort of Heavily Marketed Users in the USA.

  1. Go to + > Cohorts > Conditional on Aggregate.
  2. Select a dataset in the Cohort of field. For example, choose the Users dataset.
  3. (Optional) Click Unnamed Cohort, and enter a name and description.
  4. Set the condition in the And/Or section as follows: country in USA, CAN, AUS. Name this block Heavily Marketed Users.
  5. Go to the Aggregate block. Choose the count aggregator and select Heavily Marketed Users as the value.
  6. Click Run.
  7. Click Save.
Conditional on Aggregate

Conditional on intervals engaged

This template lets you calculate the number of distinct time intervals each actor engaged in some behavior. As an example, create a cohort of Regular Watchers. Here, a regular watcher is a user who has played content on at least five distinct days in the last 30 days.

  1. Go to + > Cohorts > Conditional on intervals engaged.
  2. Select a dataset in the Cohort of field. For example, choose the Users dataset.
  3. (Optional) Click Unnamed Cohort, and enter a name and description.
  4. Choose count of distinct days from the drop-down list and select the Users dataset in the Intervals Engaged block.
  5. Set the condition as did Play Content. Add a filter with the following configuration: where event time in Last 30 days at least 1 time and at most unbounded time. You can call this the Days Played block.
  6. Add an And/Or and set the condition to Days Played >= 5.
  7. Click Run.
  8. Click Save.
Conditional on intervals engaged

View cohorts

Cohorts section

  1. Click the Home icon.
  2. Select the Cohorts checkbox. The resulting page displays a set of templates at the top for defining cohorts.
  3. Use the search bar to find individual cohorts by name.

You can find a paginated listing of cohorts in the system, pooled across the datasets.

Each cohort entry contains the following information:

    • Name (with Description, if any)
    • Created By
    • Updated By
    • Updated At
    • Type (refers to the template used when defining the cohort)
View cohort

Dataset page

Alternatively, click Cohorts inside the dataset page to access the cohorts for a given dataset.