Prebid - exisiting gpt tag conflicts with Prebid js script

136 views Asked by At

We have an existing gpt tag(Not Prebid) placed on our site for ad. Recently we integrated prebid.js in our website. Our prebid code works well but existing gpt tag does not return anything. My assumptions are given below after some testing.

  1. gpt tag conflicts with header bidding.
  2. gpt tag is not calling defineSlot Because no google-query-id is generated on ad tag.

I have searched on google but did not find anything useful. Can anyone help?

gpt tag Code:

<script async src="https://securepubads.g.doubleclick.net/tag/js/gpt.js"></script>
<script>
  window.googletag = window.googletag || {cmd: []};
  googletag.cmd.push(function() {
    googletag.defineSlot('/xxxx/xxxx', 'div-gpt-ad-xxxxxx').addService(googletag.pubads());
    googletag.pubads().enableSingleRequest();
    googletag.enableServices();
  });
</script>

Prebid Code:

var div_1_sizes = [
              [300, 75],
              [320, 50],
              [728, 90],
              [300, 50],
            ];
            var PREBID_TIMEOUT = 100000;
            var FAILSAFE_TIMEOUT = 3000;
      
            var adUnits = [
              {
                code: "xxxxx",
                mediaTypes: {
                  banner: {
                    sizes: div_1_sizes,
                  },
                },
                bids: [
                  {
                    bidder: "minutemedia",
                    labelAny: ["desktop", "phone"],
                    params: {
                      org: "xxxx",
                      placementId: "xxx",
                      floorPrice: 0.05,
                    },
                  },
                ],
              },
            ];
      
            // ======== DO NOT EDIT BELOW THIS LINE =========== //
            var googletag = googletag || {};
            googletag.cmd = googletag.cmd || [];
            googletag.cmd.push(function () {
              googletag.pubads().disableInitialLoad();
            });
      
            var pbjs = pbjs || {};
            pbjs.que = pbjs.que || [];
      
            pbjs.que.push(function () {
              pbjs.addAdUnits(adUnits);
              pbjs.setConfig({
                enableSendAllBids: true,
                sizeConfig: [
                  {
                    mediaQuery: "(min-width: 1000px)",
                    sizesSupported: [
                      [728, 90],
                    ],
                    labels: ["desktop"],
                  },
                  {
                    mediaQuery: "(min-width: 0px) and (max-width: 600px)",
                    sizesSupported: [
                      [300, 75],
                      [320, 50],
                      [300, 50],
                    ],
                    labels: ["phone"],
                  },
                ],
              });
              pbjs.requestBids({
                bidsBackHandler: initAdserver,
                timeout: PREBID_TIMEOUT,
              });
            });
      
            function initAdserver() {
              if (pbjs.initAdserverSet) return;
              pbjs.initAdserverSet = true;
              googletag.cmd.push(function () {
                pbjs.que.push(function () {
                  pbjs.setTargetingForGPTAsync();
                  googletag.pubads().refresh();
                });
              });
            }
            // in case PBJS doesn't load
            setTimeout(function () {
              initAdserver();
            }, FAILSAFE_TIMEOUT);
      
            googletag.cmd.push(function () {
              var mapping1 = googletag
                .sizeMapping()
                .addSize([1200, 0], [[728, 90]])
                .addSize(
                  [320, 0],
                  [
                    [300, 50],
                    [320, 50],
                    [300, 75],
                  ]
                )
                .addSize(
                  [0, 0],
                  [
                    [300, 50],
                    [320, 50],
                    [300, 75],
                  ]
                )
                .build();
              googletag
                .defineSlot(
                  "xxxx",
                  div_1_sizes,
                  "xxxx"
                )
                .defineSizeMapping(mapping1)
                .addService(googletag.pubads());
              googletag.pubads().enableSingleRequest();
              googletag.pubads().collapseEmptyDivs();
              googletag.enableServices();
            });
            `
1

There are 1 answers

0
user3146221 On

Remove these 2 lines from your original GPT call and it should be fine

googletag.pubads().enableSingleRequest();
googletag.enableServices();