Drupal is a registered trademark of Dries Buytaert
External Authentication Module externalauth crossed 100,000 active installs. Leaflet MapBox 2.0.2 Minor update available for module leaflet_mapbox (2.0.2). Module Builder 4.2.4 Minor update available for module module_builder (4.2.4). HTTP Anti-virus 1.1.5 Minor update available for module httpav (1.1.5). HTTP Anti-virus 1.3.3 Minor update available for module httpav (1.3.3). Commerce Make-to-Order 1.0.1 Minor update available for module commerce_make_to_order (1.0.1). Burndown 1.0.72 Minor update available for module burndown (1.0.72). GEO Starter JSON-LD 1.2.0 Minor update available for module geo_starter_jsonld (1.2.0). ePub Generator 1.0.0 Initial release available for module epub_generator (1.0.0)! Simple Google Maps 4.0.1 Module simple_gmap updated after 17 months of inactivity (4.0.1).

Entity Segment lets you define named, reusable segments — saved audiences of any content entity type, described by a visual AND/OR tree of conditions. Describe an audience once, by its rules, and any module that needs it asks the resolver and gets the entities that match right now. If you have met CiviCRM's Smart Groups, Mailchimp's Segments, or Constant Contact's Segments, this is the same idea, generalized to the whole Drupal entity system.

What makes a segment generic is its target entity type. A segment does not select contacts, users, or nodes specifically — it selects entities of whatever content entity type its segment type (its bundle) names. The condition-building plugins, the resolver, and the IDs that come back are all parameterized by that target type, so one engine serves every audience.

This module was created as part of the Member Platform Initiative to facilitate tools for sending emails to Drupal CRM Contacts.

Features

  • Target any content entity type — users, nodes, taxonomy terms, commerce entities, your own custom entities. The target is set per segment type, so different segments can select different entity types.
  • Visual condition builder — nested AND/OR groups, arranged in the browser, each condition shown as a plain-language summary.
  • Type-aware field conditions — the shipped Field value plugin compares any field of the target entity, offering operators appropriate to the field's data type (string contains/starts with, numeric/date greater than/between, and so on).
  • Multi-hop reference traversal — descend through entity reference fields to compare fields on referenced entities, to any depth (for example an order's customer's country), built up one hop at a time in the UI.
  • Live resolution — a segment always reflects current data; there is no stale materialized list to rebuild.
  • Revisionable segments, with global / personal scope and granular per-segment-type permissions (nine per type, node-style).
  • Point-and-click segment types — define a segment type for any queryable content entity type at Structure → Segment types, no code required, or ship one as config.
  • Per-type fields — because the segment entity is bundleable, each segment type can carry its own fields (a description, a campaign reference, an external-audience id) via core's Field UI.

Defining a segment type

A segment type binds the generic segment entity to one target content entity type. Create one through the admin UI at /admin/structure/segment-type, or ship it as install config from your module:

langcode: en
status: true
dependencies:
  enforced:
    module:
      - your_module
id: event
label: 'Event'
target_entity_type_id: node

The target must be a queryable content entity type (one with base-table storage). Each segment type gets, for free, its own listing, an Add segment flow, and its own set of access permissions.

Exposing the audience safely

A segment's resolved membership is more sensitive than its definition, and the raw resolver is deliberately not access-filtered — so the engine offers two clearly separated ways to read an audience, funneled through a single access chokepoint (entity_segment.audience_access):

  • resolve() — the raw, live audience. Fast, unfiltered, the segment's definition.
  • resolveAccessible($segment, $account) — only the members that account may view. Safe to render or export to that user.
  • entity_segment.audience_access — the chokepoint: filtered() is viewer-safe; raw() returns the unfiltered audience only to accounts holding the per-type membership permission view resolved <type> segment membership.

Security: every "raw" surface can reveal the existence of entities a viewer could not otherwise see, and is permission-gated for trusted use only. When in doubt, use the filtered flavor.

Ecosystem integrations

The base engine ships optional, self-guarding integrations that expose segments and their audiences to the wider ecosystem. Each detects its host module at runtime and stays dormant until that module is enabled — entity_segment installs and runs with none of them present, and the contrib hosts are suggested, never required.

  • Views (core) — a views_data handler for listing and filtering segments, plus a Segment audience filter that constrains a target-type View to a segment's members (raw or filtered mode).
  • Token (core Token API) — [segment:*] metadata tokens plus filtered and permission-gated raw member-count / members tokens.
  • JSON:API (core) — the segment entity is auto-exposed under its normal access; custom resolved-members resources add the audience in filtered and raw (permission-gated) variants.
  • Diff (Diff) — human-readable revision comparison of a segment's condition tree.
  • VBO (Views Bulk Operations) — bulk set-scope actions and an optional ready-made admin View.
  • ECA (ECA) — an "entity is in segment" condition and a "resolve segment" action for no-code automation on membership.

Included and companion modules

  • Entity Segment: User (included submodule) — a ready-made segment type for core Users, with a first-class area under People.
  • Entity Segment: Group (included submodule) — integrates the Group module so global segments can be group content, with per-group-role access. Supports Group 3.x and 4.x.
  • CRM Contact Segment (companion project; to be published) — segments of CRM Contacts, with a first-class home in the CRM area. Install it if you use the CRM contrib module.

For developers

Entity Segment exposes a small, target-aware plugin API. A condition plugin declares which entity types it applies to (or any) and receives the segment's target type as context, so one plugin works across targets. Consumers inject the entity_segment.resolver service and call resolve() (or resolveAccessible()) — see the plugin-author and consumer guides in the module's docs/ directory.

Requirements

  • Drupal core ^11.1
  • Core Options and User modules (no other hard dependencies)
  • JavaScript enabled (the condition builder is an AJAX form)

Stability

This module ships as alpha and makes no backwards-compatibility promise. The plugin interfaces, the stored condition-tree format, and the resolver contract may change — including in breaking ways — as real consumers show us what the API needs. Pin a version and read the release notes.

AI usage

This module was initially developed with lots of help from strikethroo 3.14 using Claude Opus 4.8.

Activity

Total releases
1
First release
Jul 2026
Latest release
5 hours ago
Releases (12 mo)
1 ▲ from 0
Maintenance
Active

Releases

Version Type Release date
1.0.0-alpha1 Pre-release Jul 21, 2026