This folder contains sample integrations using Prebid.js with the UID2/EUID User ID module. Prebid.js manages token storage, refresh, and inclusion in bid requests.
When using Prebid.js for UID2/EUID integration, Prebid handles the entire token workflow:
- Token Generation — Either client-side (CSTG) or via server-provided token
- Token Storage — Stored in localStorage under
__uid2_advertising_tokenor__euid_advertising_token - Token Refresh — Prebid automatically refreshes tokens before expiration
- Bid Requests — Token is automatically included in bid requests via the User ID module
Prebid generates the token directly from an email address:
pbjs.setConfig({
userSync: {
userIds: [{
name: 'uid2', // or 'euid'
params: {
email: userEmail,
subscriptionId: 'your-sub-id',
serverPublicKey: 'your-public-key'
}
}]
}
});Server provides the initial token, but CSTG credentials are still required for Prebid to refresh it:
pbjs.setConfig({
userSync: {
userIds: [{
name: 'uid2', // or 'euid'
params: {
uid2Token: tokenFromServer, // Initial token from server
subscriptionId: 'your-sub-id', // Required for refresh
serverPublicKey: 'your-public-key' // Required for refresh
}
}]
}
});EUID Note: If using EUID, you must configure consent management for GDPR compliance. See the EUID Permissions documentation.
| Folder | Description | Port |
|---|---|---|
client-side/ |
Prebid.js handles all token management client-side using CSTG | 3051 |
client-server/ |
Server generates initial token, Prebid.js manages refresh | 3052 |
client-side-deferred/ |
Add UID2/EUID module to existing Prebid config using mergeConfig() |
3053 |
- UID2: Client-Side Guide | Client-Server Guide | Deferred Configuration
- EUID: Client-Side Guide | Client-Server Guide | Deferred Configuration
The prebid.js file in this folder is a custom Prebid.js build (v10.15.0) that includes:
All integrations in this folder require common variables plus integration-specific ones. See the individual README for each integration for the complete list of required variables.
| Variable | Description |
|---|---|
IDENTITY_NAME |
Display name for the UI (UID2 or EUID) |
UID_STORAGE_KEY |
localStorage key for Prebid token storage |
DOCS_BASE_URL |
Used for UI links to public documentation (https://unifiedid.com/docs or https://euid.eu/docs) |
| Variable | Description |
|---|---|
UID_CLIENT_BASE_URL |
API base URL for client-side calls |
UID_CSTG_SUBSCRIPTION_ID |
Your subscription ID for CSTG |
UID_CSTG_SERVER_PUBLIC_KEY |
Your server public key for CSTG |
| Variable | Description |
|---|---|
UID_SERVER_BASE_URL |
API base URL for server-side calls |
UID_API_KEY |
Your API key for server-side token generation |
UID_CLIENT_SECRET |
Your client secret for server-side token generation |
Open browser console (F12) and run:
pbjs.getConfig('userSync')// For UID2
pbjs.refreshUserIds({ submoduleNames: ['uid2'] })
// For EUID
pbjs.refreshUserIds({ submoduleNames: ['euid'] })docker compose logs prebid-client
docker compose logs prebid-client-server
docker compose logs prebid-client-side-deferreddocker compose up -d --build SERVICE_NAME| Issue | Possible Cause | Solution |
|---|---|---|
pbjs.getUserIds() returns empty |
Module not configured | Check Prebid config in page source |
| "Invalid subscription ID" | Wrong credentials | Verify credentials match operator URL |
| Token not in bid requests | Token not generated yet | Wait for pbjs.refreshUserIds() to complete |
| Module not loading | Prebid build missing module | Use the provided prebid.js build |
- Verify your
UID_API_KEYandUID_CLIENT_SECRETare correct - Ensure your API key has the GENERATOR role
- Check that credentials match your environment (local vs. integration)
- For EUID, ensure your operator's
identity_scopeis set to"euid"and you're usingEUID-C-keys
For local operator:
- Verify the operator is running at
localhost:8080 - Check
enable_v2_encryption: trueis set in the operator's config - Review operator logs for errors
- Ensure
identity_scopematches your credentials (e.g.,"uid2"or"euid")
For Docker:
- Ensure
UID_SERVER_BASE_URLuseshost.docker.internal:8080notlocalhost:8080
Run pbjs.getUserIds() in console. If empty or missing uid2/euid:
- Check console for Prebid errors
- Verify Prebid.js loaded correctly (check Network tab)
- Ensure
pbjs.setConfig()is being called after token generation - Check the browser console for "Configuring Prebid.js with..." message to confirm configuration
- Check that
IDENTITY_NAMEmatches the expected identity type (UID2 or EUID)