2

Assuming I've correctly defined a google ad:

googletag.defineSlot(adUnitPath, size, "ad-id-goes-here")

If I use multiple instances of the following code (googletag.display() with the same id) on one page:

<div id="ad-id-goes-here" style="width: 728px; height: 90px">
  <script type="text/javascript">
    googletag.cmd.push(function() {
      googletag.display('ad-id-goes-here');
    });
  </script>
</div>

Will the ad only display once (the very first instance), or will it fail to display at all?


According to the reference:

Each ad slot should only be displayed once per page.

However this says nothing about failure, any thoughts?

budi
  • 6,351
  • 10
  • 55
  • 80
  • This page has example of asynchronous usage of the `googletag.display()` - It shows multiple instances of usage. Not sure if that helps. https://support.google.com/dfp_premium/answer/1638622?hl=en – Derple May 23 '16 at 15:32
  • Thank you, but the example shows multiple instances of `googletag.display()` with unique ids. I need to know what happens if I use multiple instances with the same id. – budi May 23 '16 at 15:49

1 Answers1

4

If you attempt to call googletag.display('ad-id') twice on the same ID, the ad will only display the first time and you will get the following exception for the second call:

"Div element ad-id is already associated with another slot."

You can see this output if you append ?google_console to the URL that contains the ad units, then press ctrl+F10 to display the google publisher console.

Nissa
  • 4,636
  • 8
  • 29
  • 37
Rafal
  • 181
  • 5
  • Some more info on Google Publisher Console: https://support.google.com/dfp_sb/answer/181070?hl=en – budi Oct 28 '16 at 21:29