Skip to content
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

Prebid Core: Document setting custom cpm rounding config #4030

Merged
merged 1 commit into from
Oct 6, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 32 additions & 0 deletions dev-docs/publisher-api-reference/setConfig.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ Core config:
+ [Set the page URL](#setConfig-Page-URL)
+ [Set price granularity](#setConfig-Price-Granularity)
+ [Set media type price granularity](#setConfig-MediaType-Price-Granularity)
+ [Set custom cpm rounding](#setConfig-Cpm-Rounding)
+ [Configure server-to-server header bidding](#setConfig-Server-to-Server)
+ [Configure user syncing](#setConfig-Configure-User-Syncing)
+ [Configure targeting controls](#setConfig-targetingControls)
Expand Down Expand Up @@ -419,6 +420,37 @@ are recognized. This was driven by the recognition that outstream often shares l
If the mediatype is video, the price bucketing code further looks at the context (e.g. outstream) to see if there's
a price granularity override. If it doesn't find 'video-outstream' defined, it will then look for just 'video'.

<a name="setConfig-Cpm-Rounding" />

#### Custom CPM Rounding

Prebid defaults to rounding down all bids to the nearest increment, which may cause lower CPM ads to be selected.
While this can be addressed through higher [price granularity](#setConfig-Price-Granularity), Prebid also allows setting a custom rounding function.
This function will be used by Prebid to determine what increment a bid will round to.
<br/>
<br/>
You can set a simple rounding function:
```javascript
// Standard rounding
pbjs.setConfig({'cpmRoundingFunction': Math.round});
```

Or you can round according to more complex considerations:

```javascript
// Custom rounding function
const roundToNearestEvenIncrement = function (number) {
let ceiling = Math.ceil(number);
let ceilingIsEven = ceiling % 2 === 0;
if (ceilingIsEven) {
return ceiling;
} else {
return Math.floor(number);
}
}
pbjs.setConfig({'cpmRoundingFunction': roundToNearestEvenIncrement});
```

<a name="setConfig-Server-to-Server" />

#### Server to Server
Expand Down