ampproject / amp-wp

Enable AMP on your WordPress site, the WordPress way.
https://wordpress.org/plugins/amp/
GNU General Public License v2.0
1.79k stars 382 forks source link

Make it easier to advertise in AMP Stories #2430

Closed swissspidy closed 4 years ago

swissspidy commented 5 years ago

AMP Stories supports an amp-story-auto-ads component that works like this:

<amp-story>
  <amp-story-auto-ads>
    <script type="application/json">
      {
        "ad-attributes": {
          // ad server configuration
        }
      }
    </script>
  </amp-story-auto-ads>
  <amp-story-page>
  ...
</amp-story>

(source)

Right now, the only way to insert that component is by filtering the_content:

https://github.com/ampproject/amp-wp/blob/1aa2afaec26781a953ca7f7442fc21973e4ce243/includes/templates/single-amp_story.php#L41-L55

I wonder if we should add a dedicated action to the template there. Perhaps we could even add a amp_stories_auto_ads_attributes filter and automatically print <amp-story-auto-ads> when the attributes are not empty.

westonruter commented 5 years ago

I was chatting about this with @amedina last week as well. I also suggested a filter which would result in the AMP component printed when the array is not empty.

The alternative we chatted about was to add a new ads section to the Document sidebar in the editor, but that seems very premature. The configuration would need a UI and it seems likely that the same configuration would be used across stories anyway. And we'd want an ad-provider plugin to actually inject the ads and manage the UI.

So +1 for filter.

amedina commented 5 years ago

Sounds good; +1 for filter.

Chatted with @jasti a bit about Ads on Stories. Should sync further to discuss enabling strategies/recommended approaches for monetization. /cc @vinaymahag

swissspidy commented 5 years ago

The alternative we chatted about was to add a new ads section to the Document sidebar in the editor, but that seems very premature. The configuration would need a UI and it seems likely that the same configuration would be used across stories anyway. And we'd want an ad-provider plugin to actually inject the ads and manage the UI.

Makes sense. It seems that there are a few configurations that would need to be exposed in the UI. One example would be for toggling the next-page-no-ad attribute on an amp-story-page.

amedina commented 5 years ago

@jasti WDYT about this as a baseline?

jasti commented 5 years ago

Yeah, there are a lot of options we can fiddle with. Lets discuss if this should all be bundled as part of the Site Kit Package or ship with the AMP plugin in the next version.

swissspidy commented 5 years ago

The alternative we chatted about was to add a new ads section to the Document sidebar in the editor

Note that it's finally possible to actually extend the document sidebar with the upcoming new Gutenberg version.

See https://github.com/WordPress/gutenberg/pull/13361 / https://github.com/WordPress/gutenberg/issues/13357

swissspidy commented 4 years ago

Here are the docs for next-page-no-ad: https://amp.dev/documentation/components/amp-story-auto-ads/#insertion-control

Since we have the amp_story_auto_ads_configuration filter, we could add a checkbox for next-page-no-ad to the Document sidebar if, and only if, the filter is not empty. However, this could also be done by any ads plugin.

Since amp-story-auto-ads still only supports Ad Manager at the moment, it's not really a priority.

swissspidy commented 4 years ago

An important detail for next-page-no-ad from the docs:

The AMP runtime makes the ad call as early as possible and places the first one sometime after the first two pages, and never as the last page.

That means the next-page-no-ad setting would be irrelevant on the first and last page.