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

Issue with rendering native ads on amp pages #1806

Open
rokostik opened this issue Apr 14, 2021 · 7 comments
Open

Issue with rendering native ads on amp pages #1806

rokostik opened this issue Apr 14, 2021 · 7 comments
Assignees
Labels

Comments

@rokostik
Copy link
Contributor

Hey! I

I’m running into an issue where a native amp ad does not render on the page, specifically I get ERROR: Invalid image type for image asset from the native-trk.js library.

After digging a bit I see that the asset types are only set for requests from mobile apps (https://github.com/prebid/prebid-server/blob/master/exchange/bidder.go#L209) and the documentation states that amp pages should set the site object just as a regular page would (https://docs.prebid.org/prebid-server/endpoints/openrtb2/pbs-endpoint-amp.html).

This was discussed in #1041 but there’s no mention of amp pages. Was this overlooked or am I missing something?

@bretg
Copy link
Contributor

bretg commented Apr 14, 2021

We don't currently support native and AMP, at least we'd not specifically tested it. Honestly I'm not sure that AMP can do all the special javascript stuff the PUC wants to do here.

So I tried to set up a test page and find that I can't enter a PBJS native creative in GAM. Here's what I did:

<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="PUC_SOURCE"></script>
<script>
  	let pbNativeTagData = {};
  	pbNativeTagData.pubUrl = "%%PATTERN:url%%";
    pbNativeTagData.adId = "%%PATTERN:hb_adId%%";
  	window.pbNativeTag.renderNativeAd(pbNativeTagData);
</script>

Setting the "Rendering Type" to "Standard and AMP" receives this error: Custom JavaScript is not allowed

Please help us understand how you've set up the GAM creative. You're right that PBS isn't doing the native pre-processing for AMP. That might be the solution, but in order for us to test it, guidance on the ad server setup appreciated.

@rokostik
Copy link
Contributor Author

To be honest, I didn't check if fixing the described issue would work.

I'm now testing fixing the issue. For the ad manager setup I'm using the same setup as I'm using with mobile, described here.

I see that the creative is returned from GAM and the native-trk.js library loads the assets and triggers the impression trackers but the ad is not rendered. There are no errors in the console regarding this. So it seems that it could be possible for amp to work with PUC but I'm not sure why the ad isn't showing. Could you please test it out and let me know?

This is the patch for prebid-server that I'm testing with:

diff --git a/exchange/bidder.go b/exchange/bidder.go
index 59ef92cb..68de7d70 100644
--- a/exchange/bidder.go
+++ b/exchange/bidder.go
@@ -206,7 +206,7 @@ func (bidder *bidderAdapter) requestBid(ctx context.Context, request *openrtb2.B
 				}
 
 				// Only do this for request from mobile app
-				if request.App != nil {
+				//if request.App != nil {
 					for i := 0; i < len(bidResponse.Bids); i++ {
 						if bidResponse.Bids[i].BidType == openrtb_ext.BidTypeNative {
 							nativeMarkup, moreErrs := addNativeTypes(bidResponse.Bids[i].Bid, request)
@@ -222,7 +222,7 @@ func (bidder *bidderAdapter) requestBid(ctx context.Context, request *openrtb2.B
 							}
 						}
 					}
-				}
+				//}
 
 				if err == nil {
 					// Conversion rate found, using it for conversion

@hhhjort
Copy link
Collaborator

hhhjort commented Apr 19, 2021

I don't see an issue in expanding the scope of that code to include all types rather than just App requests. We probably want to put a feature flag on it so we don't do this for every request, it does add a little to the size of the response.

The bit of code above was originally put into place, as the Native spec assumes that the caller knows what they requested. With the advent of apps calling PBS while leveraging stored requests, the app did not know what asset IDs were associated with what native types, so needed the return values to be labeled with the proper types so it would know how to display them. AMP is in the same boat, as it also needs to use stored request, and the page has no visibility into the details of the request that was sent. So in hindsight, it is obvious that AMP would need this functionality to properly display native content.

@bretg
Copy link
Contributor

bretg commented Apr 20, 2021

Is it possible for us to determine that a given bidRequest was based off a stored request? Seems like that's the trigger for this behavior rather than either "all" or "app"?

While it's fine to make this change, I feel like it's got a good chance of not working in the wild. AMP doesn't play nice with all javascript functionality. Still, PBS should do its part, then if PUC breaks, someone can suggest a fix to make it work in an AMP context.

@bretg
Copy link
Contributor

bretg commented Jun 24, 2021

Fixed in PBS-Java 1.66 with prebid/prebid-server-java#1285

That said, I'm still not convinced this update is going to solve the underlying problem, which is that AMP doesn't much like javascript. If you find a workaround and can share a test page, we'd be happy to document for others.

@bretg bretg added the PBS-Go label Jun 24, 2021
@stale
Copy link

stale bot commented Jan 8, 2022

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the stale label Jan 8, 2022
@bretg bretg removed the stale label Feb 3, 2022
@SyntaxNode SyntaxNode added the Ready For Dev Feature specification is ready to be developed. label Sep 7, 2022
@bretg bretg removed the projectboard label Sep 8, 2022
@bretg bretg moved this from Triage to Clarify Request in Prebid Server Prioritization Oct 7, 2022
@bretg
Copy link
Contributor

bretg commented Oct 7, 2022

Linking this to #1041 -- the solution to this issue is to do the "native type processing" for AMP as well as app.

@bretg bretg moved this from Clarify Request to Ready for Dev in Prebid Server Prioritization Oct 7, 2022
@bretg bretg removed the Ready For Dev Feature specification is ready to be developed. label Dec 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Status: Ready for Dev
Development

No branches or pull requests

4 participants