Abraham Marval
Abraham Marval

Reputation: 11

Google Ad Manager Size Mapping browser warnings

This is my code

<script>
  window.googletag = window.googletag || { cmd: [] };
  var gptAdSlots = [];
  googletag.cmd.push(function() {
    var pageConfig = {
      allowOverlayExpansion: true,
      allowPushExpansion: true,
      sandbox: true
    };

    var mapping = googletag
      .sizeMapping()
      .addSize(
        [1420, 90],
        [
          [970, 90],
          [728, 90],
          [300, 600],
          [300, 250]
        ]
      )
      .addSize([769, 200], [[970, 90], [728, 90], [300, 600][(300, 250)]])
      .addSize(
        [320, 700],
        [
          [300, 250],
          [300, 100],
          [320, 100]
        ]
      )
      .build();

    gptAdSlots[0] = googletag
      .defineSlot(
        "/542XXX9/ECC_Middle1_Desktop_HOME",
        [
          [970, 90],
          [728, 90]
        ],
        "div-gpt-ad-id-0"
      )
      .defineSizeMapping(mapping)
      .addService(googletag.pubads());

    gptAdSlots[1] = googletag
      .defineSlot("/542XXX9/ECC_Left1_Desktop_HOME", [300, 250], "div-gpt-ad-id-0")
      .defineSizeMapping(mapping)
      .addService(googletag.pubads());

    gptAdSlots[3] = googletag
      .defineSlot("/542XXX9/ECC_Verical_Desktop_HOME", [300, 600], "div-gpt-ad-id-0")
      .defineSizeMapping(mapping)
      .addService(googletag.pubads());

    gptAdSlots[4] = googletag
      .defineSlot(
        "/542XXX9/ECC_Middle1_Mobile_HOME",
        [
          [300, 100],
          [320, 100]
        ],
        "div-gpt-ad-id-0"
      )
      .defineSizeMapping(mapping)
      .addService(googletag.pubads());

    gptAdSlots[5] = googletag
      .defineSlot("/542XXX9/ECC_Left1_Mobile_HOME", [300, 250], "div-gpt-ad-id-0")
      .defineSizeMapping(mapping)
      .addService(googletag.pubads());

    gptAdSlots[7] = googletag
      .defineSlot(
        "/542XXX9/Header_desktop_HOME",
        [
          [970, 90],
          [728, 90]
        ],
        "div-gpt-ad-id-0"
      )
      .defineSizeMapping(mapping)
      .addService(googletag.pubads());

    gptAdSlots[8] = googletag
      .defineSlot(
        "/542XXX9/ECC_Header_mobile_HOME",
        [
          [300, 100],
          [320, 100]
        ],
        "div-gpt-ad-id-0"
      )
      .defineSizeMapping(mapping)
      .addService(googletag.pubads());

    googletag.pubads().setForceSafeFrame(true);
    googletag.pubads().setSafeFrameConfig(pageConfig);
    googletag.pubads().enableSingleRequest();
    googletag.enableServices();
  });
</script>

Apparently everything is displayed correctly, although there are times when advertising does not render.

In the console there are warnings "Incorrect usage of googletag.Slot defineSizeMapping: Size mapping has to be an array" as I could solve this, I have reviewed in many forums and websites but I can not fix it.

Thanks for help!

Upvotes: 1

Views: 285

Answers (0)

Related Questions