-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Prebid Core: Replace missing native asset placeholders #8773
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: Replace missing native asset placeholders #8773
Conversation
Synchronization with current prebid version
IMO this should be addressed from the PUC, but I have to admit that I have a hard time understanding native - so I'm not sure. I know that it's possible to use custom renderers so I'm afraid that this might be a breaking change? because I can imagine some implementations for which it's useful to distinguish between an asset that is missing and one that is an empty string. It seems safer to me to put that fallback in the renderer (PUC in our case). |
@dgirardi we decided to go for prebid.js, because this were the incoming bid data is processed and the simplest way to add defaults. However it's probably better to make this configurable to make it configurable like the E.g. <script src="https://cdn.jsdelivr.net/npm/prebid-universal-creative@latest/dist/native-render.js"></script>
<script>
var pbNativeTagData = {};
pbNativeTagData.pubUrl = "%%PATTERN:url%%"; // GAM specific
pbNativeTagData.adId = "%%PATTERN:hb_adid%%"; // GAM specific
// if you're using 'Send All Bids' mode, you should use %%PATTERN:hb_adid_BIDDER%%
pbNativeTagData.requestAllAssets = false;
// configure a fallback that works for the publisher
pbNativeTagData.fallbackAssetValue = '';
window.pbNativeTag.renderNativeAd(pbNativeTagData);
</script> From https://docs.prebid.org/prebid/native-implementation.html So we would extend this in PUC to send the Lines 386 to 391 in dd3267d
If you like, we can talk about this 😄 |
If we involve the PUC, it can manage the fallbackValue all by itself - I don't think it needs to bounce it off Prebid. It would just need to say "replace macro with the asset value, or fallbackValue if the asset is missing or its value is undefined". I think it would also be perfectly sensible to always have have a fallback of |
True that custom renderers maybe check of In PUC it would be this code here: https://github.com/prebid/prebid-universal-creative/blob/259030726f486f161995908688f360a8befdecf1/src/nativeAssetManager.js#L340-L345 We would essentially
(assets || []).forEach(asset => {
const flag = (typeof win.pbNativeData !== 'undefined');
const searchString = (adId && !flag) ? `${NATIVE_KEYS[asset.key]}:${adId}` : ((flag) ? '##'+`${NATIVE_KEYS[asset.key]}`+'##' : `${NATIVE_KEYS[asset.key]}`);
const searchStringRegex = new RegExp(searchString, 'g');
html = html.replace(searchStringRegex, asset.value);
});
// roughly like this
scanForPlaceholders().forEach(placeholder => {
html = html.replace(placeholder, '');
}) |
@dgirardi I opened a new PR in the PUC: prebid/prebid-universal-creative#171. |
Type of change
Description of change
See the following issue: #8769
When setting
requestAllAssets
to false, missing assets are now replaced by an empty string instead ofundefined
.Be sure to test the integration with your adserver using the Hello World sample page.
For any changes that affect user-facing APIs or example code documented on http://prebid.org, please provide:
Other information