Prebid Native won't display pictures with dynamic urls.
Hello everyone, I'm facing a strange limitation while developping AdouLike Native bidder adapter:
Type of issue
Improvement on native image compatibility
Description
We are trying to implement a Native prebid adapter. But when providing this image url: https://tag-dyn.omnitagjs.com/fo-dyn/native/preview/image?key=fd4362d35bb174d6f1c80d4bb5643c22&ztop=0&zleft=0&zwidth=0&zheight=1&width=400&height=300
This image won't be shown. There is a limitation on image urls with query param. If we remove the query parameters from this url, the image is fetched as expected (but our server won't return a valid image file)
Steps to reproduce
Use an image url containing query parameters in a native ad response. like : https://tag-dyn.omnitagjs.com/fo-dyn/native/preview/image?key=fd4362d35bb174d6f1c80d4bb5643c22&ztop=0&zleft=0&zwidth=0&zheight=1&width=400&height=300
Test page
Modify any native bidder adapter to return the provided image url in a native ad to see the result. The url is never added to the background-image CSS field. ( instead we can read background-image: url() )
Expected results
No limitation on dynamic image url. Query parameters can be part of an image ressource url.
Actual results
The url is never added to the background-image CSS field. ( instead we can read background-image: url() )
Platform details
Prebid.js v4.21.0-pre built using node v12.16.1 on Chrome 87.0.4280 on Ubuntu
Does it work if you URL-encode the image url?
Hi Bretg and thank you for your answer.
I'm not sure I get it though. encodeURI would replace special chars from the image url. As their are no special characters, the encoded url is the same as the non encoded. no change on image display behavior here.
The encoded version of https://tag-dyn.omnitagjs.com/fo-dyn/native/preview/image?key=fd4362d35bb174d6f1c80d4bb5643c22&ztop=0&zleft=0&zwidth=0&zheight=1&width=400&height=300 is https%3A%2F%2Ftag-dyn.omnitagjs.com%2Ffo-dyn%2Fnative%2Fpreview%2Fimage%3Fkey%3Dfd4362d35bb174d6f1c80d4bb5643c22%26ztop%3D0%26zleft%3D0%26zwidth%3D0%26zheight%3D1%26width%3D400%26height%3D300
Please try that?
I believe this relates to https://github.com/prebid/Prebid.js/issues/3155 , GAM won't allow =char as keyvalue.
The solution is to use sendId or the Native v2 that doesn't require passing Native Assets via keywords anymore https://docs.prebid.org/prebid/native-implementation.html
I've tried with https%3A%2F%2Ftag-dyn.omnitagjs.com%2Ffo-dyn%2Fnative%2Fpreview%2Fimage%3Fkey%3Dfd4362d35bb174d6f1c80d4bb5643c22%26ztop%3D0%26zleft%3D0%26zwidth%3D0%26zheight%3D1%26width%3D400%26height%3D300
But this is not a valid url. It won't work.
#3155 contains the following information : For url, you need keep the domain as it is, and only encode the query string part, otherwise it won't pass APN validation.
I'll try that.
But this is not a valid url. It won't work.
Something would need to unencoded it before trying to use it.
Allan's suggestion is probably the right one here, though it's still not entirely clear what your scenario is. If you're trying to pass the URL through GAM KVPs and that's where the query string's getting lost, then Allan's solution should work because the URL won't be passed in that way and won't need to be encoded.
@guiann , if you switch to Prebid Native version 2, which uses https://cdn.jsdelivr.net/npm/prebid-universal-creative@latest/dist/native-render.js, then there won't have this trouble, since in the new solution, all Native asset go through Prebid messaging instead of GAM KVPs. The Prebid messaging doesn't have limit on any char.
@bretg , instructions in https://docs.prebid.org/adops/setting-up-prebid-native-in-dfp.html step 3. Style your native ad is still based on Prebid Native version 1, we need to update this doc.
Here is the html using Prebid Native version 2 to replace the html inside https://docs.prebid.org/adops/setting-up-prebid-native-in-dfp.html step 3
<div class="sponsored-post">
<div class="thumbnail"></div>
<div class="content">
<h1><a href="%%CLICK_URL_UNESC%%##hb_native_linkurl##" target="_blank" class="pb-click">##hb_native_title##</a></h1>
<p>##hb_native_body##</p>
<div class="attribution">##hb_native_brand##</div>
</div>
</div>
<script src="https://cdn.jsdelivr.net/npm/prebid-universal-creative@latest/dist/native-render.js"></script>
<script>
let pbNativeTagData = {};
pbNativeTagData.pubUrl = "%%PATTERN:url%%";
pbNativeTagData.adId = "%%PATTERN:hb_adId%%";
window.pbNativeTag.renderNativeAd(pbNativeTagData);
</script>
Just 2 things need notice:
- for another
<a>you want to record click tracking, addclass="pb-click", not like previous version, attributepbAdIdis not need anymore; - for any Prebid asset, change the token format from
%%PATTERN:hb_native_xxxx%%to##hb_native_xxxx##
@wqi1972 I believe the chunk of html you pasted in the previous comment for v2 is missing the following line before renderNativeAd is called: pbNativeTagData.requestAllAssets = true;
It should be:
<script src="https://cdn.jsdelivr.net/npm/prebid-universal-creative@latest/dist/native-render.js"></script>
<script>
var pbNativeTagData = {};
pbNativeTagData.pubUrl = "%%PATTERN:url%%";
pbNativeTagData.adId = "%%PATTERN:hb_adid%%";
pbNativeTagData.requestAllAssets = true;
window.pbNativeTag.renderNativeAd(pbNativeTagData);
</script>
The link you posted is for v1, whereas the following link is for v2: https://docs.prebid.org/adops/gam-native.html
@coreyb-cbs , good to know we already have a new doc covers v2.
Regarding pbNativeTagData.requestAllAssets = true;, that is not required when you set up native html inside GAM template, function renderNativeAd will search for tokens ##hb_native_xxxx## inside html, and add them to the request assets list. pbNativeTagData.requestAllAssets = true; is only need when html template is outside GAM.
@guiann - are we good here?
Thank you all for your time.
The original issue has been experienced from a bidder adapter point of view.
Following this documentation:
Supporting Native
The picture url is sent through the bid response in: bid.native.image.url
I'm not sure if we have the possibility to switch to the new native ad renderer from this point? I mean, as a bidder adapter developper?
@guiann - we think that this issue would go away if you updated your test page to use the Native 2 renderer method described above. Or you can coach your publisher to do so if that's the problem.
- Your adapter writes bid.native.image.url to the PBJS bid response object
- PBJS-core stores this as hb_native_image
- On your test page, use one of the
sendTargetingKeys: falseapproaches described in https://docs.prebid.org/prebid/native-implementation.html - Use ##hb_native_image## as the macro in the template
- The value will be resolved without being passed through ad server query strings
I made some clarifications to the bid adapter interface in https://github.com/prebid/prebid.github.io/pull/2792
Let us know if this isn't sufficient.
Well my test page is the "working example" for native ad given in prebid documentation:
https://docs.prebid.org/dev-docs/examples/native-ad-example.html
Can you confirm this is obsolete and update it please?
@guiann That example is indeed for the v1 implementation. There should be some sort of warning indicating that this example is for v1 (like there is on the v2 implementation guide). I am not seeing a new example for v2 yet. There are chunks of example code scattered throughout the v2 implementation guide here: https://docs.prebid.org/prebid/native-implementation.html