Giter VIP home page Giter VIP logo

Comments (4)

 avatar commented on June 2, 2024

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.

from prebid.js.

RobertLippens avatar RobertLippens commented on June 2, 2024

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

from prebid.js.

RobertLippens avatar RobertLippens commented on June 2, 2024

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

from prebid.js.

mkendall07 avatar mkendall07 commented on June 2, 2024

Hi @RobertLippens

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

from prebid.js.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.