Updated over a month ago
Need to add this part of the code inside <head>
:
<script async custom-element="amp-geo" src="https://cdn.ampproject.org/v0/amp-geo-0.1.js"></script>
<script async custom-element="amp-consent" src="https://cdn.ampproject.org/v0/amp-consent-0.1.js"></script>
And this part of the code inside <body>
:
<amp-geo layout="nodisplay">
<script type="application/json">
{
"ISOCountryGroups": {
"eea": ["preset-eea", "unknown"]
}
}
</script>
</amp-geo><amp-consent id="consent" layout="nodisplay" type="opencmp">
<script type="application/json">
{
"promptIfUnknownForGeoGroup": "eea",
"postPromptUI": "opencmp-consent-prompt-ui",
"clientConfig": {}
}
</script>
<div id="opencmp-consent-prompt-ui">
Post Prompt UI
<button on="tap:consent.prompt(consent=opencmp)" role="button">
Privacy Settings
</button>
</div>
</amp-consent>
Where {domain}
is the name of your site. Replace the placeholder with a domain without www or HTTP
And change ad tag
(add gdpr_consent and data-block-on-consent parameters):
<amp-ad data-block-on-consent="_auto_reject" width="300" height="250" type="doubleclick" data-slot="/213794966/amp/{domain}" data-enable-refresh="30" data-multi-size="1x1,200x200,312x260,250x250,320x100,320x50,300x250" rtc-config='{"urls":["https://pb.vuukle.com/openrtb2/amp?tag_id={domain}&w=ATTR(width)&h=ATTR(height)&ow=ATTR(data-override-width)&oh=ATTR(data-override-height)&ms=ATTR(data-multi-size)&slot=ATTR(data-slot)&targeting=TGT&curl=CANONICAL_URL&timeout=TIMEOUT&adcid=ADCID&purl=HREF&gdpr_consent=CONSENT_STRING"]}' class="i-amphtml-layout-fixed i-amphtml-layout-size-defined" style="width:300px;height:250px;" i-amphtml-layout="fixed">
</amp-ad>
And it will look like:
There you can find an example
amp URL with the consent screen added - https://example-amp-with-consent.netlify.app/