extensions/amp-ad-network-adsense-impl/amp-ad-network-adsense-impl-internal.md
AdSense implementation of AMP Ad tag which requests early by XHR and renders natively within the page if a valid AMP Ad is returned. Should not be directly referenced by pages and instead is dynamically loaded via the amp-ad tag. However, in order to remove an async script load of this library, publishers can include its script declaration.
<table> <tr> <td width="40%"><strong>Availability</strong></td> <td>General Availability</td> </tr> <tr> <td width="40%"><strong>Required Script</strong></td> <td><code><script async custom-element="amp-ad" src="https://cdn.ampproject.org/v0/amp-ad-0.1.js"></script></code></td> </tr> <tr> <td width="40%"><strong>Examples</strong></td> <td>TBD</td> </tr> </table>The <amp-consent> element can be used to block the ad request until the user or AMP consent checkConsentHref end point provide consent state. After the amp-consent extension has been configured (please refer to its documentation), it can be linked to the amp-ad element via the data-block-on-consent attribute.
If the user has responded negatively to the amp-consent component (user rejects the consent prompt), RTC call-outs will not be made and non-personalized ads will be requested.
If the user’s response to the amp-consent is unknown (user dismisses the consent prompt), by default, no ad requests are sent.
If data-npa-on-unknown-consent is set to true, non-personalized ads will be requested.
The amp-consent response may set the following fields in the sharedData object for additional controls:
See AdSense Help Center article and Restricted Data Processing article for more information.
Example - AdSense Ad
<amp-ad
width="300"
height="200"
type="adsense"
data-ad-client="ca-pub-8125901705757971"
data-ad-slot="7783467241"
>
</amp-ad>
always-serve-npa provides a way to utilize the <amp-geo> component to detect user's geo location to decide if a non-personalized ad should be requested from AdSense, regardless of the user's consent decision. The value of always-serve-npa should be a comma delimited string of geo group codes which are defined in <amp-geo> (details here). If no value is found or an empty string is provided, then a NPA will always be requested, regardless of the location.
<amp-ad
width="300"
height="200"
type="adsense"
always-serve-npa="geoGroup1,geoGroup2"
data-ad-client="ca-pub-8125901705757971"
data-ad-slot="7783467241"
>
</amp-ad>
<amp-geo>
<script type="application/json">
{
"ISOCountryGroups": {
"geoGroup1": [ "preset-eea", "unknown" ],
"geoGroup2": [ "preset-us-ca" ]
}
}
</script>
</amp-geo>
TODO: Add attributes