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

Support DFP Premium Same Ad Unit Multiple Slots #69

Closed
prebid opened this issue Oct 16, 2015 · 4 comments
Closed

Support DFP Premium Same Ad Unit Multiple Slots #69

prebid opened this issue Oct 16, 2015 · 4 comments

Comments

@prebid
Copy link
Collaborator

prebid commented Oct 16, 2015

As a publisher, I would like Prebid.js to support the case where I have one ad unit reused across multiple slots. For example:

googletag.defineSlot('/1234/Leaderboard', [728, 90], 'div-gpt-ad-5678-2').setTargeting('Position',['bottom']).addService(googletag.pubads());

googletag.defineSlot('/1234/Leaderboard', [[970, 90],[970, 250],[728, 90]], 'div-gpt-ad-5678-3').setTargeting('Position',['top']).addService(googletag.pubads());

(In this case, the same ad unit is served into multiple ad slots)

googletag.defineSlot('/1234/Leaderboard', [728, 90], 'div-gpt-ad-5678-2').setTargeting('Position',['bottom']).addService(googletag.pubads());

googletag.defineSlot('/1234/MobileMediumRectangle', [[300, 250],[320,100]], 'div-gpt-ad-5678-2').setTargeting('Position',['bottom']).addService(googletag.pubads());

(In this case, multiple ad units serve into the same ad slot)

We need to come up with an example to support the above cases.

@prebid
Copy link
Collaborator Author

prebid commented Oct 19, 2015

Proposed solution:

Instead of using ad unit path ('/1234/Leaderboard'), we should use the slot element ID ('div-gpt-ad-5678-2') as the code for prebid ad units.

For example:

var adUnits = [{
    code: 'div-gpt-ad-5678-2',
    sizes: [...]
    bids: [...]
}]

If 2 prebid ad units for some reason share the same code (DFP slot element ID) in this case, we'll combine the 2 ad units' result bids together.

GPT has the function getSlotElementId() that can be used to get an ad slot's element ID.

@RobertLippens
Copy link
Contributor

👍 this feature request, this is currently a blocking item for us.

@RobertLippens
Copy link
Contributor

Update: I have been fiddling around with the source code a bit and have been able to get two ads of different sizes using the same slot with the suggested method above.

var rightSlot = googletag.defineSlot('12345/slot/name', [[300, 250]], 'div1').addService(googletag.pubads());
var topSlot = googletag.defineSlot('12345/slot/name', [[728,90]], 'div2').addService(googletag.pubads());

with adUnits defined:

{
        code: 'div1',
        sizes: [[300, 250]],
        bids: [
          {
              bidder: 'yieldbot',
              params: {
                psn: 'TOADD',
                slot: 'TOADD'
              }
            }]
    }

and

{
        code: 'div2',
        sizes: [[728, 90]],
        bids: [
          {
              bidder: 'yieldbot',
              params: {
                psn: 'TOADD',
                slot: 'TOADD'
              }
            }]
    }

The necessary code change appears to be in prebid.js at setTargetingForAdUnitsGPTAsync (on line 442). The for-loop contents can be replaced with:

            var adUnitCode = slots[i].getSlotElementId();
            if (adUnitCode) {
                placementBids = getBidResponsesByAdUnit(adUnitCode);
                setGPTAsyncTargeting(slots[i].getAdUnitPath(), slots[i], placementBids);
            }

where the adUnitCode is now based on the SlotElementId as suggested, though the GPTAsyncTargeting is still based on the adUnitPath as it was previously.

I have added this to a forked PR #77

@mkendall07
Copy link
Member

Hi @RobertLippens

Thanks for the contributing. I will also update the code to reflect a fallback to getAdUnitPath() if getSlotElementId() is empty

mp-12301 pushed a commit to aol/Prebid.js that referenced this issue Apr 10, 2017
…11.0 to master

* commit 'e0e25bc31e66fe7c89003741d654ea6b25fb1a21':
  Mistype fix.
  Removed conflict message leftover.
  Change method names, simplified regex, DOMReady logic introduced.
  Minor changes in the code.
  Small changes.
  Removed adapter.
  Adding functionality of cookie syncing upon bid request
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants