1
---
2
name: data-manager-api-audience-ingestion
3
description: >-
4
Guides developers through managing (adding, removing, and clearing) audience members for Google products using
5
the Data Manager API and its associated client libraries. Use this skill when the user wants to upload audience
6
members, remove specific users, or clear/replace an entire audience for Customer Match, mobile device ID audiences, or any
7
other audience use case supported by the Data Manager API. Don't use for uploading events or
8
conversions (use the data-manager-api-event-ingestion skill), or for debugging errors, checking
9
request status, or investigating low match rates (use the data-manager-api-troubleshooting skill).
10
metadata:
11
version: "1.2.1"
12
publisher: google
13
category: GoogleAds
14
---
15
16
# Data Manager API Audience Ingestion
17
18
## Implementation Workflow
19
20
### Prerequisites
21
22
- **Authentication & Library Installation**: If you need to set up access to
23
the Data Manager API or install the client and utility libraries, refer to
24
the `data-manager-api-setup` skill.
25
- **Audience Creation (if needed)**: If the user does not have an existing
26
audience or needs to create a new one, use the
27
[Create an Audience](references/create-audience.md) reference. This step
28
provides the `product_destination_id` needed for the ingestion or removal
29
requests.
30
31
### Step 1: Identify Use Case & Read Documentation
32
33
- **Determine Destination Account Type**: [CRITICAL] If it's not clear where
34
the data is being sent (e.g., Google Ads, Display & Video 360, etc.), STOP
35
and CLARIFY with the user BEFORE generating any code. Do not assume Google
36
Ads by default. This maps to the `account_type` field of the
37
`operating_account` in the `Destination`.
38
- **Read the implementation guide**: Read the relevant guide for your
39
destination and use case. Do this before answering questions or writing code
40
because each destination has unique payload structures, consent rules, and
41
required fields.
42
43
| Destination | Audience Type | Accepted Data Types | Upload Guide | Remove All/Replace All Guide |
44
| :--- | :--- | :--- | :--- | :--- |
45
| **Google Ads** | Customer Match | `composite_data.user_data` (contact info), `mobile_data` (device IDs), `user_id_data` (user IDs) | [Upload Data](https://developers.google.com/data-manager/api/devguides/audiences/google-ads/customer-match/upload-data.md.txt) | [Remove All/Replace All](https://developers.google.com/data-manager/api/devguides/audiences/google-ads/customer-match/remove-all-members.md.txt) |
46
| **Display & Video 360** (DV360) | Customer Match | `composite_data.user_data` (contact info), `mobile_data` (device IDs) | [Upload Data](https://developers.google.com/data-manager/api/devguides/audiences/display-video/customer-match/upload-data.md.txt) | [Remove All/Replace All](https://developers.google.com/data-manager/api/devguides/audiences/display-video/customer-match/remove-all-members.md.txt) |
47
48
### Step 2: Retrieve Code Sample
49
50
> [!IMPORTANT] If writing or updating an ingestion script, ALWAYS retrieve the
51
> relevant code sample to use as a reference:
52
53
| Language | Sample |
54
| :--- | :--- |
55
| **Python** | [`ingest_audience_members.py`](https://github.com/googleads/data-manager-python/blob/main/samples/audiences/ingest_audience_members.py) |
56
| **Java** | [`IngestAudienceMembers.java`](https://github.com/googleads/data-manager-java/blob/main/data-manager-samples/src/main/java/com/google/ads/datamanager/samples/IngestAudienceMembers.java) |
57
| **PHP** | [`ingest_audience_members.php`](https://github.com/googleads/data-manager-php/blob/main/samples/audiences/ingest_audience_members.php) |
58
| **Node** | [`ingest_audience_members.ts`](https://github.com/googleads/data-manager-node/blob/main/samples/audiences/ingest_audience_members.ts) |
59
| **.NET**| [`IngestAudienceMembers.cs`](https://github.com/googleads/data-manager-dotnet/blob/main/samples/IngestAudienceMembers.cs) |
60
61
### Step 3: Retrieve Migration Guides
62
63
> [!IMPORTANT] If refactoring code to upgrade from another Google API, ALWAYS
64
> extract the full contents of the relevant field mapping guide.
65
66
#### Google Ads
67
68
* **Google Ads API Customer Match**: [Google Ads API to Customer Match
69
Migration Field
70
Mappings](https://developers.google.com/data-manager/api/devguides/audiences/google-ads/customer-match/upgrade/field-mappings.md.txt)
71
72
#### Display & Video 360
73
74
* **Display & Video 360 API Customer Match**: [Display & Video 360 API to
75
Customer Match Migration Field
76
Mappings](https://developers.google.com/data-manager/api/devguides/audiences/display-video/customer-match/upgrade/field-mappings.md.txt)
77
78
### Step 4: Implementation
79
80
Implement the ingestion logic using the following checkpoints:
81
82
- [ ] **Initialize Client**: Instantiate the Data Manager client
83
(`IngestionServiceClient`).
84
- [ ] **Define Destinations**: Build the `Destination` object using the
85
`product_destination_id` and the appropriate account configurations:
86
`operating_account` (target account receiving data), `login_account` (if
87
authenticating using a manager account or a data partner account), and
88
`linked_account` (if you're a data partner accessing the account via a
89
partner link to a manager account). **STRONGLY RECOMMENDED**: Refer to the
90
[Configure destinations and headers](https://developers.google.com/data-manager/api/devguides/concepts/destinations.md.txt)
91
guide for more details on configuring destinations.
92
- [ ] **Format User Data**: If sending an `IngestAudienceMembersRequest` or
93
`RemoveAudienceMembersRequest`, refer to **[Formatting User
94
Data](references/formatting.md)** to properly normalize and hash user identifiers using
95
the utility library.
96
- [ ] **Construct Payload**: Build the appropriate request payload based on
97
the operation:
98
* **Add**: `IngestAudienceMembersRequest`
99
* **Remove**: `RemoveAudienceMembersRequest`
100
* **Remove All**: `RemoveAllAudienceMembersRequest`
101
- [ ] **Support Validation**: Support sending the `validate_only` boolean
102
option on the payload to allow developers to validate schemas without
103
actually applying changes.
104
- [ ] **Send Request**: Execute the appropriate method and record the returned
105
`request_id` for later diagnostics. Keep the request payload, or a mapping
106
from each member's position to your own record ID, with the `request_id`.
107
Diagnostics identify failed members by their position in the request.
108
* **Add**: `ingest_audience_members`
109
* **Remove**: `remove_audience_members`
110
* **Remove All**: `remove_all_audience_members`
111
- [ ] **Check for Ingestion Warnings**: If any non-required field had a
112
validation failure, the response from `ingest_audience_members` will also
113
include `field_warnings`, a list of `FieldWarning` objects detailing the
114
issues.
115
- [ ] **Retrieve Request Status**: Check the status of the ingestion request
116
using diagnostics. Since request processing is asynchronous, a successful
117
response (HTTP 200 OK returning a `request_id`) only indicates the payload
118
was received. To check if the records actually succeeded, partially
119
succeeded, or failed to process, query `client.retrieve_request_status`
120
using the `request_id`, starting at least 30 minutes after sending. Skip
121
this step when `validate_only` is `true`, because validation-only requests
122
don't have diagnostics. Skipping this step for real requests is a common
123
user mistake. To read the results or debug failures, use the
124
`data-manager-api-troubleshooting` skill.
125
126
## Critical Gotchas
127
128
* If sending hashed user identifiers in `user_data` for
129
`ingest_audience_members` or `remove_audience_members`, you must set the
130
`encoding` field on the `IngestAudienceMembersRequest` to `HEX` or `BASE64`.
131
* If *uploading* to a Customer Match audience, the `terms_of_service` field is
132
required on the `IngestAudienceMembersRequest` to indicate the user has
133
accepted the policies.
134
* Only set the `address` field on `UserIdentifier` if all required fields
135
(`postal_code`, `family_name`, `given_name`, `region_code`) are present;
136
incomplete `address` fields will cause the API request to fail.
137
* `product_destination_id` must be a numeric string. It is NOT a resource
138
name.
139
* The enum values for `ConsentStatus` are `CONSENT_GRANTED` and
140
`CONSENT_DENIED`. Do not use the values `GRANTED` and `DENIED`.
141
* Field names on `UserIdentifier` are `email_address` and `phone_number`. Do
142
not use the Google Ads API field names `hashed_email` and
143
`hashed_phone_number`.
144
145
## API Reference
146
147
* [Send audience members guide](https://developers.google.com/data-manager/api/devguides/audiences/send-audience-members.md.txt)
148
* [REST API Reference: Ingest](https://developers.google.com/data-manager/api/reference/rest/v1/audienceMembers/ingest.md.txt)
149
* [REST API Reference: Remove](https://developers.google.com/data-manager/api/reference/rest/v1/audienceMembers/remove.md.txt)
150
* [REST API Reference: Remove All](https://developers.google.com/data-manager/api/reference/rest/v1/audienceMembers/removeAll.md.txt)
151