Question regarding creative on DFP
Type of issue
question
Description
looking at http://prebid.org/adops/step-by-step.html#step-2-add-a-creative
what is the purpose of the for loop?
for (i = 0; i < 10; i++) {...
My guess is that window parent is not always immediately accessible so it is a sort of retry mechanism. Am I correct?
Any drawback if instead of 10 i put it at higher value (ex. 1000)?
I have a page with many scripts running and I sometimes see empty ad maybe due to this.
Thanks
@DavideMoney
The for loop in that code helps it climb any nested friendly iframes in order to find/access the prebid code on the page. For example, if your ad was nested in 3 levels deep - the loop would likely iterate 3 times looking at the new parent window of each successive iframe until it found the prebid code.
In regards to the issue you mentioned, you could try to increase the value but I'm not sure it'll have a consistent/definitive impact. Do you have sample page that's exhibiting the issue that we could look at further?
@DavideMoney The simplest way to check why ad is empty open chrome inspector and network panel, search for /gampad and look at the response, does ad contain "renderAd" text. If there is no such text, check targeting keys that were sent in the same web request, in query section. If hb_pb was sent, check your line items, if not sent check pbjs.getBidResponses() and validate that any has a CPM. If there are valid bids check your pbjs integration, if there are no - your demand is empty and DFP is also empty unfortunately.
@jsnellbaker Now I get the recursion mechanism, i thought at first it was another thing, now reading the snippet it makes perfectly sense.
@GeneGenie TY for the answer.
I'm using a custom creative based on the standard prebid code and the solution to my issue was a reference to the wrong parent frame.
Anyway thank you