implement <amp-consent>
in the site’s HTML to display user messages and collect user consent using AMP pages
. This requires inserting two code snippets on your site’s AMP pages.
Locate and insert the HTML code:
- Sign in to Google Ad Manager.
- Click Privacy & messaging.
- Click Manageon one of the message type cards on the Privacy & messaging page.
- Click Tags & SDKs.
- Click AMP site tagto expand the section.
- On your site's AMP pages where you want to display a European regulations message:
- Copy the first code snippet from the "Ad Manager Tags & SDKs" page and paste it between the
<head>and</head>tags on the AMP pages where you want to display a European regulations message.Code sample
<head>
…
<script async custom-element="amp-consent" src="https://cdn.ampproject.org/v0/amp-consent-0.1.js"></script>
<script async custom-element="amp-iframe" src="https://cdn.ampproject.org/v0/amp-iframe-0.1.js"></script>
…
</head> - Copy the second code snippet from the Ad Manager Tags & SDKs page and paste it in the content area of the HTML code on the AMP pages where you want to display a European regulations message.
Code sample
<amp-consent id="googleFC" layout="nodisplay" type="googleFC">
<script type="application/json">
{
"postPromptUI": "fcConsentRevocation", // may be removing on all but policy pages
"clientConfig": {
"publisherIdentifier": "pub_id"
}
}
</script>
<div id="fcConsentRevocation">
<button on="googleFC.prompt(consent=googleFC, expireCache=true)">Manage Privacy Options</button>
</div>
</amp-consent>
- Copy the first code snippet from the "Ad Manager Tags & SDKs" page and paste it between the
Meta tag is required
Sites using a consent management platform (CMP)
to manage consent gathered under TCF v2.2 must include a <meta>
tag
on their pages. The <meta>
tag is included in the first line of code, and it can be customized for your needs.
Block nothing
To prevent <amp-consent>
from blocking any components on a page, insert the following code between the <head>
and </head>
tags:
If you choose not to block any components, all elements on the page will display. Use data-block-on-consent
to override this setting on individual amp-ad
and amp-analytics
elements.
Block only amp-ad
To allow <amp-consent>
to block amp-ad on a page, insert the following code between the <head>
and </head>
tags:
<meta name="amp-consent-blocking" content="amp-ad">
Block amp-ad and amp-analytics
To allow <amp-consent>
to block amp-ad and amp-analytics on a page, insert the following code snippet between the <head>
and </head>
tags:
By default, amp-ad
and amp-analytics
are blocked in the code snippet on the "Tags & SDKs" tab in Privacy & messaging. Add additional AMP extensions
to the content attribute to customize the components blocked on the page.
Consent revocation
Consent revocability is a requirement of the Privacy & messaging user consent program. Ensure you include a consent revocation link on your data, cookie, or privacy policy page before publishing consent message

