User-provided data matching

  • User-provided data matching (UPDM) combines your first-party data with a user's signed-in activity across Google ad data.

  • UPDM is only available for Google owned & operated data linked to a signed-in user in Google ad data.

  • The Connections page in Ads Data Hub simplifies the process of importing, transforming, and matching your ads data in BigQuery for use in Ads Data Hub queries.

  • To use user-provided data matching, your first-party data must be formatted correctly and adhere to specific privacy requirements, including obtaining necessary consent.

  • Match tables, created through UPDM, can be queried in Ads Data Hub to gain insights by joining your first-party data with Google Ads data.

User-provided data matching (UPDM) joins first-party data that you've collected about a user—such as information from your websites, apps, or physical stores—with that same user's signed-in activity across all Google ad data, including Google owned & operated data. This includes data bought through Google Marketing Platform (GMP) products, for example, YouTube bought using Display & Video 360. Other GMP products which are not Google owned & operated are not supported.

To be eligible for user-provided data matching, the ad event must be linked to a signed-in user in Google ad data.

This document describes the user-provided data matching feature, and provides guidance on setup and use.

Connections Tab Overview

Gaining valuable advertising insights often requires stitching together data from multiple sources. Building your own solution to this data pipeline problem requires significant time investment and engineering investment. The Connections page in Ads Data Hub streamlines this process by providing a step-by-step, guided interface for importing, transforming, and matching your ads data in BigQuery, so that you can use it in your Ads Data Hub queries, or any other product that reads from BigQuery. Enriching your queries with first-party data can deliver richer customer experiences, and is more resistant to industry-wide ad-tracking changes.

The Connections page is built with tools that allow you to encrypt and share personally identifiable information (PII) with partners in a privacy-centric manner. After selecting which columns contain PII, Ads Data Hub encrypts the data, ensuring that your first-party data can only be exported or read by people who have permission to do so. Knowing which first-party data is needed for your measurement or activation use case can be difficult, so Ads Data Hub provides a comprehensive list of predefined use cases, then guides you through the entire experience of extracting, transforming, and loading your data. While can create multiple types of connections, this document assumes that you are using the Connections page for user-provided data matching.

Supported first-party data sources

You can import data from these data sources:

  • BigQuery
  • Cloud Storage
  • Secure FTP (sFTP)
  • Snowflake
  • MySQL
  • PostgreSQL
  • Amazon Redshift
  • Amazon S3

Because user-provided data matching is only available on Google owned and operated inventory for signed-in users, it is not impacted by the upcoming deprecation of third-party cookies. Since it's more resistant to industry changes than third-party data, it can provide richer insights, which can lead to higher customer engagement.

Learn the terminology

  • User-provided data connection: Set up a user-provided data connection to import and match your data, schedule data imports, transform data, and match your ads data using a user ID. The ad event must be linked to a signed-in user in Google ad data. Requires multiple Google Cloud projects.
  • First-party data connection: Set up a first-party data connection as a data preparation tool, to schedule data imports and transform data without the advanced features of UPDM. This type of connection requires only one Google Cloud project.
  • Data source: A connected product, imported file, or third-party integration–for example, BigQuery.
  • Destination: A use case; typically a Google product or product feature, where imported data is activated–for example, Ads Data Hub user-provided data matching.
  • Admin project: The Google Cloud project that contains your proprietary advertising data in its raw format.
  • Output dataset: The BigQuery dataset that Ads Data Hub writes to. By default, this is a dataset under your admin project. To change it to another Google Cloud project, see Configure service accounts.

Process summary

  1. Setup of data ingestion and matching
    • You Make sure your first-party data is located in BigQuery and your service account has read access to it. See Set up data ingestion.
  2. First-party data ingestion and matching
    • You format and upload your first-party data to your BigQuery dataset. For the simplest setup, use your admin project. However, you can use any BigQuery dataset that you own.
    • You initiate a data-matching request by creating a connection and setting a schedule.
    • Google joins data between your project and Google-owned data containing Google's user ID and hashed user-provided data to build and update match tables.
    • See Ingest first-party data
  3. Ongoing queries in Ads Data Hub, based on matched data
    • You run queries against the match tables in the same way you run regular queries in Ads Data Hub. See Query matched data.

Learn about privacy requirements

Collecting customer data

When using user-provided data matching, you must upload first-party data. This could be information you collected from your websites, apps, physical stores, or any information that a customer shared with you directly.

You must:

  • Ensure that your privacy policy discloses that you share customer data with third parties to perform services on your behalf, and that you obtain consent for such sharing where legally required
  • Only use Google's approved API or interface to upload customer data
  • Comply with all applicable laws and regulations, including any self-regulatory or industry codes that may apply

First-party consent acknowledgement

To ensure you are able to use your first-party data in Ads Data Hub, you must confirm that you have obtained proper consent to share data from EEA end users with Google per the EU user consent policy and Ads Data Hub policy. This requirement applies to each Ads Data Hub account, and must be updated every time you upload new first-party data. Any one user can make this acknowledgement on behalf of the entire account.

Note that the same Google service query rules that apply to analysis queries also apply to UPDM queries. For example, you can't run cross-service queries on users in the EEA when you create a match table.

To learn how to acknowledge consent in Ads Data Hub, see Consent requirements for the European Economic Area.

Data size

To protect end-user privacy, user-provided data matching enforces these requirements regarding the size of your data:

  • Your user list must match more than 1,000 users.
  • In the legacy Connections tab, every successful update of your match table must include a minimum number of newly matched users. This behavior is similar to difference checks.
  • Your list must not exceed the maximum number of records. To learn about the maximum data limit, reach out to your Google representative.

Set up data ingestion

Before you start, you need to configure your Ads Data Hub account to create data connections, which is how you'll establish your data-matching pipeline. You only need to perform these steps once.

From the Connections page, click Begin setup to open the account setup wizard at the UPDM enablement stage.

Go to Connections

What permissions are granted for BigQuery and Cloud Storage?

If you set up UPDM for use with BigQuery or Cloud Storage, use this reference to understand the permissions that are granted to the Ads Data Hub service accounts.

BigQuery

Datafusion service account
Purpose The datafusion service account is used to display a list of source fields in the Ads Data Hub UI.
Format service-some-number@gcp-sa-datafusion.iam.gserviceaccount.com
Required access
BigQuery Data Viewer
roles/bigquery.dataViewer
for specific datasets in Data Source and Destination projects
Storage Admin
roles/storage.admin
for the Data Source project, or a dedicated storage bucket
Dataproc service account
Purpose The dataproc service account is responsible for running the data pipelines in the background.
Format some-number-compute@developer.gserviceaccount.com
Required access
BigQuery Data Viewer
roles/bigquery.dataViewer
for specific datasets in Data Source and Destination projects
BigQuery Data Editor
roles/bigquery.dataEditor
for specific datasets in the Destination project
BigQuery Job User
roles/bigquery.jobUser
for both Data Source and Destination projects
Storage Admin
roles/storage.admin
for both Data Source and Destination projects, or a dedicated storage bucket
UPDM service account
Purpose The UPDM service account is used to run the matching job.
Format service-some-number@gcp-sa-adsdataconnector.iam.gserviceaccount.com
Required access
BigQuery Data Viewer
roles/bigquery.dataViewer
for the Destination project
BigQuery Job User
roles/bigquery.jobUser
for the Destination project

Cloud Storage

Datafusion service account
Purpose The datafusion service account is used to display a list of source fields in the Ads Data Hub UI.
Format service-some-number@gcp-sa-datafusion.iam.gserviceaccount.com
Required access
Storage Object Viewer
roles/storage.objectViewer
for specific storage buckets in the Data Source project
BigQuery Data Viewer
roles/bigquery.dataViewer
for the Data Source project, or a dedicated storage bucket
Storage Admin
roles/storage.admin
for the Data Source project, or a dedicated storage bucket
Dataproc service account
Purpose The dataproc service account is responsible for running the data pipelines in the background.
Format some-number-compute@developer.gserviceaccount.com
Required access
Storage Admin
roles/storage.admin
for both Data Source and Destination projects, or a dedicated storage bucket
BigQuery Job User
roles/bigquery.jobUser
for the Destination project
UPDM service account
Purpose The UPDM service account is used to run the matching job.
Format service-some-number@gcp-sa-adsdataconnector.iam.gserviceaccount.com
Required access
BigQuery Data Viewer
roles/bigquery.dataViewer
for the Destination project
BigQuery Job User
roles/bigquery.jobUser
for the Destination project

Other data sources

Not necessary for other data sources

Ingest and match first-party data

Source permissions and connection requirements

Ads Data Hub Connections uses the service account shown under Settings > Details > Service account (usually service-<number>@gcp-sa-adsdatahub.iam.gserviceaccount.com). Grant it these roles:

  • BigQuery source: roles/bigquery.dataViewer (BigQuery Data Viewer) on the source dataset or table.
  • Cloud Storage source: roles/storage.objectViewer (Storage Object Viewer) on the source bucket.
  • First-party data import destination: roles/bigquery.dataEditor (BigQuery Data Editor) on the destination dataset, if the table isn't in your default dataset.

To create, edit, or delete connections in the updated Connections experience, you also need the Analyst or Superuser role in Ads Data Hub (see Assign access by role). Users who only have the Link manager role can't view or manage connections in the updated experience.

Field and data type requirements

These rules are for connections in the updated Connections experience. They depend on the connection type: User-provided data matching or First-party data.

User-provided data matching (UPDM)

Map user_id and at least one of these: email, phone, or a full address (first_name, last_name, country, and zip_code). If you map any address column, map all four. Otherwise, you can't save the connection. You can't change the Type of these columns: it's HASH for email, phone, first_name, and last_name, and STRING for user_id, country, and zip_code.

The source column that you map to each destination column must contain the following. To format the values, see Format data for input.

Destination column Source column value Example
user_id Your ID for the user, in plain text customer-1234
email, phone, first_name, last_name The formatted value, hashed with SHA-256 and encoded in Base64 (44 characters). Hex encoding (64 characters) also works. h5JGBrQTGorO7q6IaFMfu5cSqqB6XTp1aybOD11spnQ=, the hash of test@gmail.com
country A 2-letter country code (ISO 3166-1 alpha-2), in plain text US
zip_code A zip or postal code of up to 20 characters (letters A-Z, a-z, digits, spaces, and hyphens), in plain text 94043
  • Hash the values in your source. Connections doesn't hash email, phone, first_name, or last_name, even though their Type is HASH. One exception: if your connection was moved to the updated Connections experience, and a field used compute hash before the move (compute hash hashed the column for you), Connections still hashes that field. Keep that field's source values unhashed, but formatted; see Moved connections.
  • In a BigQuery source table, use STRING columns.
    • email, phone, first_name, and last_name must be STRING. With another type, such as INT64, you can't save the connection.
    • user_id can also be INT64 or BYTES. A BYTES value that isn't UTF-8 text becomes NULL.
    • zip_code can also be INT64, but an INT64 can't keep a leading zero (02134 is stored as 2134), so such a zip code can't match. Store zip codes as STRING.
  • Give every row a user ID. All rows with a NULL user ID count as one user, so at most one of them can match. The same goes for all rows with an empty user ID.
  • Your user ID becomes BYTES. Connections converts it to BYTES, the user ID type that Format data for input lists, so your source column can stay STRING. For example, the INT64 value 42 becomes b"42". In the _updm match tables, it's the customer_data_user_id column. CAST(my_data.user_id AS BYTES) fails for an INT64 ID, so to join on one, cast it to STRING first: customer_data_user_id = CAST(CAST(my_data.user_id AS STRING) AS BYTES).
  • An empty or wrongly formatted email, phone, or address value can't match, but it doesn't fail the run. The row can still match on its other values. For example, an email in plain text, the country USA, or the zip code 94043.1351 can't match. To match on its address, a row needs valid values in all four address columns.
  • In a Private Cloud Match query, a value in the wrong format can fail the whole query. This applies if you create the match table with the CREATE OR REPLACE TABLE adh.updm_match_table query in Ads Data Hub instead of a connection. For example, an email hash that isn't 44 characters long, such as a hex-encoded one, fails the query with an error such as email must be encoded using TO_BASE64(SHA256(email)).
  • Check your match rate. For example, use the Calculate match rate query. Connections doesn't report values that can't match; you get fewer matched users. If 1,000 users or fewer match, the run fails with Minimum match count check failed.
  • Use only one UPDM connection per account. UPDM connections have no destination table. Every UPDM connection in an account, and every Private Cloud Match query, writes the same match table, and each successful run replaces it. To match data from several sources, combine it into one table or file first. An account can update its match table up to 10 times per day across all UPDM connections and Private Cloud Match queries.
  • Run the connection at least every 60 days. The matches from a run are deleted 60 days after the run. A failed run keeps the earlier matches. If the connection doesn't run successfully within 60 days, for example because its schedule is paused or its runs fail, your matches are deleted.
First-party data

For each column, choose a Type (Data Type on the connection details page). Connections converts each source value to that type, and the destination column gets the BigQuery type listed here:

Type Destination column Values it converts Values that become NULL
STRING (default) STRING Any value, as text. From BigQuery, 123 becomes "123" and TRUE becomes "true". From Cloud Storage, the text is kept as is. A BYTES value that isn't UTF-8 text
HASH STRING Same as STRING. Connections doesn't hash or check the value. Same as STRING
INTEGER INT64 Whole numbers, and number text such as "42". From BigQuery, a decimal is truncated: 1.9 becomes 1. Other values, such as "abc", TRUE, or a date. From Cloud Storage, also a decimal, such as 1.9.
DOUBLE FLOAT64 Numbers, and number text such as "1.5" Other values, such as TRUE or a date
DATE DATE DATE values, and year-month-day text such as 2026-01-15 or 2026-1-5 Other values, such as 01/15/2026, 20260115, or a TIMESTAMP or DATETIME value
TIMESTAMP TIMESTAMP TIMESTAMP, DATETIME, and DATE values, and text such as 2026-01-15 10:00:00 or 2026-01-15T10:00:00-08:00. A value without a time zone is read as UTC; a date becomes midnight UTC. Other values, such as a Unix epoch time (1768471200)
  • A value that can't be converted doesn't fail the run. It's imported as NULL, and Connections doesn't report it, so check the destination table after the first run.
  • Choose the type that fits your data. For a BigQuery source, choose the type that matches the source column: STRING for STRING, INTEGER for INT64, DOUBLE for FLOAT64, DATE for DATE, and TIMESTAMP for TIMESTAMP. These values are imported unchanged. For a Cloud Storage source, every CSV value is text: choose the type of the values in the column, such as INTEGER for 42 or DATE for 2026-01-15. If a column comes out NULL in every row, choose STRING, or convert the values in your source data first.
  • Some BigQuery types can't be mapped. If you map an ARRAY, STRUCT, JSON, or GEOGRAPHY column, you can't save the connection.
  • Each run replaces the whole destination table. It doesn't append. If the table doesn't exist yet in an existing dataset, the run creates it. If the source has no rows, the destination becomes empty. Don't use the source table, or a table whose data you need to keep, as the destination.
Moved connections

Transformations aren't available in the updated Connections experience: you can't add one to a field, and the field mappings don't show them. A connection that was moved to the updated Connections experience still keeps the transformations of its fields, such as compute hash (SHA-256 hashing).

  • In a first-party data connection, a field with a transformation gets the value that the transformation produces, instead of the Data Type conversion, and you can't change its Data Type (to remove the transformation and choose a Data Type, remove the field mapping and add it again). In a UPDM connection, the UPDM rules still apply to that value. Compute hash and lowercase or uppercase formatting need a STRING or BYTES source column, unless a conversion to a string comes first.
  • A UPDM field that used compute hash is still hashed by Connections. Keep its source values unhashed, but formatted as described in Format data for input: an already hashed value is hashed again and can't match. To hash the values yourself instead, remove the field mapping and add it again.
  • Only these transformations are moved:

    • Compute hash with SHA-256 (Base64 or hex), except on a UPDM user_id, country, or zip_code, which must stay plain text.
    • Lowercase or uppercase formatting.
    • Conversion to a string.
    • Timestamp parsing without a default time zone, on up to 10 fields of a connection.
    • Two of the first three in a row, such as lowercase formatting and then compute hash.

    A transformation is moved only if what it produces fits its field. For two in a row, what the second one produces counts: lowercase formatting and then compute hash fits email, but compute hash and then lowercase formatting doesn't.

    • In a UPDM connection, compute hash fits email, phone, first_name, and last_name. Lowercase or uppercase formatting and conversion to a string fit user_id, country, and zip_code. Timestamp parsing fits no field.
    • In a first-party data connection, compute hash fits a STRING or HASH column. Lowercase or uppercase formatting and conversion to a string fit a STRING column. Timestamp parsing fits a TIMESTAMP column.

    A connection with any other transformation, such as merging or splitting fields, or with a transformation that doesn't fit its field, isn't moved.

Cloud Storage CSV column requirements

  • Use one uncompressed, UTF-8 CSV file, with commas between values and no line breaks inside quoted values.
  • Include a header row. The first line is skipped; its column names aren't used.
  • The file must contain exactly the mapped source columns, no more and no fewer. Extra columns fail the run.
  • First-party data: Columns must be in the same order as the field mappings.
  • User-provided data matching: Columns must be in this order, keeping only the fields you map: user_id, email, phone, first_name, last_name, country, zip_code. The order of the mapping rows doesn't matter.
  • A different column order isn't detected: values load into the wrong fields (or match rates drop) without an error.
  • Map each CSV column only once, and give each field mapping a different Source column name. Unlike a BigQuery column, a CSV column can't be mapped to two destination columns, such as user_id and email.
  • In Source column, use only letters (A-Z, a-z), digits, and underscores, starting with a letter or underscore.

Supported data sources and connection limits

  • Data sources: Only BigQuery and Cloud Storage sources are supported.
  • BigQuery table names: Source and destination BigQuery tables need the full project.dataset.table name. Dataset and table names can contain only letters (A-Z, a-z), digits, and underscores. For example, a connection can't read from or write to a table named my-table.
  • Locations: Source and destination BigQuery datasets must be in the location of your Ads Data Hub account, such as US or EU (see Create a BigQuery dataset). For a Cloud Storage source, place the bucket in a location colocated with your account's location; see BigQuery's Cloud Storage location considerations.
  • Cloud Storage file paths: Provide a single file URI (such as gs://bucket/path/file.csv). Wildcard paths (* or ?) and folder paths (such as gs://bucket/folder/) aren't supported. A folder path isn't rejected when you save, but the files in the folder aren't read.
  • Connection names: Use a name of up to 150 characters that doesn't match another connection or a report in your account.

Format data for input

Your data must adhere to these formatting requirements to be correctly matched:

  • Where indicated in the following input field descriptions, you must upload using SHA256 hashing.
  • UPDM supports Base64 encoding. See TO_BASE64.
  • Input fields must be formatted as strings. For example, if you're using the BigQuery SHA256 hash function, use the following transformation: TO_BASE64(SHA256(user_data)).

User ID

  • Data type: BYTES
  • Hashing: None

Email

  • Remove leading and trailing whitespaces
  • Lowercase all characters
  • Include a domain name for all email addresses, such as gmail.com or hotmail.co.jp
  • Remove accents—for example, change è, é, ê, or ë to e
  • Remove all periods (.) that precede the domain name in gmail.com and googlemail.com email addresses
  • Hashing: Base64 encoded SHA256

Valid: TO_BASE64(SHA256("jeffersonloveshiking@gmail.com"))

Invalid: TO_BASE64(SHA256("JéffersonLôvesHiking@gmail.com"))

Phone

  • Strip whitespace
  • Format in E.164 format—for instance, US example: +14155552671, UK example: +442071838750
  • Remove all special characters except the "+" before the country code
  • Hashing: Base64 encoded SHA256

Valid: TO_BASE64(SHA256("+18005550101"))

Invalid: TO_BASE64(SHA256("(800) 555-0101"))

First name

  • Strip whitespace
  • Lowercase all characters
  • Remove all prefixes-for example Mrs., Mr., Ms., Dr.
  • Don't remove accents—for example, è, é, ê, or ë
  • Hashing: Base64 encoded SHA256

Valid: TO_BASE64(SHA256("daní"))

Invalid: TO_BASE64(SHA256("Daní"))

Last name

  • Strip whitespace
  • Lowercase all characters
  • Remove all suffixes-for example Jr., Sr., 2nd, 3rd, II, III, PHD, MD
  • Don't remove accents—for example, è, é, ê, or ë
  • Hashing: Base64 encoded SHA256

Valid: TO_BASE64(SHA256("délacruz"))

Invalid: TO_BASE64(SHA256("dé la Cruz, Jr."))

Country

  • Include the country code even if all of your customer data is from the same country
  • Don't hash country data
  • Use ISO 3166-1 alpha-2 country codes
  • Hashing: None

Valid: US

Invalid: United States of America or USA

Zip code

  • Don't hash zip code data
  • Both US and international zip and postal codes are allowed
  • Use only letters (A-Z, a-z), digits, spaces, and hyphens, up to 20 characters
  • For US:
    • 5 digit codes are allowed—for example, 94043
    • 5 digits followed by 4 digit extension are also allowed—for example, 94043-1351 or 940431351
  • For all other countries:
    • No need to convert to lowercase or to remove spaces and hyphens
    • Leave out postal code extensions
  • Hashing: None

Hash validation and data encoding

You can use the following hash validation scripts to ensure that your data is correctly formatted.

JavaScript

  /**
   * @fileoverview Provides the hashing algorithm, as well as some valid hashes of
   * sample data for testing.
  */

  async function hash(token) {
    // Removes leading or trailing spaces and converts all characters to lowercase.
    const formattedToken = token.trim().toLowerCase();
    // Hashes the formatted string using the SHA-256 hashing algorithm.
    const hashBuffer = await crypto.subtle.digest(
        'SHA-256', (new TextEncoder()).encode(formattedToken));
    // Converts the hash buffer to a base64-encoded string and returns it.
    const base64Str = btoa(String.fromCharCode(...new Uint8Array(hashBuffer)));
    return base64Str;
  }

  function main() {
    // Expected hash for test@gmail.com:
    // h5JGBrQTGorO7q6IaFMfu5cSqqB6XTp1aybOD11spnQ=
    hash('test@gmail.com').then(result => console.log(result));

    // Expected hash for +18005551212:
    // YdkRG+0+bZz8G8O1yzWkAmh8TxVGvuBhor1ET73WTEQ=
    hash('+18005551212').then(result => console.log(result));

    // Expected hash for John: ltljLzY1ZMwwMlIUCc8iqFLyAy7sCZ7VlnwNAAzsYHo=
    hash('John').then(result => console.log(result));

    // Expected hash for Doe: eZ75KhGvkY4/t0HfQpNPO1aO0tk6wd908bjUGieTKm8=
    hash('Doe').then(result => console.log(result));
  }

  main()

Python

  """Provides the hashing algorithm, as well as some valid hashes of sample data for testing.

  Supports: Python 2, Python 3

  Sample hashes:

    - Email 'test@gmail.com': h5JGBrQTGorO7q6IaFMfu5cSqqB6XTp1aybOD11spnQ=
    - Phone '+18005551212':   YdkRG+0+bZz8G8O1yzWkAmh8TxVGvuBhor1ET73WTEQ=
    - First name 'John':      ltljLzY1ZMwwMlIUCc8iqFLyAy7sCZ7VlnwNAAzsYHo=
    - Last name 'Doe':        eZ75KhGvkY4/t0HfQpNPO1aO0tk6wd908bjUGieTKm8=
  """

  import base64
  import hashlib

  def hash(token):
  # Generates a base64-encoded SHA-256 hash of a normalized input string.
    return base64.b64encode(
        hashlib.sha256(
            token.strip().lower().encode('utf-8')).digest()).decode('utf-8')

  def print_hash(token, expected=None):
  # Computes and displays the hash of a token, with optional validation.
    hashed = hash(token)

    if expected is not None and hashed != expected:
      print(
          'ERROR: Incorrect hash for token "{}". Expected "{}", got "{}"'.format(
              token, expected, hashed))
      return

    print('Hash: "{}"\t(Token: {})'.format(hashed, token))

  def main():
  # Tests the hash function with sample tokens and expected results.
    print_hash(
        'test@gmail.com', expected='h5JGBrQTGorO7q6IaFMfu5cSqqB6XTp1aybOD11spnQ=')
    print_hash(
        '+18005551212', expected='YdkRG+0+bZz8G8O1yzWkAmh8TxVGvuBhor1ET73WTEQ=')
    print_hash('John', expected='ltljLzY1ZMwwMlIUCc8iqFLyAy7sCZ7VlnwNAAzsYHo=')
    print_hash('Doe', expected='eZ75KhGvkY4/t0HfQpNPO1aO0tk6wd908bjUGieTKm8=')

  if __name__ == '__main__':
    main()

Go

  /*
  Provides the hashing algorithm, as well as some valid hashes of sample data for testing.

  Sample hashes:

    - Email 'test@gmail.com': h5JGBrQTGorO7q6IaFMfu5cSqqB6XTp1aybOD11spnQ=
    - Phone '+18005551212':   YdkRG+0+bZz8G8O1yzWkAmh8TxVGvuBhor1ET73WTEQ=
    - First name 'John':      ltljLzY1ZMwwMlIUCc8iqFLyAy7sCZ7VlnwNAAzsYHo=
    - Last name 'Doe':        eZ75KhGvkY4/t0HfQpNPO1aO0tk6wd908bjUGieTKm8=
  */
  package main

  import (
    "crypto/sha256"
    "encoding/base64"
    "fmt"
    "strings"
  )

  // Hash hashes an email, phone, first name, or last name into the correct format.
  func Hash(token string) string {
    formatted := strings.TrimSpace(strings.ToLower(token))
    hashed := sha256.Sum256([]byte(formatted))
    encoded := base64.StdEncoding.EncodeToString(hashed[:])
    return encoded
  }

  // PrintHash prints the hash for a token.
  func PrintHash(token string) {
    fmt.Printf("Hash: \"%s\"\t(Token: %s)\n", Hash(token), token)

  }

  func main() {
    PrintHash("test@gmail.com")
    PrintHash("+18005551212")
    PrintHash("John")
    PrintHash("Doe")
  }

Java

  package updm.hashing;

  import static java.nio.charset.StandardCharsets.UTF_8;

  import java.security.MessageDigest;
  import java.security.NoSuchAlgorithmException;
  import java.util.Base64;

  /**
  * Example of the hashing algorithm.
  *
  * <p>Sample hashes:
  *
  * <ul>
  *   <li>Email 'test@gmail.com': h5JGBrQTGorO7q6IaFMfu5cSqqB6XTp1aybOD11spnQ=
  *   <li>Phone '+18005551212': YdkRG+0+bZz8G8O1yzWkAmh8TxVGvuBhor1ET73WTEQ=
  *   <li>First name 'John': ltljLzY1ZMwwMlIUCc8iqFLyAy7sCZ7VlnwNAAzsYHo=
  *   <li>Last name 'Doe': eZ75KhGvkY4/t0HfQpNPO1aO0tk6wd908bjUGieTKm8=
  * </ul>
  */
  public final class HashExample {

  private HashExample() {}

  public static String hash(String token) {
    // Normalizes and hashes the input token using SHA-256 and Base64 encoding.
    String formattedToken = token.toLowerCase().strip();

    byte[] hash;
    try {
      hash = MessageDigest.getInstance("SHA-256").digest(formattedToken.getBytes(UTF_8));
    } catch (NoSuchAlgorithmException e) {
      throw new IllegalStateException("SHA-256 not supported", e);
    }

    return Base64.getEncoder().encodeToString(hash);
  }

  public static void printHash(String token) {
    // Calculates and prints the hash for the given token.
    System.out.printf("Hash: \"%s\"\t(Token: %s)\n", hash(token), token);
  }

  public static void main(String[] args) {
    // Executes hash calculations and prints results for sample tokens.
    printHash("test@gmail.com");
    printHash("+18005551212");
    printHash("John");
    printHash("Doe");
  }
  }

SQL

  /*
  Provides the hashing algorithm, as well as some valid hashes of sample data for testing.

  The following code uses Google Standard SQL and can be run on BigQuery to generate match tables from unhashed data.

  Sample hashes:

    - Email 'test@gmail.com': h5JGBrQTGorO7q6IaFMfu5cSqqB6XTp1aybOD11spnQ=
    - Phone '+18005551212':   YdkRG+0+bZz8G8O1yzWkAmh8TxVGvuBhor1ET73WTEQ=
    - First name 'John':      ltljLzY1ZMwwMlIUCc8iqFLyAy7sCZ7VlnwNAAzsYHo=
    - Last name 'Doe':        eZ75KhGvkY4/t0HfQpNPO1aO0tk6wd908bjUGieTKm8=

  The unhashed input table schema is assumed to be:

  - Column name: UserID, Type: String
  - Column name: Email, Type: String
  - Column name: Phone, Type: String
  - Column name: FirstName, Type: String
  - Column name: LastName, Type: String
  - Column name: PostalCode, Type: String
  - Column name: CountryCode, Type: String
  */

  -- Creates a new table with Base64-encoded SHA-256 hashes of specified columns.
  CREATE TABLE `your_project_name.your_dataset_name.output_hashed_table_name`
  AS
  SELECT
    UserID,
    TO_BASE64(SHA256(LOWER(Email))) AS Email,
    TO_BASE64(SHA256(Phone)) AS Phone,
    TO_BASE64(SHA256(LOWER(FirstName))) AS FirstName,
    TO_BASE64(SHA256(LOWER(LastName))) AS LastName,
    PostalCode,
    CountryCode,
  FROM
    `your_project_name.your_dataset_name.input_unhashed_table_name`;

Join keys

Some combinations of user-provided data are stronger than others. Following is a list of different user-provided data combinations, ranked by relative strength. If you use an address, you must include: First name, Last name, Country, and Zip code.

  1. Email, Phone, Address (strongest)
  2. Phone, Address
  3. Email, Address
  4. Email, Phone
  5. Address
  6. Phone
  7. Email (weakest)

Create a match table

  1. Click Connections > Create connection > User-provided data matching.
  2. Choose a data source, then click Connect.
  3. Authenticate, if prompted, then click Next:

    BigQuery

    Click Apply to grant access to BigQuery.

    Cloud Storage

    Click Apply to grant access to Cloud Storage.

    MySQL

    Enter your MySQL database location, port, username, and password.

    S3

    Enter your Amazon S3 secret access key.

    PostgreSQL

    Enter your PostgreSQL database location, port, username, password, and database.

    Redshift

    Enter your Redshift database location, port, username, password, and database.

    sFTP

    Enter your sFTP server location, username, and password.

    Snowflake

    Enter your Snowflake account identifier, username, and password.

  4. Configure your data source, then click Next:

    BigQuery

    Select the BigQuery table to import.

    Cloud Storage

    Enter the gsutil path, such as gs://my-bucket/folder/ and select your file's formatting.

    If this is the first time you have connected this resource, an alert appears. Click Apply to grant access, then click Next. Note: you must have a role with permission to delegate storage.buckets.setIamPolicy for the relevant bucket.

    MySQL

    Select the MySQL database and table that you want to use.

    S3

    Enter the URI to the file you want to upload, relative to the host address.

    PostgreSQL

    Enter the PostgreSQL schema and table (or view) name.

    Redshift

    Enter the Redshift schema and table (or view) name. By default, Redshift uses database location URLs that follow this template: cluster-identifier.account-number.aws-region.redshift.amazonaws.com .

    sFTP

    Enter the file path and name, formatted as /PATH/FILENAME.csv

    Snowflake

    Enter the Snowflake database, schema, and table (or view) that you want to use.

  5. Select a BigQuery dataset to use as an intermediary destination, then click Next. This step ensures that your data is correctly formatted.
  6. Optional: Modify the format of your data. Transformations include compute hash, lower/upper case formatting, and merging/splitting fields.
    1. Click Action > > Transform.
    2. In the panel that pops up, click Add transformation or Add another transformation
    3. Choose a transformation type from the dropdown menu and enter the requirements.
    4. Click Save.
  7. Choose at least one join key and map the fields you will use. Ads Data Hub will automatically map fields with identical names, indicated by a . Make any necessary edits, then click Next.
  8. Set a schedule:
    1. Name your connection.
    2. Set a frequency, dictating how often data will be imported into the dataset that you selected in the previous step. Each run will overwrite data in the destination table.
    3. Specify how you'd like user ID collisions to be handled. You can choose between keeping the existing match or overwriting with new data.
  9. Click Finish. Match tables are generally ready to be queried 12 hours after they are created.

View connection details

The connection details page gives you information on a given connection's recent runs and errors. To view details for a specific connection:

  1. Click Connections.
  2. Click the name of the connection to view its details.
  3. You can now see the connection's details and recent runs. Each shows two possible types of errors: connection-level (the connection didn't run) and row-level errors (a row wasn't imported).
    1. A Failed status indicates that the entire connection failed to run (e.g. service account permission issue). Click on the error status to see which errors impacted the connection.
    2. A Completed status indicates that the connection ran successfully. However, there may still be row-level errors—indicated by a non-zero value in the "Rows with errors" column. Click the value to learn more about which records failed.

Edit a connection

The following details can be edited:

  • Connection name
  • Schedule
  • Destination table
  • Field mapping

Editing data source isn't supported. To change a data source, create a new connection and delete the old one.

To edit connection details:

  1. Click Connections.
  2. Click the name of the connection you want to edit.
  3. Edit the details you want to change:
    • Connection name: Click Edit, enter the new name, then press Enter.
    • Schedule: Click Edit, set the new schedule, then click Save.
    • Destination table: Click Edit, enter the new destination name, then click Save.
    • Field mapping: Click , make changes to fields, then click Save.
  4. Click .

Migrate existing connections

Existing connections in the Connections tab are moving to an updated Connections experience built directly into Ads Data Hub. Updated connections read sources and write destinations using the service account shown under Settings > Details > Service account (usually service-<number>@gcp-sa-adsdatahub.iam.gserviceaccount.com) instead of the legacy Data Fusion, Dataproc, and UPDM service accounts.

Complete these action items before your connections are moved:

  1. Grant service account permissions: Grant the service account shown under Settings > Details > Service account (usually service-<number>@gcp-sa-adsdatahub.iam.gserviceaccount.com) the required source and destination roles (roles/bigquery.dataViewer, roles/storage.objectViewer, and roles/bigquery.dataEditor on non-default destination datasets). Connections with unreadable, deleted, or changed sources may still be moved (especially Cloud Storage sources, which aren't validated at move time), but runs fail until you grant access or fix the source.
  2. Grant the Analyst role to Link managers: Users who only have the Link manager role can't view or manage connections after the move. Ask a Superuser to also add them with the Analyst role (see Assign access by role).
  3. Convert unsupported connections: Connections with the following configurations won't be migrated. Convert them to supported BigQuery or Cloud Storage connections:

    • Other data sources (Amazon S3, Snowflake, MySQL, PostgreSQL, Amazon Redshift, sFTP, or Salesforce): Stage the data in BigQuery or Cloud Storage first, then create a BigQuery or Cloud Storage connection.
    • Unsupported field mappings or data types: Update or recreate the connection to meet the field and data type requirements.
    • Unsupported transformations: Only the transformations listed in Moved connections are moved. Remove any other transformation, such as merging or splitting fields, and do that work in your source data instead.
    • Cloud Storage wildcard paths (* or ?): Replace the wildcard URI with a single file URI or load the files into BigQuery first.
    • BigQuery dataset or table names with characters other than letters, digits, and underscores, such as a hyphen: Use source and destination tables with supported names. This also applies to the destination table that a legacy user-provided data matching connection writes.
    • Names already used or longer than 150 characters: Rename the connection if its name is longer than 150 characters, or if a report, or a connection created in the updated Connections experience, already has the same name in your account.

    Existing connections that share a name with each other are still migrated: the oldest one keeps the name, and the others get a suffix, such as (2) or (3). The name with its suffix must also be 150 characters or fewer and not already in use.

  4. Check Cloud Storage paths and CSV files: A Cloud Storage folder path (such as gs://bucket/folder/) isn't rejected, but the files in the folder aren't read. Replace the folder URI with a single file URI, or load the files into BigQuery first. In the updated Connections experience, Cloud Storage CSV files are read by column position, not by header name, and must contain only the mapped columns. Make sure your files and mapped Source column names meet the Cloud Storage CSV column requirements (for UPDM, remove every column that isn't mapped to one of the 7 supported fields).

  5. Delete unused connections: Delete obsolete connections you no longer need.

After a connection is moved:

  • A user-provided data matching connection keeps only the user_id, email, phone, first_name, last_name, country, and zip_code mappings. Other columns that it mapped aren't moved, and the BigQuery destination table that it wrote is no longer updated. If your queries read that table, read your source data instead. For a Cloud Storage source, load the file into a BigQuery table first.
  • If you have more than one user-provided data matching connection, each successful run replaces the matches of the others. Combine their data into one source and keep one connection. See User-provided data matching (UPDM).
  • The connection keeps its schedule and, except as described here, its field mappings. It doesn't keep its run history.

Query matched data

Query the match tables

When your match tables contain enough data to satisfy privacy checks, you're ready to run queries against the tables.

The original table for first-party data (1PD) is represented by my_data. This includes both Personally Identifiable Information (PII) and non-PII data. Using the original table can improve your reports with more insights, as it represents all the 1PD data in scope, when compared to a match table.

Each table in the Ads Data Hub schema containing a user_id field is accompanied by a match table. For example, for the adh.google_ads_impressions table, Ads Data Hub also generates a match table called adh.google_ads_impressions_updm containing your user IDs. Separate match tables are created for policy-isolated network tables. For example, for the adh.google_ads_impressions_policy_isolated_network table, Ads Data Hub also generates a match table called adh.google_ads_impressions_policy_isolated_network_updm containing your user IDs.

These tables contain a subset of the users available in the original tables, where there is a match on the user_id. For example, if the original table contains data for User A and User B, but only User A is matched, then User B won't be in the match table.

The match tables contain an additional column called customer_data_user_id, which stores the user identifier as BYTES.

It's important to consider the field's type when writing your queries. SQL comparison operators expect that the literals you're comparing are of the same type. Depending on how the user_id is stored in your table of first-party data, you may need to encode the values in the table before matching the data. You need to cast your join key into BYTES for successful matches:

JOIN ON
  adh.google_ads_impressions_updm.customer_data_user_id = CAST(my_data.user_id AS BYTES)

Additionally, string comparisons in SQL are sensitive to capitalization, so you may need to encode strings on both sides of your comparison to ensure that they can be accurately compared.

Sample queries

Count matched users

This query counts the number of matched users in your Google Ads impressions table.

/* Count matched users in Google Ads impressions table */

SELECT COUNT(DISTINCT user_id)
FROM adh.google_ads_impressions_updm

Calculate match rate

Not all users are eligible for matching. For example, signed-out users, children, and unconsented users are not matched through UPDM. You can use the is_updm_eligible field to calculate more accurate UPDM match rates. Note that the is_updm_eligible field was available beginning on October 1, 2024. You cannot use this field to calculate match rates before that date.

/* Calculate the UPDM match rate */

CREATE TEMP TABLE total_events OPTIONS(privacy_checked_export=TRUE) AS
SELECT
  customer_id,
  COUNT(*) AS n
FROM adh.google_ads_impressions
WHERE is_updm_eligible
GROUP BY 1;

CREATE TEMP TABLE matched_events OPTIONS(privacy_checked_export=TRUE) AS
SELECT
  customer_id,
  COUNT(*) AS n
FROM adh.google_ads_impressions_updm
GROUP BY 1;

SELECT
  customer_id,
  SAFE_DIVIDE(matched_events.n, total_events.n) AS match_rate
FROM total_events
LEFT JOIN matched_events
  USING (customer_id)

Join first-party and Google Ads data

This query shows how to join first-party data with Google Ads data:

/* Join first-party data with Google Ads data. The customer_data_user_id field
contains your ID as BYTES. You need to cast your join key into BYTES for
successful matches. */

SELECT
  inventory_type,
  COUNT(*) AS impressions
FROM
  adh.yt_reserve_impressions_updm AS google_data_imp
LEFT JOIN
  `my_data`
ON
  google_data_imp.customer_data_user_id = CAST(my_data.user_id AS BYTES)
GROUP BY
  inventory_type

UPDM FAQs

For a list of FAQs related to UPDM, see UPDM FAQs.