An [`Audience`](https://developers.google.com/google-ads/api/reference/rpc/v26/Audience) is a reusable collection of focused segments,
demographic targeting, and exclusions. Audience targeting is supported for
[Performance Max](https://support.google.com/google-ads/answer/10724817), [Demand Gen](https://support.google.com/google-ads/answer/9176876), and [App
campaigns](https://support.google.com/google-ads/answer/6247380). If you want to target audience segments directly
in a Display, Search, Video, Hotel, or Standard Shopping campaign, see [Audience
segments](https://developers.google.com/google-ads/api/docs/remarketing/audience-segments/getting-started).

## Create audiences

Create and update an audience using the [`AudienceService`](https://developers.google.com/google-ads/api/reference/rpc/v26/AudienceService).
Each [`Audience`](https://developers.google.com/google-ads/api/reference/rpc/v26/Audience) must have a unique name. This reusable audience
allows a combination of multiple audience dimensions:

- [Audience segments](https://developers.google.com/google-ads/api/docs/remarketing/audience-segments/getting-started)
  - [User list segments](https://developers.google.com/google-ads/api/reference/rpc/v26/UserListSegment)
  - [Affinity or in-market segments](https://developers.google.com/google-ads/api/reference/rpc/v26/UserInterestSegment)
  - [Life event segments](https://developers.google.com/google-ads/api/reference/rpc/v26/LifeEventSegment)
  - [Detailed demographic segments](https://developers.google.com/google-ads/api/reference/rpc/v26/DetailedDemographicSegment)
  - [Custom audience segments](https://developers.google.com/google-ads/api/docs/remarketing/audience-segments/custom-audiences) ([`CustomAudienceSegment`](https://developers.google.com/google-ads/api/reference/rpc/v26/CustomAudienceSegment))
- Age: [`AgeDimension`](https://developers.google.com/google-ads/api/reference/rpc/v26/AgeDimension)
- Gender: [`GenderDimension`](https://developers.google.com/google-ads/api/reference/rpc/v26/GenderDimension)
- Household income: [`HouseholdIncomeDimension`](https://developers.google.com/google-ads/api/reference/rpc/v26/HouseholdIncomeDimension)
- Parental status: [`ParentalStatusDimension`](https://developers.google.com/google-ads/api/reference/rpc/v26/ParentalStatusDimension)

> [!NOTE]
> **Note:** Only [`UserListSegment`](https://developers.google.com/google-ads/api/reference/rpc/v26/UserListSegment)---a wrapper for a [`UserList`](https://developers.google.com/google-ads/api/reference/rpc/v26/UserList) referenced within an `Audience`---can be used in an [`exclusion_dimension`](https://developers.google.com/google-ads/api/reference/rpc/v26/AudienceExclusionDimension).

### Inspect MutateAudienceResult for audience_id

When creating an audience with
[`AudienceService.MutateAudiences`](https://developers.google.com/google-ads/api/reference/rpc/v26/AudienceService/MutateAudiences), each operation returns a
[`MutateAudienceResult`](https://developers.google.com/google-ads/api/reference/rpc/v26/MutateAudienceResult). You can inspect
`MutateAudienceResult` to obtain the `audience_id` by parsing the returned
`resource_name`, and you can inspect mutable fields (such as `name`) on the
returned `audience` object when `response_content_type` is set to
`MUTABLE_RESOURCE`:

    # Configure the request to return the mutable resource in the response.
    request = googleads_client.get_type("MutateAudiencesRequest")
    request.customer_id = customer_id
    request.operations = [operation]
    request.response_content_type = (
        googleads_client.enums.ResponseContentTypeEnum.MUTABLE_RESOURCE
    )

    response = audience_service.mutate_audiences(request=request)

    for result in response.results:
        resource_name = result.resource_name
        # Format: customers/{customer_id}/audiences/{audience_id}
        audience_id = audience_service.parse_audience_path(resource_name)[
            "audience_id"
        ]
        print(f"Created audience '{resource_name}' with ID '{audience_id}'.")

        # Access mutable fields on result.audience when MUTABLE_RESOURCE is requested.
        if result.audience.resource_name:
            print(f"Audience name from mutable resource: {result.audience.name}")

## Retrieve audiences

As with other resources, you can use
[`GoogleAdsService.SearchStream`](https://developers.google.com/google-ads/api/reference/rpc/v26/GoogleAdsService/SearchStream) to retrieve attributes of
audiences.

    SELECT
      audience.id,
      audience.resource_name,
      audience.name,
      audience.status,
      audience.description,
      audience.dimensions,
      audience.exclusion_dimension
    FROM audience

## Target audiences

Audiences can be targeted in multiple ways depending on the campaign type.

### Asset group signals

Performance Max campaigns use an [`AssetGroupSignal`](https://developers.google.com/google-ads/api/reference/rpc/v26/AssetGroupSignal) to
target audiences. See the [Asset group signals](https://developers.google.com/google-ads/api/performance-max/asset-group-signals) guide
to learn how to target audiences using asset group signals.

### Ad group criterion

Demand Gen and App campaigns support adding an audience ad group criterion using
[`AdGroupCriterion`](https://developers.google.com/google-ads/api/reference/rpc/v26/AdGroupCriterion) to target audiences or provide audience
signals. You can target audiences at the ad group level using
[`AudienceInfo`](https://developers.google.com/google-ads/api/reference/rpc/v26/AudienceInfo) criteria on
[`AdGroupCriterion.audience`](https://developers.google.com/google-ads/api/reference/rpc/v26/AdGroupCriterion#audience) by setting the
[`AudienceInfo.audience`](https://developers.google.com/google-ads/api/reference/rpc/v26/AudienceInfo#audience) field
(`ad_group_criterion.audience.audience`) to the audience resource name.

Here are the steps to set up audience targeting:

#### Enable audience targeting in the `AdGroup`

You must enable audience targeting in the `AdGroup` by setting
[`use_audience_grouped`](https://developers.google.com/google-ads/api/reference/rpc/v26/AdGroup.AudienceSetting#use_audience_grouped) to `true` when the ad group is
created. This setting cannot be changed after the ad group is created.

This lets you add `AdGroupCriterion` with audiences. If this value is not set to
`true`, then your subsequent request to target the audience will fail.

#### Create an `AdGroupCriterion`

Create an `AdGroupCriterion`, and set the
[`AudienceInfo.audience`](https://developers.google.com/google-ads/api/reference/rpc/v26/AudienceInfo#audience) field on
[`AdGroupCriterion.audience`](https://developers.google.com/google-ads/api/reference/rpc/v26/AdGroupCriterion#audience) to the resource name
of the audience created in [Create audiences](https://developers.google.com/google-ads/api/docs/remarketing/audiences#create-audiences).

#### Optional: Enable audience targeting in the `Campaign`

You can optionally set [`use_audience_grouped`](https://developers.google.com/google-ads/api/reference/rpc/v26/Campaign.AudienceSetting#use_audience_grouped) to `true`
when the campaign is created. With this setting, you receive an error if you try
to add criteria that would exclude segments and demographics at the campaign
level.

## Best practices

- **Use audiences for persona building.** Audiences are best used in Performance Max, Demand Gen, and App campaigns where you want to layer multiple segments and demographic criteria to target a specific persona.
- **Use audience segments for direct targeting.** For Display, Search, Video, Hotel, and Standard Shopping campaigns, or when you only need to target a single segment (like a remarketing list), use [Audience
  segments](https://developers.google.com/google-ads/api/docs/remarketing/audience-segments/getting-started) instead of Audiences.

## Common errors

When creating or updating an [`Audience`](https://developers.google.com/google-ads/api/reference/rpc/v26/Audience), the Google Ads API validates the
request and returns errors from the [`AudienceError`](https://developers.google.com/google-ads/api/reference/rpc/v26/AudienceErrorEnum.AudienceError) enum if
validation fails.
`AudienceError` `AUDIENCE_SEGMENT_NOT_FOUND` Summary An audience segment in the request was not found. Common causes Referencing a segment ID that does not exist or is inaccessible. How to handle Ensure all segment IDs exist and are accessible before creating or updating an audience. Prevention tips Validate segment IDs before including them in an audience. `DIMENSION_INVALID` Summary An audience dimension is invalid. Common causes Including `detailed_demographic` in `exclusion_dimension`. How to handle Only use `user_list` for exclusions in `exclusion_dimension`. Prevention tips Ensure only `user_list` is used in `exclusion_dimension` when creating or updating an audience. `DUPLICATE_AUDIENCE_SEGMENT` Summary The audience contains duplicate segments. Common causes Adding the same segment multiple times to the same audience. How to handle Remove duplicate segments from the audience definition. Prevention tips Ensure all segments in an audience are unique. `NAME_ALREADY_IN_USE` Summary The audience name is already in use. Common causes Attempting to create multiple audiences with the same name. How to handle Use a unique name when creating an audience. Prevention tips Check for existing audience names before creating a new one. `TOO_MANY_DIMENSIONS_OF_SAME_TYPE` Summary The audience contains too many dimensions of the same type. Common causes Including multiple dimensions of the same type (for example, multiple age dimensions) in one audience. How to handle Ensure the audience definition contains only one dimension of each type. Prevention tips Review the audience definition to ensure no duplicate dimension types are included. `TOO_MANY_SEGMENTS` Summary The audience contains too many segments. Common causes Exceeding the maximum allowed number of segments in an audience. How to handle Reduce the number of segments in the audience definition. Prevention tips Check documentation for limits on the number of segments per audience.