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

# External Audiences

> Bring CDP audience memberships into ACI, match visitors, and target experiences and experiments.

Use an external audience when your CDP or another system already decides who belongs to a group. ACI imports those memberships, matches a consented visitor to the provider's identity, and makes the mapped ACI audiences available to personalization and experiments.

Choose how the export reaches ACI:

| Path | Best for | Guide |
| - | - | - |
| Scheduled S3 export | Recurring exports from a CDP or data pipeline | [Configure an S3 export](https://docs.gradial.com/aci/personalization/external-audiences-s3.md) |
| File upload | A manual export or a team without an S3 export pipeline | [Upload an audience file](https://docs.gradial.com/aci/personalization/external-audiences-upload.md) |

Both paths use the same provider configuration, validation, import reports, and audience mappings.

```text theme={null}
CDP export → S3 drop zone or uploaded file → imported memberships
                                                    ↓
Consented visitor + matching provider identity → ACI audience
                                                    ↓
                               audience experience or experiment
```

## 1. Define the provider

Create `.content/providers/customer-cdp/_index.json`. This example accepts records containing a customer ID and an array of segment IDs:

```json theme={null}
{
  "$type": "audience_provider",
  "props": {
    "id": "customer-cdp",
    "displayName": "Customer CDP",
    "status": "enabled",
    "format": "mapped-json",
    "mapping": {
      "identity": { "path": "/customerId" },
      "membership": { "segmentIdsPath": "/segments" }
    },
    "identity": {
      "sourceNamespace": "customer_id",
      "absencePolicy": "unlink",
      "resolution": [{ "field": "cookie.customer_id" }]
    },
    "membershipTtlDays": 14,
    "discovery": { "mode": "report-only" }
  }
}
```

The provider ID must match its directory name. Use JSON pointers such as `/customerId` and `/segments` to describe your export's fields. The importer accepts a JSON array or JSONL, with one record per line. For example, `profiles.json` can contain:

```json theme={null}
[
  { "customerId": "customer-001", "segments": ["seg-gold", "seg-newsletter"] },
  { "customerId": "customer-002", "segments": ["seg-newsletter"] }
]
```

`membershipTtlDays` controls how long imported memberships remain valid after import. Choose a value that covers your expected refresh interval; for a daily export, 14 days allows room to recover a failed export. Expired memberships stop qualifying visitors.

### Match the visitor's identity

The export and the page request must carry the same identity value. In this example, the application sets a first-party `customer_id` cookie whose value is exactly the `customerId` in the export. Configure that handoff in your application before testing personalization.

* `sourceNamespace` names the provider identity, such as `customer_id` or `ecid`; it cannot be `aci_id`.
* `resolution` is an ordered list of `cookie.<name>`, `query.<name>`, or `header.<name>` fields. Cookie, query, and header names support letters, digits, `_`, and `-`.
* Values are matched as supplied. ACI does not lowercase emails, strip prefixes, or otherwise transform them for you.
* `absencePolicy: "unlink"` treats a missing identity as logout/removal. Use `"retain"` only when absence is intentional and non-authoritative, such as a one-time handoff. A changed present identity replaces the previous value under either policy.

Use an opaque identifier appropriate for your consent and data policy. Ensure any identity header comes from a trusted application or proxy. Never place an API token or signing secret in a browser cookie, query parameter, or provider document.

External audience delivery does not require a collection event. It still requires the site's consent and identity policy. See [Collection and Consent](https://docs.gradial.com/aci/personalization/collection-and-consent.md).

### Adobe Experience Platform exports

For an AEP profile export with `identityMap` and `segmentMembership`, use `"format": "aep-batch-export"` and omit `mapping`. Set `identity.sourceNamespace` to the exported namespace, such as `ecid`, and declare the request field that supplies that exact identity. A record looks like:

```json theme={null}
{
  "identityMap": { "ecid": [{ "id": "12345678901234567890" }] },
  "segmentMembership": {
    "ups": {
      "seg-gold": { "status": "realized" }
    }
  }
}
```

Only `realized` and `existing` memberships qualify. For an AEP export shaped as a plain list or another custom schema, use `mapped-json` with mappings that match the actual file.

## 2. Map a provider segment to an ACI audience

Create `.content/audiences/gold-members/_index.json`:

```json theme={null}
{
  "$type": "audience",
  "props": {
    "id": "gold-members",
    "displayName": "Gold members",
    "status": "enabled",
    "priority": 200,
    "membershipSource": "external",
    "providerRef": "$ref:providers/customer-cdp",
    "externalSegmentId": "seg-gold"
  }
}
```

`externalSegmentId` must exactly match the exported segment ID. The provider and audience must both be enabled. Each provider/segment pair maps to one ACI audience. Unmapped segment IDs appear in import discovery results but do not become live targeting automatically.

With `discovery.mode: "report-only"`, inspect the report and author the audience documents you want. `"draft"` discovery can create draft audiences for review; they must be reviewed, enabled, and published before delivery.

## 3. Publish the configuration and import a file

Compile and review the provider and audience resources, land them on `main`, and promote the required paths to `live` using [Preview, Publish, and Roll Back](https://docs.gradial.com/aci/personalization/preview-publish-and-rollback.md). The importer reads provider configuration from the active release, so a local file or unpublished branch is not enough.

Dry-run a publish with external audience delivery activated:

```bash theme={null}
curl --request POST "$ACI_API_URL/v1/publishes" \
  --header "Authorization: Bearer $ACI_API_TOKEN" \
  --header "Content-Type: application/json" \
  --data '{"dryRun": true, "activateEdgeReader": true}'
```

After review, publish with `{"activateEdgeReader": true}` and activate the resulting release through the normal release workflow. This publish option requires enabled identity declarations and at least one enabled segment-to-audience mapping. Include it on later publishes that should continue external audience delivery.

If you do not know the segment IDs yet, first publish and activate the provider without that option, import an export, and inspect the report's discovered IDs. Then add the audience mappings and publish with `activateEdgeReader: true`.

Now follow either [S3 exports](https://docs.gradial.com/aci/personalization/external-audiences-s3.md) or [file uploads](https://docs.gradial.com/aci/personalization/external-audiences-upload.md). Wait for an `accepted` import report before testing a member.

## 4. Use the audience in an experience

Create an ordinary audience overlay at:

```text theme={null}
.content/overlays/audience/gold-members/pages/home/_index.json
```

Use the same overlay shape and validation as [Experiences and Overlays](https://docs.gradial.com/aci/personalization/experiences-and-overlays.md). Audience priority resolves overlapping matches. Visitors without a qualifying membership receive the normal audience or base experience.

## 5. Restrict an experiment to this audience

Add `eligibility` inside the experiment's `props`:

```json theme={null}
{
  "eligibility": {
    "audienceRef": "$ref:audiences/gold-members",
    "mode": "claims"
  }
}
```

For example, add it to the `home-hero` A/B experiment in [Experiments and Reporting](https://docs.gradial.com/aci/personalization/experiments-and-reporting.md). Keep its goal, route scope, arms, allocation version, and salt. The eligibility check runs before assignment: members can enter the experiment; non-members and visitors without verified membership are skipped and generate no exposure for it. Ordinary content selection still runs.

This gate uses audience membership, independently of which audience experience wins by priority. Experiment arm overlays keep the experiment paths shown in that guide. Raw CDP attributes such as lifetime value are not automatically exposed as request-rule fields; define the corresponding segment in your provider, export its memberships, and map that segment to an ACI audience.

Use the collector and a configured goal to measure exposures and conversions. External matching can serve content without collection, but it does not supply experiment measurements. Read the report as results **among eligible members**, rather than the whole site. Membership changes can change eligibility on later requests.

## Verify the complete path

1. Confirm an `accepted` report with the expected record counts and segment IDs.
2. Preview the audience with `?aci_audience=gold-members`. Preview each experiment arm with `?aci_experiment.home-hero=control` or `?aci_experiment.home-hero=outcome-led`. Preview forcing checks content; it does not prove identity matching or import delivery.
3. On the activated site, test a consented member with the matching provider identity and confirm the audience or experiment is selected on the page response.
4. Test a non-member, a missing identity, logout/account switching, and denied consent. Confirm the intended ordinary experience and no ineligible experiment exposure.
5. With measurement consent, trigger the goal and confirm exposure/conversion data in the experiment report.

The serving edge reads imported memberships and maps them through the active release; it does not call the CDP or ACI control-plane API on each page. Changing an audience mapping requires a new release, while refreshing memberships uses a new import. Existing signed claims have a bounded lifetime, so allow for claims refresh when checking a changed export.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.