google-chromeadsenseamp-htmlamp-ad

How to render Amp ads without amp-ad?


Tried implementing amp-ad to render video ads in amp pages, but facing below issue.

<div class='ad-banner' id="div-gpt-ad-xxxxxxxxx-1">
<amp-ad layout=fluid height=fluid type="doubleclick" data-slot="/12431234343/Qa/Android_Mobile_Web/Home" json="{&quot;targeting&quot;:{&quot;NativeType&quot;:&quot;videoad&quot;}}">
</amp-ad>

In ad response we could see the proper response, but in elements we could see height=0 or hidden attrb has been added as part of amp-ad element. So rendered ad is not visible in the front end.

So is there anyway to render ad without amp-ads or the above one is resolvable.


Solution

  • The layout type of fluid isn't valid per the amp-ad component specifications, you require fill, fixed, fixed-height, flex-item, intrinsic, nodisplay, or responsive. Also you need to define a height and width value for your advertisement on the amp-ad element depending on the layout type selected.

    From the amp-ad documentation:

    The <amp-ad> requires width and height values to be specified according to the rule of its layout type. It requires a type argument that select what ad network is displayed.

    It's likely that the combination of these issues is causing the advertisement to hide.