Create an Audience (User List)
If the user needs to create a new audience before ingesting data, follow these steps.
Reference
[CRITICAL] Follow the relevant guide for sample requests and more information on how to create an audience using the Data Manager API:
- Google Ads Customer Match: Create a Customer Match audience
- Display & Video 360 Customer Match: Create a Customer Match audience
Common Mistakes & Gotchas
The below examples are in Python, but the concepts apply to all client libraries.
- The correct client is
UserListServiceClient, notUserListsClient.
from google.ads import datamanager_v1
user_list_client = datamanager_v1.UserListServiceClient()Do not pass Google Ads specific headers like
login-customer-idordeveloper-token. If required, setlogin-accountorlinked-accountheaders formatted as resource names (e.g.,accountTypes/{account_type}/accounts/{id}) for resource management requests.- Set
login-accountif authenticating using a manager account or a data partner account. - Set
linked-accountif you're a data partner accessing the account via a partner link to a manager account. - Consult the Configure destinations and headers documentation for example headers in different resource management request access scenarios.
- Set
headers = []
account_type = "GOOGLE_ADS"
login_account_id = "1234567890"
if login_account_id:
headers.append(
(
"login-account",
f"accountTypes/{account_type}/accounts/{login_account_id}",
)
)
response = user_list_client.create_user_list(
parent=parent_account, user_list=user_list_data, metadata=headers
)