UID2 Implementation Guide for Google Ad Manager
A publisher running 50 million monthly ad impressions drops third-party cookie coverage from 100% to zero on Safari and Firefox, while Chrome privacy changes continue to decay unauthenticated addressability. Without an explicit identity strategy, DSPs bid on your inventory as unaddressed traffic, collapsing programmatic eCPMs by 30% to 60% on non-cookie impressions. Addressable inventory commands higher yield because buyers can apply frequency capping, cross-site attribution, and first-party audience targeting.
Unified ID 2.0 (UID2)—an open-source identity framework initiated by The Trade Desk and governed by IAB Tech Lab—replaces third-party cookies with encrypted, privacy-conscious identifiers derived from normalized, hashed email addresses (or phone numbers). When implemented inside Google Ad Manager (GAM), UID2 exposes a deterministic identifier to buyer demand via OpenRTB bid streams and Google Secure Signals (formerly Encrypted Signals API).
This technical guide details the architectural pathways, code implementations, verification procedures, and troubleshooting steps necessary to deploy UID2 across your GAM stack.
What Architecture Drives UID2 Integration in Google Ad Manager?
Google Ad Manager does not natively capture raw user credentials to mint UID2 tokens. Instead, the publisher front-end or server-side architecture captures authenticated user data, requests an encrypted UID2 token from a UID2 Operator, and passes that payload into GAM. GAM then forwards the payload to demand partners inside the ad auction.
You can integrate UID2 into GAM using three primary technical routes:
- Google Publisher Tag (GPT) Secure Signals API: Direct browser-side integration where the client script retrieves a UID2 payload and registers a signal provider with GAM via
googletag.secureSignals. GAM automatically passes the encrypted token to participating Google Demand and authorized programmatic buyers. - Prebid.js User ID Module: Prebid's standard
uid2sub-module fetches, stores, and refreshes tokens via the UID2 client SDK, attaching the resultingeidsobject directly to bid requests sent to header bidding SSPs. - Server-Side Integration (Node.js/Python/Go): The publisher web server generates and decrypts UID2 tokens using official SDKs, passing the advertising token to the front end. This model conceals API secrets and eliminates browser-side hashing overhead.
| Integration Method | Primary Use Case | Latency Impact | Implementation Complexity | Supported Demand Channels |
|---|---|---|---|---|
How Do You Pass UID2 Tokens Into GAM via Secure Signals?
Google Secure Signals acts as an encrypted transport mechanism within GPT. It allows publishers to collect encrypted user identifiers client-side and pass them securely to demand partners without allowing GAM or third parties to read the underlying identity payload.
To pass UID2 tokens through Secure Signals, you must register a custom signal provider script or use the official UID2 Secure Signals integration library provided by The Trade Desk.
The standard browser workflow follows this execution path:
- The user authenticates (e.g., email login) on your site.
- The front end normalizes the email (lowercase, trim whitespace) and hashes it using SHA-256, or sends raw credentials over HTTPS to your server.
- The UID2 client SDK sends the hashed email to a UID2 Operator endpoint, returning an Advertising Token, a Refresh Token, and an expiration timestamp.
- The application stores the encrypted UID2 Advertising Token in local storage or first-party cookies.
- GPT loads on the page and invokes the registered Secure Signals callback.
- The provider resolves the promise with the active UID2 Advertising Token string, which GPT appends to ad requests.
If you encounter broken script variables during credential capture, follow the steps for fixing undefined data layer variables to keep email strings clean before hashing.
Step-by-Step: How to Configure UID2 with Prebid.js and GPT
Combining Prebid.js and GPT Secure Signals gives publishers 100% demand coverage across header bidding SSPs and Google Exchange buyers. Follow these steps to build a complete deployment.
Step 1: Obtain Credentials and Define Your Operator Strategy
Register for a UID2 account through The Trade Desk or a participating administrator (such as LiveRamp). You will receive:
API Key: Used for authentication against the UID2 Operator.Client Secret: Required if you perform server-side token generation.Operator URL: The standard public operator domain or a private operator instance endpoint.
Step 2: Collect and Hash First-Party Credentials
When a user submits an email address on your site, normalize and format the string. Remove all leading and trailing whitespace, convert all characters to lowercase, and compute a SHA-256 hash output in hexadecimal format.
Example client-side JavaScript for normalization and SHA-256 hashing:
async function hashEmail(email) {
const normalized = email.trim().toLowerCase();
const encoder = new TextEncoder();
const data = encoder.encode(normalized);
const hashBuffer = await crypto.subtle.digest('SHA-256', data);
const hashArray = Array.from(new Uint8Array(hashBuffer));
return hashArray.map(b => b.toString(16).padStart(2, '0')).join('');
}
Step 3: Implement Prebid.js User ID Module Setup
Ensure your Prebid.js build includes both userId core module and the uid2Submodule. Add the UID2 configuration block into your pbjs.setConfig call:
pbjs.setConfig({
userSync: {
auctionDelay: 50,
userIds: [{
name: 'uid2',
params: {
// Option A: Pass normalized email directly if client SDK handles generation
emailHash: 'e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855',
// Option B: Point to your internal API endpoint that returns the token payload
apiBaseUrl: 'https://operator.realtime.com',
},
storage: {
type: 'html5',
name: 'uid2_advertising_token',
expires: 30
}
}]
}
});
Step 4: Enable GAM Secure Signals Integration
Inside your Google Publisher Tag setup, register the secure signal callback before issuing googletag.display() calls. If you use the standalone UID2 SDK (uid2-sdk-js), initialize the SDK instance and connect its signal promise to GPT:
window.googletag = window.googletag || { cmd: [] };
googletag.cmd.push(function() {
googletag.secureSignals = googletag.secureSignals || [];
googletag.secureSignals.pushProvider({
id: 'uidapi.com', // Recognized signal provider ID for UID2
getSignal: function() {
return new Promise((resolve) => {
if (window.__uid2 && window.__uid2.isInitialized()) {
const advertisingToken = window.__uid2.getAdvertisingToken();
resolve(advertisingToken || "");
} else {
resolve("");
}
});
}
});
});
When configured correctly, GAM grabs the string returned by getSignal(), packages it inside an encrypted protocol buffer, and passes it into the programmatic auction stream.
Step 5: Bind Privacy Management and CMP Controls
UID2 respects global privacy preferences. In jurisdictions governed by GDPR or US state privacy laws (CCPA/CPRA), token generation must respect consent strings passed by your Consent Management Platform (CMP).
Ensure your implementation checks TCF v2.2 consent signals. The UID2 JavaScript SDK handles TCF signals automatically if an IAB-compliant CMP is present on the page, halting token refresh operations if explicit consent for Purpose 1 (Store/access information on device) is missing.
If your monetization stack suffers from missing consent signals across advertising tags, review our guide on configuring Google Consent Mode v2 signals to prevent tag blocking and programmatic revenue drop-offs.
How Do You Verify UID2 Token Delivery in Ad Server Logs and Bids?
Deploying code without validating packet flow leads to undetected identity leaks. You must verify token generation, storage persistence, and signal transmission inside the ad server call.
1. Inspect Local Storage and Cookies
Open Chrome DevTools > Application > Local Storage. Confirm that the storage key (e.g., __uid2_advertising_token or your configured Prebid storage key) contains a JSON object with four critical parameters:
advertising_token: The base64-encoded encrypted string sent to DSPs.refresh_token: The authorization token used to mint fresh advertising tokens.identity_expires: Epoch timestamp indicating token invalidation.refresh_from: Timestamp instructing the client SDK when to attempt background refresh.
2. Audit Prebid Bid Stream Payload
Execute pbjs.getUserIds() in the browser console. The object returned must include a uid2 key mapping to the raw advertising token string:
{
"uid2": "AgAAAAT8V...[truncated_token_string]..."
}
Inspect outgoing bid requests sent to header bidding partners in the Network tab (filter by partner domain, e.g., Rubicon, Magnite, or Index Exchange). Expand the request payload to verify the user.ext.eids array contains the UID2 structure:
{
"user": {
"ext": {
"eids": [
{
"source": "uidapi.com",
"uids": [
{
"id": "AgAAAAT8V...",
"atype": 1
}
]
}
]
}
}
}
3. Validate GAM Network Requests
Filter Network requests for gampad/ads. Inspect the query string parameters of the Google ad request. Look for the encrypted signal parameter (typically passed in the encrypted_hyperlocal or extension binary payload inside encrypted signals parameters).
Use the official Google Publisher Console (append ?googfc to your website URL) to inspect active Secure Signals providers on the page. Confirm that uidapi.com reports a status of "Signal successfully retrieved."
What Troubleshooting Steps Fix Common Token Refresh and Match Discrepancies?
Deploying identity solutions introduces edge cases across authentication flows, token expiration, and cross-device sessions. Addressing these issues systematically protects inventory coverage.
Handling Unauthenticated Traffic Gracefully
Only authenticated users yield UID2 tokens. For unauthenticated pageviews, the UID2 SDK returns a status code of OPTOUT or EXPIRED. Ensure your ad server implementation falls back cleanly to alternative identity solutions (such as Publisher Provided IDs or contextual targeting modules) rather than firing empty network requests or throwing unhandled JavaScript exceptions.
Fixing Token Expiry and Background Refresh Failures
UID2 advertising tokens carry an explicit lifespan (typically 60 minutes). If a user leaves a tab open for hours, the token expires. If the background refresh cycle fails due to network failures or invalid refresh tokens, bid requests send invalid tokens that DSPs instantly drop.
To resolve background refresh drop-offs:
- Initialize the UID2 SDK at the top of the head tag to start token verification before header bidding auctions execute.
- Set an appropriate
auctionDelay(50ms–100ms) inside Prebid.js to allow token refresh completion on slow connections. - Monitor your server logs for HTTP 400 responses from the UID2 Operator endpoint, which signals an expired secret or malformed payload.
Resolving Identity Discrepancies Across Platforms
Discrepancies often emerge when comparing CRM user counts against addressable ad requests inside your ad server logs or warehouse integrations. If you observe identity drops, check your database for inconsistent email formatting (e.g., uppercase letters or trailing spaces) applied prior to SHA-256 calculation.
If you sync identity layers into external analytics warehouses like Google BigQuery, consult our guide on reconciling cross-device identity discrepancies to align database identifiers with front-end ad tokens.
Audit Your Setup for Production Readiness
To confirm your Google Ad Manager UID2 setup is ready for production traffic, complete this checklist:
- Verify that your site normalizes and hashes emails (lowercased, trimmed, SHA-256) before sending requests to the UID2 Operator.
- Confirm that
googletag.secureSignals.pushProviderexecutes with IDuidapi.comprior to initial ad calls. - Check that Prebid.js exports the
eidsobject withsource: "uidapi.com"to all active header bidding adapters. - Validate CMP integration by testing token blocking when user consent for Purpose 1 is explicitly denied.
- Run real-time ad request traces using Chrome DevTools and Google Publisher Console to confirm zero console errors during execution.
Frequently Asked Questions
Does Google Ad Manager charge extra fees for using Secure Signals with UID2?
No. Google Ad Manager does not charge an additional fee for passing encrypted signals via the Secure Signals API. However, monetization yields and server request costs depend on your programmatic deal structures and infrastructure configuration.
Can UID2 tokens be read by Google or third-party web scrapers in cleartext?
No. UID2 advertising tokens are double-encrypted strings generated by the UID2 Operator. GAM transports the token as an encrypted string, and only DSPs holding the master decryption keys can resolve the token back to a raw identity hash for bidding.
What happens to UID2 if a user opts out through the UID2 central portal?
When a user opts out via the public UID2 portal, the UID2 Operator revokes the token during the next client SDK refresh cycle. The client SDK clears the local storage payload, stopping any further transmission of advertising tokens for that hashed identifier.
Is client-side email hashing as secure as server-side UID2 token generation?
Server-side token generation is strictly more secure because your private API key remains hidden on your application server. Client-side hashing relies on public client keys and sends raw hashes over browser APIs, making server-side generation the preferred choice for enterprise architectures.