Skip to content

Commit 4c0d056

Browse files
dgirardismenzer
andauthored
Update documentation for publisher userID api (prebid#3698)
* Update documentation for publisher userID api * Update dev-docs/modules/userId.md Fix backtick Co-authored-by: Scott Menzer <smenzer@gmail.com> Co-authored-by: Scott Menzer <smenzer@gmail.com>
1 parent d373665 commit 4c0d056

3 files changed

Lines changed: 38 additions & 4 deletions

File tree

dev-docs/modules/userId.md

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ The User ID module supports multiple ways of establishing pseudonymous IDs for u
2929
1. If GDPR applies, the consent signal from the CMP is hashed and stored in a cookie called `_pbjs_userid_consent_data`. This is required so that ID sub-modules may be called to refresh their ID if the user's consent preferences have changed from the previous page, and ensures cached IDs are no longer used if consent is withdrawn.
3030
1. An object containing one or more IDs (`bidRequest.userId`) is made available to Prebid.js adapters and Prebid Server S2S adapters.
3131
1. In addition to `bidRequest.userId`, `bidRequest.userIdAsEids` is made available to Prebid.js adapters and Prebid Server S2S adapters. `bidRequest.userIdAsEids` has userIds in ORTB EIDS format.
32-
1. The page can call [pbjs.getUserIds()](/dev-docs/publisher-api-reference/getUserIds.html) or [pbjs.getUserIdsAsEids()](/dev-docs/publisher-api-reference/getUserIdsAsEids.html)
32+
1. The page can call [pbjs.getUserIds()](/dev-docs/publisher-api-reference/getUserIds.html), [pbjs.getUserIdsAsEids()](/dev-docs/publisher-api-reference/getUserIdsAsEids.html), or [pbjs.getUserIdsAsync()](/dev-docs/publisher-api-reference/getUserIdsAsync.html).
3333

3434
{: .alert.alert-info :}
3535
Note that User IDs aren't needed in the mobile app world because device ID is available in those ad serving scenarios.
@@ -76,7 +76,7 @@ The PPID in GAM (which is unrelated to the PPID UserId Submodule) has strict rul
7676
{: .table .table-bordered .table-striped }
7777
| Param under userSync | Scope | Type | Description | Example |
7878
| --- | --- | --- | --- | --- |
79-
| ppid | Optional | String | Must be a source from the [pbjs.getUserIdsAsEids()](/dev-docs/publisher-api-reference/getUserIdsAsEids.html) array | `"pubcid.org"` |
79+
| ppid | Optional | String | Must be a source from the [pbjs.getUserIdsAsEids()](#getUserIdsAsEids) array | `"pubcid.org"` |
8080

8181
The table below has the options that are common across ID systems. See the sections below for specific configuration needed by each system and examples.
8282

@@ -2348,6 +2348,7 @@ Bidders that want to support the User ID module in Prebid Server, need to update
23482348
23492349
See the [Prebid.js EIDs javascript source](https://github.com/prebid/Prebid.js/blob/master/modules/userId/eids.js) for the definitive list of user EID sources.
23502350
2351+
<a name="getUserIds"/>
23512352
### Exporting User IDs
23522353
23532354
If you need to export the user IDs stored by Prebid User ID module, the `getUserIds()` function will return an object formatted the same as bidRequest.userId.
@@ -2356,7 +2357,9 @@ If you need to export the user IDs stored by Prebid User ID module, the `getUser
23562357
pbjs.getUserIds() // returns object like bidRequest.userId. e.g. {"pubcid":"1111", "tdid":"2222"}
23572358
```
23582359
2359-
You can use [`getUserIdsAsEids()`](/dev-docs/publisher-api-reference/getUserIdsAsEids.html) to get the user IDs stored by Prebid User ID module in ORTB Eids format. Refer [eids.md](https://github.com/prebid/Prebid.js/blob/master/modules/userId/eids.md) for output format.
2360+
<a name="getUserIdsAsEids"/>
2361+
2362+
You can use `getUserIdsAsEids()` to get the user IDs stored by Prebid User ID module in ORTB Eids format. Refer [eids.md](https://github.com/prebid/Prebid.js/blob/master/modules/userId/eids.md) for output format.
23602363
```
23612364
pbjs.getUserIdsAsEids() // returns userIds in ORTB Eids format. e.g.
23622365
[
@@ -2393,6 +2396,19 @@ pbjs.getUserIdsAsEids() // returns userIds in ORTB Eids format. e.g.
23932396
]
23942397
```
23952398
2399+
<a name="getUserIdsAsync" />
2400+
2401+
`pbjs.getUserIds()` and `pbjs.getUserIdsAsEids()` may return only some IDs, or none at all, if they are called before all ID providers have had a chance to initialize - depending on [`auctionDelay` and/or `syncDelay`](/dev-docs/publisher-api-reference/setConfig.html#setConfig-ConfigureUserSyncing-UserSyncProperties), that may need to wait until an auction has completed.
2402+
To access the complete set of IDs, you may use `getUserIdsAsync`, which returns a promise that is guaranteed to resolve only once all IDs are available:
2403+
2404+
```
2405+
pbjs.getUserIdsAsync().then(function (userIds) {
2406+
// all IDs are available here:
2407+
pbjs.getUserIds() // same as the `userIds` argument
2408+
pbjs.getUserIdsAsEids()
2409+
});
2410+
```
2411+
23962412
## ID Providers
23972413
23982414
If you're an ID provider that wants to get on this page:
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
---
2+
layout: api_prebidjs
3+
title: pbjs.getUserIdsAsync()
4+
description:
5+
---
6+
7+
{: .alert.alert-info :}
8+
To use this function, include the [UserId module](/dev-docs/modules/userId.html) in your Prebid.js build.
9+
10+
`getUserIdsAsync()` returns a promise to the same value returned by [getUserIds()](/dev-docs/publisher-api-reference/getUserIds.html), but it's guaranteed to resolve only once the complete set of IDs is available:
11+
12+
```
13+
pbjs.getUserIdsAsync().then(function (userIds) {
14+
// all IDs are available here:
15+
pbjs.getUserIds() // same as the `userIds` argument
16+
pbjs.getUserIdsAsEids()
17+
});
18+
```

dev-docs/publisher-api-reference/refreshUserIds.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,4 +21,4 @@ The `refreshUserIds` function allows you to force either all or a subset of user
2121
```
2222
pbjs.refreshUserIds();
2323
pbjs.refreshUserIds({ submoduleNames: ['britepoolId'] }, () => console.log("Done!"));
24-
```
24+
```

0 commit comments

Comments
 (0)