AdSense For Shopping - Above the Fold
Description

This is an example of AdSense for Shopping (AFSh) ads placed above the fold. See the reference documentation for more information about AFSh.

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.
Additional requirements & information:
  • You must use a fallback div to show alternate content when no ads are returned. If no ads are returned the ad will not be collapsed because it is above the fold.
  • 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.


AMP Ad Tag


<amp-ad 
  height=200
  type="csa"
  data-afsh-page-options='{"pubId": "partner-vert-pla-pub-id", "query": "user search query"}'
  data-afsh-adblock-options='{"width": "auto", "height": 200}'>
  <div fallback>Content for when no ads are returned.</div>
</amp-ad> 
              
AMP Demo
Note: Emulate with a mobile user agent for accurate rendering.