This folder contains sample integrations using the UID2/EUID JavaScript SDK directly, without Prebid.js or Google Secure Signals.
The JavaScript SDK provides a straightforward way to manage UID2/EUID tokens:
- Token Generation — Either client-side (CSTG) or via server-provided token
- Token Storage — Stored in localStorage or first-party cookie
- Token Refresh — SDK automatically refreshes tokens before expiration
- Callbacks — SDK notifies your code when token state changes
// Initialize with server-generated token (client-server)
__uid2.init({ identity: tokenFromServer });
// OR generate token client-side (CSTG)
__uid2.setIdentityFromEmail(email, {
subscriptionId: 'your-sub-id',
serverPublicKey: 'your-public-key'
});
// Get current advertising token
__uid2.getAdvertisingToken();
// Check if login is needed
__uid2.isLoginRequired();
// Clear identity (logout)
__uid2.disconnect();| Type | Token Generation | Use Case |
|---|---|---|
| Client-Side | SDK uses CSTG | Simple setup, all client-side |
| Client-Server | Server generates, SDK refreshes | More control, server-side validation |
| Folder | Description | Port |
|---|---|---|
client-side/ |
Client-side token generation using CSTG | 3031 |
client-server/ |
Server generates initial token, client SDK manages refresh | 3032 |
react-client-side/ |
React implementation of client-side token generation | 3034 |
- UID2: Client-Side Guide | Client-Server Guide | SDK Reference
- EUID: Client-Side Guide | Client-Server Guide | SDK Reference
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) |
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 |
UID_JS_SDK_URL |
URL to the JavaScript SDK |
UID_JS_SDK_NAME |
Global variable name (__uid2 or __euid) |
React Note: For the React example (
react-client-side/), all client-side variables must be prefixed withREACT_APP_(e.g.,REACT_APP_UID_CLIENT_BASE_URL). See the React README for the complete list.
| 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 |
docker compose config# Replace SERVICE_NAME with the specific service
docker compose logs javascript-sdk-client-side
docker compose logs javascript-sdk-client-server
docker compose logs javascript-sdk-react-client-sidedocker compose up -d --build SERVICE_NAMEOpen Developer Tools (F12) and check:
- Console: Look for SDK initialization messages and errors
- Application > Local Storage: Check for
__uid2_advertising_tokenor__euid_advertising_token - Network: Monitor API calls to the operator endpoint
| Issue | Possible Cause | Solution |
|---|---|---|
| "Invalid subscription ID" | Wrong credentials for the environment | Verify credentials match your operator URL |
| Token not persisting | localStorage blocked | Check browser privacy settings |
| SDK not loading | Wrong SDK URL | Verify UID_JS_SDK_URL is accessible |
| "Unexpected origin" | Domain not allowed | Use local operator or verify domain is registered |
- 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