ads/vendors/csa.md
To request AdSense for Search ads on the Custom Search Ads protocol, use the data-afs-page-options and data-afs-adblock-options attributes in the amp-ad tag. The values you pass should be set to a stringified version of the Javascript object you would pass in the ad request of a standard CSA request.
<amp-ad
height="300"
type="csa"
data-afs-page-options='{"pubId": "partner-pub-id", "query": "flowers", "styleId": "123456789"}'
data-afs-adblock-options='{"width": "auto", "number": 2}'
>
</amp-ad>
Please see documentation for AdSense for Search for more information.
To request AdSense for Shopping ads on the Custom Search Ads protocol, use the data-afsh-page-options and data-afsh-adblock-options attributes in the amp-ad tag. The values you pass should be set to a stringified version of the Javascript object you would pass in the ad request of a standard CSA request.
<amp-ad
height="300"
type="csa"
data-afsh-page-options='{"pubId": "partner-vert-pla-pubid-pdp", "query": "flowers", "styleId": "123456789"}'
data-afsh-adblock-options='{"width": "auto", "height": 300}'
>
</amp-ad>
To request an AFSh ad with a width equal to the screen width, use "auto" for the CSA width parameter. Please note that "auto" width is not supported in non-AMP implementations.
Note that only the multiple-format AdSense for Shopping ads are supported under this integration.
Please see documentation for AdSense for Shopping for more information.
To request AFS ads when AFSh does not return any ads, include both the data-afs-* and data-afsh-* attributes in the amp-ad tag. If AFSh does not return ads, AMP will request AFS ads with the values from the data-afs-* attributes.
<amp-ad
height="400"
type="csa"
data-afsh-page-options='{"pubId": "partner-vert-pla-pubid-pdp", "query": "flowers"}'
data-afsh-adblock-options='{"width": "auto", "height": 400}'
data-afs-page-options='{"pubId": "partner-pub-id", "query": "flowers", "channel": "backfill"}'
data-afs-adblock-options='{"width": "auto"}'
>
</amp-ad>