AdSense For Shopping - Backfill with AFS
Description

This is an example of AdSense for Shopping (AFSh) ads backfilled with AFS. If no AFSh ads are returned, a subsequent request for AFS ads will be made.

AMP ad attributes:
  • type - Must be set to "csa".
  • height - Should be set to the same value you used for the height parameter in data-afsh-adblock-options.
  • data-afsh-page-options - AFSh page options as a string, in the same way you would specify the options in a normal web request.
  • data-afsh-adblock-options - AFSh block options as a string.
    • Set the width parameter to "auto" for best results.
    • No need to set the container parameter.
  • data-afs-page-options - AFS page options as a string. This will be used in case AFSh does not return ads.
  • data-afs-adblock-options - AFS block options as a string. This will be used in case AFSh does not return ads.
    • Set the width parameter to "auto" for best results.
    • No need to set the container parameter.
Additional requirements & information:
  • Although the page options containing the query parameter are passed as a string, you must dynamically change the query to match the actual search query.
  • Each amp-ad tag contains one adblock; only one data-afsh-adblock-options attribute and one data-afs-adblock-options attribute can be specified in the tag.
  • The query parameter in data-afsh-adblock-options must be the same as the query parameter in data-afs-adblock-options.


AMP Ad Tag


<amp-ad 
  height=400
  type="csa"
  data-afsh-page-options='{"pubId": "partner-vert-pla-pub-id", "query": "user search query"}'
  data-afsh-adblock-options='{"width": "auto", "height": 400}'
  data-afs-page-options='{"pubId": "partner-pub-id", "query": "user search query"}'
  data-afs-adblock-options='{"width": "auto", "number": 2}'>
</amp-ad> 
              
AMP Demo
Note: Emulate with a mobile user agent for accurate rendering.