Google Accelerated Mobile Pages and the <amp-ad>
Our platform, like many others, generally delivers its content to the page via a
<script> tag. Google restricts the inclusion of
<script> elements on AMP pages in the name of protecting the user experience and improving the loading efficiency of the pages. Instead, they require ads to be loaded via specially provisioned
<amp-ad> elements over which the AMP runtime has control and whose contents can be loaded asynchronously based on that runtime’s logic. Accordingly, we had to develop a new way to deliver our ads to the page which fit in with this paradigm. On the face, this is very simple:
1 2 3 4 5
This tag looks much different and simpler than our usual ad tags. It works in conjunction with the AMP Project’s ad library. The AMP runtime’s
3p/integration.js module loads in the
flite.js module which then controls how our ads are served into AMP pages where an
<amp-ad> tag is included.
A handful of our features and tracking functionality require access to the top level
window in order to function. Most of our publisher customers serve our ads into iframes which are friendly, giving our ads full access to the top level
window. For publishers who do not serve our ads into friendly iframes and instead into 3rd-party iframes – iframes with a different domain than the page – we institute the use of an iframe buster in order to achieve this same access.
The AMP runtime and infrastructure load ads in through a 3rd party iframe. However, we cannot implement our usual iframe busting solution because publishers are not actually hosting their AMP pages. Instead, AMP pages are cached and served from Google’s own CDN. This is a limitation currently facing all ad tech vendors which prevents popular executions like lightbox and adhesive footer ads.
Thankfully, Google provides built in layout tools and APIs that give access to some information from the top
window. These tools allow us to retain our most important tracking and measurement functionality as well as allow for the development of new tools which take advantage of this information.