Google Data Manager
The google_data_manager connector uses the Google Data Manager API
to send first-party data to Google: conversions (events) and audience members (Customer Match). One API reaches
Google Ads, Google Analytics, Display & Video 360 and Campaign Manager 360. It can also read the processing status
of what you sent, and resources such as user lists.
Install
sw connectors -i google_data_manager
Connect
Put these keys in a job's connection (with provider: google_data_manager). Use a refresh token or a service account.
| Key | What it is | Required / default |
|---|---|---|
client_id | The OAuth client id (secret) | With a refresh token |
client_secret | The OAuth client secret (secret) | With a refresh token |
refresh_token | An OAuth refresh token with the https://www.googleapis.com/auth/datamanager scope (secret) | With a refresh token |
service_account_json | A service account key: JSON text or a file path (secret) | Instead of a refresh token |
Every key must be a secret reference ({{ secrets.NAME }}). They are redacted in every log line.
connections:
dm:
provider: google_data_manager
client_id: "{{ secrets.client_id }}"
client_secret: "{{ secrets.client_secret }}"
refresh_token: "{{ secrets.refresh_token }}"
Write data
A job's apply output (reverse ETL) sends its rows to Google. Each row is one record of the request, and its columns are the record's fields.
| Operation | A row is | Rows per call |
|---|---|---|
IngestionService.ingest_events | An event: transaction_id, event_timestamp, ad_identifiers, user_data, conversion_value, currency, ... | 2000 |
IngestionService.ingest_audience_members | An audience member: user_data, mobile_data, pair_data, consent, ... | 10000 |
IngestionService.remove_audience_members | An audience member to remove (needs allow_remove: true) | 10000 |
Any other IngestionService.ingest_* or remove_* | One element of the request's list | 1000 |
Arguments:
| Argument | What it does | Default |
|---|---|---|
destinations | Where the records go: a list of destinations (an operating account, a login account and a product destination such as a conversion action or user list) | Required, unless the rows carry their own (below) |
consent | The request's consent, for example {ad_user_data: CONSENT_GRANTED, ad_personalization: CONSENT_DENIED}. Send only the consent you actually collected. A row's own consent takes precedence | |
encoding | How hashed identifiers are encoded: HEX or BASE64 | HEX |
validate_only | true: Google checks the request and ingests nothing (a dry run) | false |
terms_of_service | Audiences only: the Customer Match terms of service status |
Any other request field goes to Google unchanged.
Send conversions
steps:
- name: events
sql: |
SELECT transaction_id,
converted_at AS event_timestamp,
'WEB' AS event_source,
CASE WHEN gclid IS NOT NULL THEN {'gclid': gclid} END AS ad_identifiers,
value AS conversion_value,
currency,
json_object('user_identifiers', [
json_object('email_address', sha256(lower(trim(email))))
]) AS user_data
FROM input
outputs:
- name: ingest
connection: dm
step: events
operation:
service: IngestionService
method: ingest_events
arguments:
destinations:
- operating_account: {account_type: GOOGLE_ADS, account_id: "{{ config.customer_id }}"}
product_destination_id: "{{ config.conversion_action_id }}"
consent: # the consent you collected: never assume it was granted
ad_user_data: "{{ config.ad_user_data_consent }}"
ad_personalization: "{{ config.ad_personalization_consent }}"
validate_only: "{{ config.validate_only }}"
apply: {nulls: skip_field, on_row_error: continue}
- Identifiers: normalize and SHA-256 hash emails, phone numbers and addresses in SQL, as Google's formatting guidelines describe. Only the hashes then reach the state store and the logs.
- Missing values:
nulls: skip_fieldleaves out a field whose value is NULL, such as a conversion without a gclid. - Deduplication: Google deduplicates events on
transaction_id, so a call cut short is sent again. Every event needs one: a row without atransaction_idfails alone (INVALID_ROW).
A destination per row
Rows can go to different destinations, for example conversions to several conversion actions. Leave out the
destinations argument and give each row a destination column with the same fields as a destination. Each request
then lists its rows' destinations, and each record names its own, as Google's
guide describes.
A request takes at most 10 destinations: a chunk splits into more requests past that, and a row with more than 10
of its own fails alone (INVALID_ROW).
A row can also pick some of the destinations argument by their reference, in a destination_references column.
A reference that names none of them fails the row (INVALID_ROW), rather than sending the event everywhere.
SELECT ...,
{'operating_account': {'account_type': 'GOOGLE_ADS', 'account_id': '{{ config.customer_id }}'},
'product_destination_id': action_id} AS destination
FROM conversions
The action_id can come from a call step, for example a conversion action looked up by name with the
google_ads connector.
Errors, warnings and processing status
The Data Manager API checks a whole request before it accepts it, and reports problems per record.
- Rejected records. When Google names records with invalid fields, those rows fail alone, with Google's reason as
their error code (for example
INVALID_HEX_ENCODING). The rest of the chunk is sent again without them. A problem with the request itself fails every row of the chunk. - Field warnings. An accepted record can come with warnings, for example an optional field Google dropped. The row
is applied, and its result keeps
warnings: each with itsfield,reasonanddescription. - Processing. Google processes accepted requests later. Each applied row keeps the
request_idand itsrecord_index.IngestionService.retrieve_request_statusreports, per destination, how many records were processed and the indices of the records that failed. - Retries. Rate limits and transient errors are retried. An exhausted daily quota fails with
DAILY_QUOTA_EXHAUSTEDand is not retried. Other errors carry Google's reasons and its support request id.
Read the rows' outcomes with the output's log:, for example a line
per rejected record:
log:
sql: |
SELECT transaction_id, outcome.error_code AS code, outcome.error_message AS reason
FROM ingest WHERE outcome.status = 'failed'
message: "transaction {transaction_id}: {code}: {reason}"
level: warning
Read data
A call step reads with the same operation keys. Its sql reads the table records
(call steps).
| Operation | Arguments | Records |
|---|---|---|
IngestionService.retrieve_request_status | request_id | One per destination of the request |
*Service.list_*, search_*, get_*, retrieve_* | The request's fields, as vendor arguments | One per resource |
steps:
- name: status
connection: dm
operation:
service: IngestionService
method: retrieve_request_status
arguments:
request_id: "{{ config.request_id }}"
sql: |
SELECT record->>'$.request_status' AS status,
CAST(record->'$.error_info' AS VARCHAR) AS errors
FROM records
Complete jobs (conversions, conversions by action name, audiences, request status) are in
examples/google_data_manager.
Good to know
- Engines: DuckDB and Spark jobs (apply outputs and call steps), and sources.
- Rejected rows: each keeps Google's reason as its code (
INVALID_HEX_ENCODING), and the record'sfieldfor error rules. - Logs: the Google library logs on
google.ads.datamanager_v1. StreamWright never turns it on; name it with--log google.ads.datamanager_v1=DEBUG, and its lines are redacted like StreamWright's own.
See also
- Apply outputs: how writes are delivered, logged and retried.
- Google Ads: read conversion actions and upload conversions with the Google Ads API.