-
Notifications
You must be signed in to change notification settings - Fork 0
Create new sample page deferred prebid #139
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
eiman-eltigani-ttd
merged 6 commits into
main
from
eee-UID2-4875-new-sample-page-deferred-prebid
Dec 15, 2025
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
7bf99aa
update readme instructions to include env variables
eiman-eltigani-ttd 2d39965
Merge main into deferred-prebid branch
eiman-eltigani-ttd d2ef071
Fix infinite reload loop in secure-signals-client-server
eiman-eltigani-ttd 6941e26
Update landing page: remove mergeConfig note, open links in new tabs
eiman-eltigani-ttd 0dbd6e2
clean up console.logs and excess comments
eiman-eltigani-ttd 4554a11
update live example links and fix mergeConfig documentation URL
eiman-eltigani-ttd File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -58,14 +58,6 @@ | |
| // Read from localStorage | ||
| const secureSignalsStorageKey = '<%- secureSignalsStorageKey %>'; | ||
| const secureSignalsStorage = localStorage[secureSignalsStorageKey]; | ||
| const token = sdk.getAdvertisingToken(); | ||
|
|
||
| // Safety net: If token exists but Secure Signals haven't loaded yet, reload the page | ||
| if (token && !secureSignalsStorage && !<%= isOptout %>) { | ||
| console.log("Token exists but Secure Signals not loaded yet, reloading page..."); | ||
| location.reload(); | ||
| return; | ||
| } | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Removed the infinite reload loop in secure signals client server (bug fix) |
||
|
|
||
| const secureSignalsStorageJson = secureSignalsStorage && JSON.parse(secureSignalsStorage); | ||
|
|
||
|
|
||
19 changes: 19 additions & 0 deletions
19
web-integrations/prebid-integrations/client-side-deferred/Dockerfile
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,19 @@ | ||
| FROM nginx:alpine | ||
|
|
||
| # Install gettext for envsubst | ||
| RUN apk add --no-cache gettext | ||
|
|
||
| # Copy static files from client-side-deferred directory | ||
| COPY client-side-deferred/app.css /usr/share/nginx/html/ | ||
| COPY prebid.js /usr/share/nginx/html/ | ||
|
|
||
| # Copy config and HTML | ||
| COPY client-side-deferred/default.conf /etc/nginx/conf.d/default.conf | ||
| COPY client-side-deferred/index.html /usr/share/nginx/html/index.template.html | ||
| COPY client-side-deferred/entrypoint.sh /entrypoint.sh | ||
|
|
||
| RUN chmod +x /entrypoint.sh | ||
|
|
||
| ENTRYPOINT ["/entrypoint.sh"] | ||
| CMD ["nginx", "-g", "daemon off;"] | ||
|
|
123 changes: 123 additions & 0 deletions
123
web-integrations/prebid-integrations/client-side-deferred/README.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,123 @@ | ||
| # Deferred UID2/EUID Integration with Prebid.js (using mergeConfig) | ||
|
|
||
| This example demonstrates how to integrate UID2 or EUID with Prebid.js using **deferred configuration**. Unlike the standard integration where UID2/EUID is configured on page load, this pattern uses `mergeConfig()` and `refreshUserIds()` to add the identity module *after* the page has already loaded. | ||
|
|
||
| ## Use Cases | ||
|
|
||
| This pattern is useful for: | ||
|
|
||
| - **Async Login**: User logs in after the page has loaded | ||
| - **Delayed Consent**: Consent is given asynchronously (e.g., via a consent management platform) | ||
| - **Single Page Applications (SPAs)**: Dynamic login/logout without full page reloads | ||
| - **Lazy Loading**: Only load UID2/EUID when actually needed | ||
| - **User State Changes**: Handle logout and re-login scenarios | ||
|
|
||
| ## How It Works | ||
|
|
||
| ### Standard Flow (for comparison) | ||
| ```javascript | ||
| // Page load: UID2 configured immediately | ||
| pbjs.setConfig({ | ||
| userSync: { | ||
| userIds: [{ name: 'uid2', params: {...} }] | ||
| } | ||
| }); | ||
| ``` | ||
|
|
||
| ### Deferred Flow (this example) | ||
| ```javascript | ||
| // Step 1: Page load - Prebid configured WITHOUT UID2 | ||
| pbjs.setConfig({ | ||
| userSync: { | ||
| syncDelay: 5000, | ||
| auctionDelay: 1000, | ||
| // Note: NO userIds configured here! | ||
| } | ||
| }); | ||
|
|
||
| // Step 2: Later (after login, consent, etc.) - Add UID2 via mergeConfig | ||
| pbjs.mergeConfig({ | ||
| userSync: { | ||
| userIds: [{ | ||
| name: 'uid2', | ||
| params: { | ||
| uid2ApiBase: 'https://operator-integ.uidapi.com', | ||
| email: '[email protected]', | ||
| subscriptionId: 'your-subscription-id', | ||
| serverPublicKey: 'your-server-public-key' | ||
| } | ||
| }] | ||
| } | ||
| }); | ||
|
|
||
| // Step 3: Trigger user ID refresh to generate the token | ||
| await pbjs.refreshUserIds(); | ||
| ``` | ||
|
|
||
| ## Key Prebid.js APIs | ||
|
|
||
| | API | Purpose | | ||
| |-----|---------| | ||
| | `pbjs.setConfig()` | Initial configuration (without UID2) | | ||
| | `pbjs.mergeConfig()` | Add/update configuration without replacing existing config | | ||
| | `pbjs.refreshUserIds()` | Trigger user ID module to fetch/generate new IDs | | ||
| | `pbjs.getUserIds()` | Get current user IDs (check if token was generated) | | ||
|
|
||
| ## Live Examples | ||
|
|
||
| - **UID2**: [https://prebid-deferred.samples.uidapi.com/](https://prebid-deferred.samples.uidapi.com/) | ||
| - **EUID**: [https://prebid-deferred.samples.integ.euid.eu/](https://prebid-deferred.samples.integ.euid.eu/) | ||
|
|
||
| ## Running Locally | ||
|
|
||
| ### Using Docker Compose (recommended) | ||
|
|
||
| From the repository root: | ||
|
|
||
| ```bash | ||
| docker compose up prebid-client-side-deferred | ||
| ``` | ||
|
|
||
| Access at: http://localhost:3053 | ||
|
|
||
| ### Using the Reverse Proxy | ||
|
|
||
| ```bash | ||
| docker compose up | ||
| ``` | ||
|
|
||
| Access at: http://prebid-deferred.sample-dev.com (requires hosts file configuration) | ||
|
|
||
| ## Environment Variables | ||
|
|
||
| | Variable | Description | Default | | ||
| |----------|-------------|---------| | ||
| | `UID_CLIENT_BASE_URL` | API base URL for client-side calls | `https://operator-integ.uidapi.com` | | ||
| | `UID_CSTG_SUBSCRIPTION_ID` | Your CSTG subscription ID | Test value provided | | ||
| | `UID_CSTG_SERVER_PUBLIC_KEY` | Your CSTG server public key | Test value provided | | ||
| | `UID_STORAGE_KEY` | localStorage key for token storage | `__uid2_advertising_token` | | ||
| | `IDENTITY_NAME` | Display name (UID2 or EUID) | `UID2` | | ||
| | `DOCS_BASE_URL` | Base URL for documentation links | `https://unifiedid.com/docs` | | ||
|
|
||
| ## Testing Flow | ||
|
|
||
| 1. **Page loads** - Observe that Prebid is loaded but UID2 shows "Not yet configured (deferred)" | ||
| 2. **Enter email** - Type an email address in the input field | ||
| 3. **Click "Configure UID2 with mergeConfig()"** - This triggers: | ||
| - `pbjs.mergeConfig()` to add UID2 configuration | ||
| - `pbjs.refreshUserIds()` to generate the token | ||
| 4. **Observe results** - Token appears in the status tables | ||
| 5. **Test opt-out** - Use `[email protected]` to see opt-out behavior | ||
|
|
||
| ## Documentation | ||
|
|
||
| - [UID2 Client-Side Integration Guide for Prebid.js](https://unifiedid.com/docs/guides/integration-prebid-client-side) | ||
| - [EUID Client-Side Integration Guide for Prebid.js](https://euid.eu/docs/guides/integration-prebid-client-side) | ||
| - [Prebid.js User ID Module](https://docs.prebid.org/dev-docs/modules/userId.html) | ||
| - [Prebid.js mergeConfig](https://docs.prebid.org/dev-docs/publisher-api-reference/mergeConfig.html) | ||
|
|
||
| ## Related Examples | ||
|
|
||
| - [client-side](../client-side/) - Standard Prebid + UID2 (configured on page load) | ||
| - [client-server](../client-server/) - Server-side token generation with Prebid | ||
|
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.