---
title: "Setting up automatic group membership"
slug: "configure-automatic-group-membership"
description: "Add users to a Group automatically with a query on profile fields such as job title, department, or location. Includes syntax, examples, and fixes."
updated: 2026-04-30T20:30:59.000Z
canonical: "https://help.opensense.com/docs/configure-automatic-group-membership"
---

> ## Documentation Index
> Fetch the complete documentation index at: https://help.opensense.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Setting up automatic group membership

## Overview

Dynamic membership adds users to a Group automatically, based on their profile fields, such as job title, department, or location. Instead of adding users by hand, you write a query, and the query keeps the group's membership up to date.

:::note[Before you start]
- You need admin access to your Opensense account.
- You need the exact field values stored in your user profiles, for example the exact job title strings.
:::


## Setting up a dynamic group

1. In the navigation pane, select **Manage** > **Groups**.
2. Open the Group that you want to configure, or create one.
3. Under **Membership**, select the **Dynamic** tab to open the query editor.
4. In the **Query** field, enter your query: `fields.fieldname`, followed by an operator and a value in single quotes. The most common field is `fields.title` (job title), but you can use any user profile field. See [Query syntax](#query-syntax-reference) and [Examples](#examples).
5. Save the query.

The matching users appear on the **Dynamic** tab of the Group. The Group can take a moment to refresh.


## Query syntax

Refer to a field with dot notation: `fields.fieldname`. Replace `fieldname` with the field key from the user profile, for example `fields.title`, `fields.department`, or `fields.location`.

### Comparison operators

| Operator | Meaning | Example |
| --- | --- | --- |
| `==` | The field value matches exactly. | `fields.title == 'Account Executive'` |
| `contains` | The field value contains the quoted text. | `fields.title contains 'Sales'` |
| `!=` | The field value does not equal the quoted text. | `fields.department != 'Engineering'` |

### Logic operators

| Operator | Meaning | Example |
| --- | --- | --- |
| `and` | Both conditions must be true. | `fields.department == 'Sales' and fields.location == 'New York'` |
| `or` | Either condition can be true. Use it to match several values. | `fields.title == 'Account Executive' or fields.title == 'Sales Rep'` |

:::tip[Exact match or contains?]
Use `==` when you know the exact field value. Use `contains` when users have slightly different titles that share a common term. For example, `fields.title contains 'Sales Rep'` matches both "Senior Sales Rep" and "Sales Rep".
:::

## Examples

### Match a single job title

Add all users whose title is exactly "Account Executive":

```text
fields.title == 'Account Executive'
```

### Match several job titles

Add users with any of several titles by chaining conditions with `or`:

```text wrap
fields.title == 'Account Executive' or fields.title == 'Sales Rep' or fields.title == 'Regional Sales Manager'
```

### Match by department and location

Add users who are in the Sales department and located in Chicago:

```text
fields.department == 'Sales' and fields.location == 'Chicago'
```

### Exclude a group of users

Add all users except those in the Engineering department:

```text
fields.department != 'Engineering'
```

## Troubleshooting

<div class="kb-faq">
  <details id="no-users-are-being-added-despite-a-validlooking-query">
    <summary><span class="kb-faq__question">No users are added, although the query looks valid</span></summary>
    <div class="kb-faq__answer">
      <p>Field values in a query must match the values stored in user profiles exactly, including capitalization. A query that uses <code>==</code> is case-sensitive.</p>
      <ol>
        <li>Open a user profile that should match your query, and note the exact field value.</li>
        <li>Change your query to match that value exactly, or change <code>==</code> to <code>contains</code> to allow for differences in capitalization.</li>
        <li>Save the query, and give the Group a moment to refresh.</li>
      </ol>
      <p>When it is fixed, the matching users appear on the <strong>Dynamic</strong> tab of the Group.</p>
    </div>
  </details>
  <details id="more-users-are-being-added-than-expected">
    <summary><span class="kb-faq__question">More users are added than expected</span></summary>
    <div class="kb-faq__answer">
      <p>A broad <code>contains</code> value matches every field value that includes that text. For example, <code>contains 'Manager'</code> matches "Account Manager", "Marketing Manager", and every other title with that word.</p>
      <ol>
        <li>Find the <code>contains</code> conditions in your query that are too broad.</li>
        <li>Change <code>contains</code> to <code>==</code> for each condition that should match an exact title.</li>
        <li>Save the query, and check the <strong>Users</strong> tab to confirm that the membership is correct.</li>
      </ol>
      <p>When it is fixed, the matching users appear on the <strong>Dynamic</strong> tab of the Group.</p>
    </div>
  </details>
  <details id="the-query-field-shows-an-error-or-does-not-save">
    <summary><span class="kb-faq__question">The query field shows an error, or the query does not save</span></summary>
    <div class="kb-faq__answer">
      <p>A syntax error stops the query from saving. The most common causes are missing single quotes, uppercase operators, and stray characters.</p>
      <ol>
        <li>Make sure that every text value is in single quotes, for example <code>'Account Executive'</code>.</li>
        <li>Make sure that every operator is lowercase: <code>and</code>, <code>or</code>, <code>contains</code>.</li>
        <li>Remove line breaks, extra spaces, and special characters from the query.</li>
        <li>Enter the query again, and save it.</li>
      </ol>
      <p>When it is fixed, the query saves without an error, and the <strong>Dynamic</strong> tab shows the matching members.</p>
    </div>
  </details>
</div>

:::note[Still having issues?]
Contact [Opensense Support](mailto:help@opensense.com). Include:

- The full query that you entered
- A screenshot of any error message
- An example of a user who should match but does not, or who matches but should not
:::

## What's next

- [Setting up group targets for campaigns](https://help.opensense.com/docs/initial-setup): show different banners to each Group.
- [Assigning business cards in Routing](https://help.opensense.com/docs/routing-2): give each Group its own business card.
