### Example Bidder Adapter Setup Note
Source: https://docs.prebid.org/dev-docs/bidder-adaptor.html
This note indicates that the Example Bidding adapter requires specific setup before use. Contact the provided email for assistance.
```markdown
### Note
The Example Bidding adapter requires setup before beginning. Please contact us at [setup@example.com](mailto:setup@example.com).
```
--------------------------------
### Serve Optimera RTD Provider Example
Source: https://docs.prebid.org/dev-docs/modules/optimeraRtdProvider.html
Serve the Optimera RTD Provider example locally. This command compiles the necessary modules and starts a local server.
```bash
gulp serve --modules=appnexusBidAdapter,optimeraRtdProvider
```
--------------------------------
### AIDEM Bid Adapter Development Setup
Source: https://docs.prebid.org/dev-docs/bidders/aidem.html
Install dependencies, build the adapter, and serve it locally for development. Use the pbjs_debug=true URL parameter to enable detailed console logging.
```bash
nvm use
npm install
gulp build --modules=aidemBidAdapter
gulp serve --modules=aidemBidAdapter
# Open a chrome browser with no ad blockers enabled, and paste in this URL. The `pbjs_debug=true` is needed if you want to enable `loggerInfo` output on the `console` tab of Chrome Developer Tools.
http://localhost:9999/integrationExamples/gpt/hello_world.html?pbjs_debug=true
```
--------------------------------
### Navigate to Contxtful RTD Provider Example
Source: https://docs.prebid.org/dev-docs/modules/contxtfulRtdProvider
Access the Contxtful RTD provider integration example in your browser after serving it locally.
```bash
http://localhost:9999/integrationExamples/gpt/contxtfulRtdProvider_example.html
```
--------------------------------
### Example Integration
Source: https://docs.prebid.org/dev-docs/modules/contxtfulRtdProvider
Instructions to run a local example of the Contxtful RTD module integration.
```APIDOC
## Example
To view an integration example:
1. In your CLI run:
```bash
gulp serve --modules=rtdModule,appnexusBidAdapter,rubiconBidAdapter,sharethroughBidAdapter,contxtfulRtdProvider
```
2. In your browser, navigate to:
```
http://localhost:9999/integrationExamples/gpt/contxtfulRtdProvider_example.html
```
```
--------------------------------
### Serve Example with Contxtful RTD Provider
Source: https://docs.prebid.org/dev-docs/modules/contxtfulRtdProvider
Serve an integration example locally using Gulp, including the Contxtful RTD provider and other specified adapters.
```bash
gulp serve --modules=rtdModule,appnexusBidAdapter,rubiconBidAdapter,sharethroughBidAdapter,contxtfulRtdProvider
```
--------------------------------
### Select Media Ad Unit Configurations
Source: https://docs.prebid.org/dev-docs/bidders/selectmedia
Example ad unit configurations for Select Media, demonstrating setup for video instream, video outstream, and banner ad types. Ensure the 'aid' parameter is correctly set for each ad unit.
```javascript
var adUnits = [
// Video instream adUnit
{
code: 'div-test-div',
sizes: [[640, 480]],
mediaTypes: {
video: {
context: 'instream'
}
},
bids: [{
bidder: 'selectmedia',
params: {
aid: 331133
}
}]
},
// Video outstream adUnit
{
code: 'outstream-test-div',
sizes: [[640, 480]],
mediaTypes: {
video: {
context: 'outstream'
}
},
bids: [{
bidder: 'selectmedia',
params: {
aid: 331133
}
}]
},
// Banner adUnit
{
code: 'div-test-div',
sizes: [[300, 250]],
bids: [{
bidder: 'selectmedia',
params: {
aid: 350975
}
}]
}
];
```
--------------------------------
### Example Bid Params Table
Source: https://docs.prebid.org/dev-docs/bidder-adaptor.html
This table details the parameters required for the Example Bidding adapter, including their scope, description, example value, and type.
```markdown
{: .table .table-bordered .table-striped }
| Name | Scope | Description | Example | Type |
|---------------|----------|-----------------------|-----------|-----------|
| `placement` | required | Placement id | `'11111'` | `string` |
```
--------------------------------
### CondorX Bidder Setup and Parameters
Source: https://docs.prebid.org/dev-docs/bidders/condorx.html
Configure CondorX adapter with required and optional parameters. Ensure to contact CondorX for setup before integration.
```javascript
var adUnits = [{
code: 'condorx-container-id',
mediaTypes: {
banner: {
sizes: [[300, 250]],
}
},
bids: [{
bidder: "condorx",
params: {
widget: 'widget id by CondorX',
website: 'website id by CondorX',
url:'current url',
bidfloor: 0.50
}
}]
},
{
code: 'condorx-container-id',
mediaTypes: {
native: {
image: {
required: true,
sizes: [236, 202]
},
title: {
required: true,
len: 100
},
sponsoredBy: {
required: true
},
clickUrl: {
required: true
},
body: {
required: true
}
}
},
bids: [{
bidder: "condorx",
params: {
widget: 'widget id by CondorX',
website: 'website id by CondorX',
url:'current url',
bidfloor: 0.75
}
}]
},
{
code: 'condorx-container-id',
mediaTypes: {
banner: {
sizes: [[728, 90]],
}
},
bids: [{
bidder: "condorx",
params: {
widget: 'widget id by CondorX',
website: 'website id by CondorX',
url:'current url',
bidfloor: 1.00,
useOpenRTB: true
}
}]
}];
```
--------------------------------
### Get Specific Configuration Property
Source: https://docs.prebid.org/dev-docs/publisher-api-reference/readConfig.html
Call `readConfig()` with a string parameter to retrieve a single configuration property. For example, 'debug' to get the debug configuration.
```javascript
config.readConfig('debug')
```
--------------------------------
### Running the Optable RTD Provider Example
Source: https://docs.prebid.org/dev-docs/modules/optableRtdProvider.html
Command to build and serve the Prebid.js project with the Optable RTD Provider and related modules for testing. Access the example via the specified URL.
```bash
gulp serve --modules=optableRtdProvider,consentManagementGpp,consentManagementTcf,appnexusBidAdapter
```
--------------------------------
### Native Setup Example for TheMediaGrid (S2S)
Source: https://docs.prebid.org/dev-docs/bidders/grid
Configure native ad unit media types for server-to-server integration with TheMediaGrid. This example shows how to define assets like images, titles, and data fields.
```javascript
...
mediaTypes: {
native: {
ortb: {
ver: '1.2',
"assets": [
{
"id": 1,
"img": {
"hmin": 180,
"wmin": 216,
"type": 3
},
"required": 1
},
{
"title": {
"len": 140
},
"id": 2,
"required": 1
},
{
"id": 3,
"data": {
"len": 25,
"type": 1
},
"required": 1
}
],
}
}
},
...
```
--------------------------------
### Welect Example Ad Unit Setup
Source: https://docs.prebid.org/dev-docs/bidders/welect
Configure your ad unit with the Welect bidder and its required parameters. Ensure the placementId is obtained from Welect.
```javascript
var adUnits = [
{
bidder: 'welect',
params: {
placementId: 'exampleId'
},
mediaTypes: {
video: {
context: 'instream',
playerSize: [640, 360]
}
},
}
];
```
--------------------------------
### Minimal Prebid Express Integration Example
Source: https://docs.prebid.org/dev-docs/modules/dfp_express.html
This example demonstrates a minimal setup for Prebid Express. Ensure the AdUnit.code matches an actual GPT slot name and that `pbjs.express(adUnits)` is called to initiate header bidding. The Prebid.js file must be loaded synchronously.
```javascript
var adUnits = [
{
code: '/111111/slot-name',
mediaTypes: {
banner: {
sizes: [[300,250]]
}
},
bids: [
{
bidder: 'rubicon',
params: { account: 1001, siteId: 113932, zoneId: 535510 }
}
}];
pbjs.express(adUnits);
```
```html
// prebid.js needs to be loaded synchronously to make sure GPT doesn't fire before header bidding takes place
// it's assumed that the above myprebid.js file contains:
// - a definition for a prebid.js adunit with a `code` of 'slot-name' or 'div-name'
// - a call to pbjs.express(adUnits)
Express Test
```
--------------------------------
### Delay Auction for User IDs
Source: https://docs.prebid.org/dev-docs/publisher-api-reference/setConfig
Delay the auction to retrieve user IDs via the userId module before the auction starts. This example delays the auction by 1 second.
```javascript
pbjs.setConfig({
userSync: {
auctionDelay: 1000 // delay auction up to 1 second
}
});
```
--------------------------------
### Serve AirGrid RTD Example
Source: https://docs.prebid.org/dev-docs/modules/airgridRtdProvider.html
Serve the Prebid build with the AirGrid RTD module and bidder adapter for on-page testing.
```bash
gulp serve-fast --modules=rtdModule,airgridRtdProvider,appnexusBidAdapter
```
--------------------------------
### Basic Prebid.js Setup with Bitmedia Adapter
Source: https://docs.prebid.org/dev-docs/bidders/bitmedia
This HTML snippet demonstrates a basic Prebid.js setup for running an auction with the Bitmedia adapter. It includes defining ad units and configuring Prebid settings. Ensure your Prebid build includes the Bitmedia adapter.
```html
Ad Serverless Test Page
```
--------------------------------
### Configure LiveIntent ID with All Supported Parameters
Source: https://docs.prebid.org/dev-docs/modules/userid-submodules/liveintent.html
This example demonstrates the setup using all supported configuration parameters for the LiveIntent ID module. Note that `distributorId` is ignored if `liCollectConfig.appId` is present.
```javascript
pbjs.setConfig({
userSync: {
userIds: [{
name: "liveIntentId",
params: {
publisherId: "9896876",
distributorId: "did-0123",
identifiersToResolve: ["my-own-cookie"],
requestedAttributesOverrides: { uid2: true, magnite: true, bidswitch: true },
url: "https://publisher.liveintent.com/idex",
partner: "prebid",
ajaxTimeout: 1000,
liCollectConfig: {
fpiStorageStrategy: "cookie",
fpiExpirationDays: 730,
collectorUrl: "https://rp.liadm.com",
appId: "a-0012"
},
fpid: {
strategy: "cookie"
name: "foobar"
}
}
}]
}
});
```
--------------------------------
### Example Prebid.js Build Command
Source: https://docs.prebid.org/dev-docs/publisher-api-reference/installedModules.html
This command demonstrates how to build a Prebid.js package with specific modules. The installedModules array will reflect the modules listed here.
```bash
gulp build --modules=a,b,c
```
--------------------------------
### Configure RtbSape Ad Units
Source: https://docs.prebid.org/dev-docs/bidders/rtbsape.html
Example configuration for RtbSape ad units, demonstrating setup for both display and video ad types. Ensure the 'placeId' parameter is correctly set for each bid.
```javascript
var adUnits = [
{
code: 'banner-div',
sizes: [[300, 250]],
bids: [
{
bidder: 'rtbsape',
params: {
placeId: 553307
}
}
]
}, {
code: 'video-div',
mediaTypes: {
video: {
context: 'outstream',
playerSize: [600, 340]
}
},
bids: [{
bidder: 'rtbsape',
params: {
placeId: 553309
}
}]
}
];
```
--------------------------------
### Configure Floxis Video Ad Unit
Source: https://docs.prebid.org/dev-docs/bidders/floxis
Example configuration for a video ad unit with the Floxis bidder. This includes player settings and required parameters. Contact Floxis for account setup.
```javascript
var adUnits = [{
code: 'video-ad-div',
mediaTypes: {
video: {
context: 'instream',
playerSize: [[640, 480]],
mimes: ['video/mp4'],
protocols: [2, 3, 5, 6],
minduration: 5,
maxduration: 30
}
},
bids: [{
bidder: 'floxis',
params: {
seat: 'testSeat',
region: 'us-e',
partner: 'floxis'
}
}]
}];
```
--------------------------------
### Configure Video Ad Unit for Reset Digital
Source: https://docs.prebid.org/dev-docs/bidders/resetdigital.html
This example shows how to set up a video ad unit for the Reset Digital bidder. Key parameters like player size and publisher/site IDs are demonstrated. Note the different parameter name for site ID ('site_id' instead of 'siteID').
```javascript
var videoAdUnits = [
{
code: 'your-div', // Replace with the actual video ad unit code
mediaTypes: {
video: {
playerSize: [640, 480] // Define the player size for video ads
}
},
bids: [
{
bidder: "resetdigital",
params: {
pubId: "your-pub-id", // (required) Replace with your publisher ID
site_id: "your-site-id", // Replace with your site ID
forceBid: true, // Optional parameter to force the bid
zoneId: {
placementId: "", // Optional ID used for reports
deals: "", // Optional string of deal IDs, comma-separated
test: 1 // Set to 1 to force the bidder to respond with a creative
}
}
}
]
}
];
```
--------------------------------
### Initiate Prebid Process with URL Configuration
Source: https://docs.prebid.org/dev-docs/plugins/cross-player-prebid-component/cross-player-api.html
Use this to start the Prebid process by providing a URL that points to a JSON file containing Prebid configuration options. The component will load and use this configuration.
```javascript
window.prebidPluginCP.doPrebid('https://my-url-to-prebid-options.json');
```
--------------------------------
### Get Storage Use Disclosures API
Source: https://docs.prebid.org/dev-docs/modules/storageControl.html
Retrieve a list of all storage disclosures for the first-party domain across all installed modules. The returned data includes disclosure details and the modules that provided them.
```javascript
pbjs.getStorageUseDisclosures()
```
```json
[
{
"disclosedIn": "https://cdn.jsdelivr.net/gh/prebid/Prebid.js/metadata/disclosures/prebid/sharedId-optout.json",
"disclosedBy": [
"sharedIdSystem"
],
"identifier": "_pubcid_optout",
"type": "cookie",
"maxAgeSeconds": 31536000,
"cookieRefresh": false,
"purposes": []
},
...
]
```
--------------------------------
### Configure Tagoras Bidder with Ad Units and User Sync
Source: https://docs.prebid.org/dev-docs/bidders/tagoras
Example of how to define ad units for the Tagoras bidder and configure Prebid.js for user syncing. Ensure 'cId' and 'pId' are provided during setup.
```javascript
var adUnits = [{
code: 'banner-div',
mediaTypes: {
banner: {
sizes: [
[300, 250],
[728, 90]
]
}
},
bids: [{
bidder: 'tagoras',
params: {
cId: '562524b21b1c1f08117fc7f9', // Required - PROVIDED DURING SETUP...
pId: '59ac17c192832d0011283fe3', // Required - PROVIDED DURING SETUP...
bidFloor: 1.23 // Optional
}
}]
}
];
// configure pbjs to enable user syncing
pbjs.setConfig({
userSync: {
filterSettings: {
iframe: {
bidders: 'tagoras',
filter: 'include'
}
}
}
});
```
--------------------------------
### Build Prebid.js with AppNexus and DFP Modules
Source: https://docs.prebid.org/dev-docs/show-long-form-video-with-gam.html
Use this command to build Prebid.js with the AppNexus bidder adapter and the dfpAdServerVideo module. Include the categoryTranslation module if competitive separation is required.
```bash
gulp build --modules=appnexusBidAdapter,dfpAdServerVideo
```
--------------------------------
### Add Improve Digital Bidder to Ad Unit
Source: https://docs.prebid.org/dev-docs/bidders/improvedigital
Integrate the Improve Digital bidder into a Prebid.js ad unit configuration. This example shows basic setup with required placement and publisher IDs.
```javascript
pbjs.addAdUnits({
code: 'banner1',
sizes: [[728, 90], [970, 250]],
bids: [
{
bidder: 'improvedigital',
params: {
placementId: 1111111,
publisherId: 1234
}
}
]
});
```
--------------------------------
### Basic Size Mapping Example
Source: https://docs.prebid.org/dev-docs/examples/size-mapping.html
This example demonstrates a basic size mapping configuration. It defines a default size and then maps different sizes for smaller and larger viewports.
```javascript
var mapping = googletag.sizeMapping()
.addSize([728, 90], [[728, 90]])
.addSize([992, 100], [[970, 90], [970, 250]])
.addSize([1, 1], [[300, 250]])
.build();
```
--------------------------------
### Prismassp Ad Unit Configurations
Source: https://docs.prebid.org/dev-docs/bidders/prismassp
Example ad unit configurations for Prismassp, demonstrating setup for banner, video, native, and multi-format ad types. Ensure correct `tagId` and `videoTagId` (for multi-format) are provided.
```javascript
var adUnits = [
// Banner adUnit
{
code: 'banner-div',
mediaTypes: {
banner: {
sizes: [[300, 250], [300,600]]
}
},
bids: [{
bidder: 'prismassp',
params: {
tagId: 'testpris'
}
}]
},
// Video adUnit
{
code: 'video1',
mediaTypes: {
video: {
playerSize: [640, 480],
context: 'instream'
}
},
bids: [{
bidder: 'prismassp',
params: {
tagId: 'testpris'
}
}]
},
// Native adUnit
{
code: 'native1',
mediaTypes:
native: {
title: {
required: true
},
image: {
required: true
},
sponsoredBy: {
required: true
}
}
},
bids: [{
bidder: 'prismassp',
params: {
tagId: 'testpris'
}
}]
},
// Multiformat Ad
{
code: 'multi1',
mediaTypes: {
video: {
playerSize: [640, 480],
context: 'instream'
},
banner: {
sizes: [[300, 250], [300,600]]
}
},
bids: [{
bidder: 'prismassp',
params: {
tagId: 'testpris',
videoTagId: 'testpris'
}
}]
};
];
```
--------------------------------
### Serve Example with Geoedge Module
Source: https://docs.prebid.org/dev-docs/modules/geoedgeRtdProvider.html
Run the Gulp serve command to include the geoedge RTD provider and related adapters for local testing. Navigate to the provided URL in your browser to view the integration example.
```bash
gulp serve --modules=appnexusBidAdapter,geoedgeRtdProvider
```
```plaintext
http://localhost:9999/integrationExamples/gpt/geoedgeRtdProvider_example.html
```
--------------------------------
### OpenX Ad Unit Configurations (Display, Video, Native)
Source: https://docs.prebid.org/dev-docs/bidders/openx
Example ad unit configurations for OpenX, demonstrating display, video, and native ad formats with various parameters.
```javascript
var adUnits = [
{
code: 'test-div',
sizes: [[728, 90]], // a display size
mediaTypes: {'banner': {}},
bids: [
{
bidder: 'openx',
params: {
unit: '539439964',
delDomain: 'se-demo-d.openx.net',
customParams: {
key1: 'v1',
key2: ['v2', 'v3']
},
}
}, {
bidder: 'openx',
params: {
unit: '539439964',
delDomain: 'se-demo-d.openx.net',
customParams: {
key1: 'v1',
key2: ['v2', 'v3']
},
}
}
]
},
{
code: 'video1',
mediaTypes: {
video: {
playerSize: [640, 480],
context: 'instream',
mimes: ['video/x-ms-wmv, video/mp4']
}
},
bids: [{
bidder: 'openx',
params: {
unit: '1611023124',
delDomain: 'PUBLISHER-d.openx.net'
}
}]
},
{
code: 'native1',
mediaTypes: {
native: {
ortb: {
assets: [
{
id: 1,
required: 1,
img: {
type: 3,
w: 150,
h: 50,
}
}
]
}
}
},
bids: [{
bidder: 'openx',
params: {
unit: '539439964',
delDomain: 'se-demo-d.openx.net'
}
}]
}
];
```
--------------------------------
### Accessing Installed Modules in Prebid.js
Source: https://docs.prebid.org/dev-docs/publisher-api-reference/installedModules.html
After building a Prebid.js package, you can access the pbjs.installedModules array to see which modules were compiled into the package. For example, if the package was built with modules 'a', 'b', and 'c', the array will contain these values.
```javascript
pbjs.installedModules
```
--------------------------------
### Serve AIDEM Adapter for Video
Source: https://docs.prebid.org/dev-docs/bidders/aidem.html
Command to serve the AIDEM adapter along with DFP ad server for video testing.
```bash
gulp serve –modules=aidemBidAdapter,dfpAdServerVideo
```
--------------------------------
### Hybrid In-Image Banner with GPT Integration
Source: https://docs.prebid.org/dev-docs/bidders/hybrid.html
This example demonstrates integrating the Hybrid bidder for in-image banners with Google Publisher Tag (GPT). It includes Prebid.js setup, GPT configuration, and the logic for refreshing ads.
```html
Prebid.js Banner Example
Prebid.js Banner Ad Unit Test
```
--------------------------------
### Hybrid In-Image Banner Integration with Prebid.js
Source: https://docs.prebid.org/dev-docs/bidders/hybrid.html
This example shows how to configure an ad unit for an in-image banner ad using the Hybrid bidder. It includes the necessary Prebid.js setup and ad server targeting logic.
```html
Prebid.js Banner Example
Prebid.js InImage Banner Test
```
--------------------------------
### Request Bids with Floxis Adapter
Source: https://docs.prebid.org/dev-docs/bidders/floxis
This example demonstrates how to initialize ad units and request bids using the Floxis adapter. It includes setting bid timeout and handling bid responses.
```javascript
var pbjs = pbjs || {};
pbjs.que = pbjs.que || [];
pbjs.que.push(function() {
pbjs.addAdUnits([{
code: 'div-gpt-ad-1234567890123-0',
mediaTypes: {
banner: {
sizes: [[300, 250], [320, 50]]
}
},
bids: [{
bidder: 'floxis',
params: {
seat: 'testSeat',
region: 'us-e',
partner: 'floxis'
}
}]
}]);
pbjs.requestBids({
timeout: 3000,
bidsBackHandler: function(bidResponses) {
// Handle bid responses
pbjs.setTargetingForGPTAsync();
}
});
});
```
--------------------------------
### AdGrid Bidder Test Parameters
Source: https://docs.prebid.org/dev-docs/bidders/adgrid
Example ad unit configurations for AdGrid, demonstrating setup for banner and video ad types. Ensure to replace placeholder values with your actual publisher ID and desired placement.
```javascript
var adUnits = [
// Banner adUnit
{
code: 'test-div-1',
mediaTypes:{
banner:{
sizes: [[300, 250]]
}
},
bids: [{
bidder: 'adgrid',
params: {
domainId: 12345,
placement: 'global'
}
}]
},
{
code: 'test-div-2',
mediaTypes:{
banner:{
sizes: [[728, 90], [320, 50]]
}
},
bids: [{
bidder: 'adgrid',
params: {
domainId: 12345,
placement: 'global'
}
}]
},
// Video adUnit
{
code: 'test-video-div',
mediaTypes: {
video: {
playerSize: [
[640, 480]
],
context: 'instream'
}
},
bids: [{
bidder: 'adgrid',
params: {
domainId: 12345,
placement: 'global'
}
}]
}
];
```
--------------------------------
### Configure Video Ad Unit for iQM
Source: https://docs.prebid.org/dev-docs/bidders/iqm.html
Set up a video ad unit for iQM integration. This example includes parameters specific to video ads such as playerSize, context, placement, mimes, protocols, skippable, and playback_method.
```javascript
var videoAdUnit = {
code: 'video1',
mediaTypes: {
video: {
playerSize: [640, 480],
context: 'instream'
}
},
bids: [{
bidder: 'iqm',
params: {
// placementId: iosDevice ? 13239390 : 13232361, // Add your own placement id here. Note, skippable video is not supported on iOS
publisherId: 'df5fd732-c5f3-11e7-abc4-cec278b6b50a',
placementId: 23451,
geo:{
country:'USA'
},
bidfloor: 0.05,
video: {
placement :2,
mimes: ['video/mp4'],
protocols: [2,5],
skipppable: true,
playback_method: ['auto_play_sound_off']
}
}
}]
};
```
--------------------------------
### Configure Hadron RTD Provider in Prebid.js
Source: https://docs.prebid.org/dev-docs/modules/hadronRtdProvider.html
Configure the Hadron RTD provider in your Prebid.js setup to retrieve segments from Audigent. This example shows how to set up publisher ID 1234 and specifies that the auction should wait for the RTD prefetch to complete.
```javascript
pbjs.setConfig({
// ...
realTimeData: {
auctionDelay: auctionDelay,
dataProviders: [
{
name: "hadron",
waitForIt: true,
params: {
segmentCache: false,
partnerId: 1234
}
}
]
}
// ...
});
```
--------------------------------
### Sample Brightcove Player Prebid Plugin Integration (Prebid in Header)
Source: https://docs.prebid.org/dev-docs/plugins/bc/bc-prebid-plugin-sample-prebid-header.html
This HTML structure includes the necessary JavaScript and CSS to initialize the Brightcove Player with the Prebid plugin, configuring pre-bidding to run in the header before the player is loaded. Ensure the `window.bc_plugin_pbjs` variable is defined as shown.
```html
Brightcove Player Prebid Plugin - Prebid in Header
```
--------------------------------
### Sync Transaction IDs with Prebid.js and Another Library
Source: https://docs.prebid.org/dev-docs/examples/sync-tid.html
This example shows how to use Prebid.js and another ad library, ensuring they both use the same transaction ID for impressions. It includes setup for both libraries, bid requests, and a failsafe timeout mechanism.
```javascript
const AUCTION_TIMEOUT = 1500;
const FAILSAFE_TIMEOUT = 3000;
const requestManager = {
adserverRequestSent: false,
otherLibrary: false,
prebid: false,
};
const slots = [
{
id: 'div-gpt-ad-123-0',
tid: crypto.randomUUID(),
sizes: [
[300, 250]
]
}
]
anotherLibraryTag.fetchBids({
slots: slots.map((slot) => ({
// Please confirm precise syntax for this next line with other library documentation
slotID: slot.id,
sizes: slot.sizes,
timeout: AUCTION_TIMEOUT
})),
function() {
googletag.cmd.push(function() {
anotherLibraryTag.setDisplayBids();
requestManager.otherLibrary = true;
sendBidsToAdServer();
});
}
});
pbjs.que.push(function() {
pbjs.setConfig({
debug: true,
});
pbjs.requestBids({
bidsBackHandler: prebidBidsBack,
timeout: AUCTION_TIMEOUT,
adUnits: slots.map((slot) => ({
code: slot.id,
mediaTypes: {
banner: {
sizes: slot.sizes,
},
},
ortb2Imp: {
ext: {
tid: slot.tid
}
},
bids: [
{
bidder: 'appnexus',
params: {
placementId: 13144370,
},
},
],
}))
});
});
// prebid bids returned
function prebidBidsBack() {
pbjs.initAdserverSet = true;
googletag.cmd.push(function() {
if (pbjs.libLoaded) {
pbjs.que.push(function() {
pbjs.setTargetingForGPTAsync();
requestManager.prebid = true;
sendBidsToAdServer();
});
} else {
googletag.pubads().refresh();
requestManager.adserverRequestSent = true;
}
});
}
// send all bids to GAM
function sendBidsToAdServer(failsafeTimoutReached) {
if (requestManager.adserverRequestSent === true) return;
if (failsafeTimoutReached) {
console.warn("AUCTION FAILSAFE TIMEOUT REACHED");
googletag.cmd.push(function() {
googletag.pubads().refresh();
});
requestManager.adserverRequestSent = true;
return;
}
if (requestManager.otherLibrary && requestManager.prebid) {
googletag.cmd.push(function() {
googletag.pubads().refresh();
});
requestManager.adserverRequestSent = true;
}
}
setTimeout(function() {
sendBidsToAdServer(true);
}, FAILSAFE_TIMEOUT);
```
--------------------------------
### HTML Structure for Size Mapping Example
Source: https://docs.prebid.org/dev-docs/examples/size-mapping.html
This HTML file sets up the necessary structure for a Prebid.js size mapping example. It includes meta tags for viewport, required scripts for Prebid.js and GPT, and the JavaScript code for ad unit configuration and size mapping.
```html
Filter Sizes Dynamically with Labels