Provide dynamic fallback for amp-ad

294 Views Asked by At

I would like to use "amp-ad" tag as a fallback for another amd-ad. Here is the example:

<amp-ad width="300"
    height="200"
    type="MY_PROVIDER"
    data-slot="MY_SLOT">
    <div fallback>
    <!-- Try to insert fallback amp-ad here -->
    </div>
</amp-ad>

3d-party ad provider (MY_PROVIDER) could return another amp-ad markup (from another provider) as a fallback. If i just insert this markup to the main ad container, it will not be executed:

document.getElementById('c').innerHTML = '<amp-ad width="300" height="200" type="MY_FALLBACK_PROVIDER" data-slot="MY_FALLBACK_SLOT"></amp-ad>'; //will not work

Is there any way to dynamically insert this fallback amp-ad markup to the fallback contanier at the host (top) page?

1

There are 1 best solutions below

0
On BEST ANSWER

Here's a quote from the amp docs:

A fallback is a convention that allows the element to communicate to the reader that the browser does not support the element

amp fallback

Fallback is just a way to communicate failure.