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

Added docs for #2562 #822

Merged
merged 2 commits into from
Jun 10, 2019
Merged

Added docs for #2562 #822

merged 2 commits into from
Jun 10, 2019

Conversation

ptomasroos
Copy link
Contributor

Copy link
Contributor

@bretg bretg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry - while I get the general request for flexibility here, don't fully follow how this would be utilized. Please provide an example use case in this doc.

@ptomasroos
Copy link
Contributor Author

Do you mean something like this https://github.com/prebid/Prebid.js/pull/2562/files#diff-f8e049a1b6d4f9aa96fca41d2f7aa11dR159 or a new example file ?

@bretg
Copy link
Contributor

bretg commented Jun 21, 2018

I mean a short example illustrating it's use. Not the implementation. Doesn't have to be a separate file.

@bretg
Copy link
Contributor

bretg commented Nov 14, 2018

@ptomasroos -- anything else you can provide as to the use of this feature?

@ptomasroos
Copy link
Contributor Author

Yeah of course. We use it infinite scrolling when we don’t know what the div will be named at the point of when a auction is finished. Since someone might have scrolled in the list. Then we use that to map to what’s visible in the viewport @bretg

@bretg
Copy link
Contributor

bretg commented Feb 13, 2019

Ok @ptomasroos - I took a stab at reverse engineering what's happening here enough to come up with an example that made more sense to me than "return slot => { return adUnitCode => { return slot.getSlotElementId() === 'myFavoriteDivId'; } };" Sorry, I'm slow on this -- functional programming is not my forte.

We use it infinite scrolling when we don’t know what the div will be named at the point of when a auction is finished. Since someone might have scrolled in the list. Then we use that to map to what’s visible in the viewport

Is the function below a realistic use case?

// returns a filter function that matches the current slot to the adUnitCode, but only when that
// slot is in view according to the divInView() function
function pickInViewDiv(slot) {
   return function(adUnitCode) {
        return adUnitCode === slot.getAdUnitPath() &&
                    divInView(slot.getSlotElementId()); }
};

// force the matching of the AdUnit targeting to a slot having the right name, but also being in view
setTargetingForGPTAsync(adUnit, pickInViewDiv);

@ptomasroos
Copy link
Contributor Author

Sorry for forgetting this! Will reply today

@ptomasroos
Copy link
Contributor Author

This is more a realistic description @bretg

Does it make sense?

// returns a filter function that matches either with the slot or the adUnitCode
// this filter function is being invoked after the auction has completed
// this means that it can be used in order to place this within viewport instead of a static div naming 
// which regular classic setup allows (by default the its looking for a div id named same as the adUnitCode)

// slot is in view according to the divInView() function
function pickInViewDiv(slot) {
   return function(adUnitCode) {
        return adUnitCode === slot.getAdUnitPath() &&
                    divInView(slot.getSlotElementId()); }
};

// make sure we render the results from the auction in a div that is visible in the viewport (example infinite scrolling, instead of rendering a ad in the top of the list that will never be visible (made up example))

setTargetingForGPTAsync(adUnit, pickInViewDiv);

@ptomasroos
Copy link
Contributor Author

The reason why this exists is to allow greater flexibility in order to decide when the auction has finished in which div id "placeholder" the ad results should render into.

Since a auction may have a init time of xxx ms and then also run for xxxx ms. This closes the gap in some design decisions in order to avoid having to set the timeout of auctions so short to make sure they get good viewability. Instead the logic can find a good placement for the auction result depending on where the user is at and how much time the auction took to complete.

Copy link
Contributor

@bretg bretg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks - makes sense now. Added some words describing the use case.

@bretg bretg merged commit a8fabe0 into prebid:master Jun 10, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants