I2I: Support CMP Integration with <amp-consent>
To #15653
Overview
The following sections will try to answer these questions:
- What to include in the prompt dialog and how to allow CMP to customize it?
- What is the blocking behavior with CMP?
- What the data flow looks like between different parties?
- What the CMP needs to do to integrate with AMP?
- What does a publisher need to do to include a CMP solution on their AMP page?
Background
<amp-consent> provides a solution for publishers to collect user consent and block or unblock any AMP component in an AMP page. Currently, this solution only allows the publisher to collect a boolean consent for all vendors in the consent UI.
To support per purpose and per vendor based consents and allow for third party integration from Consent Management Platforms (CMP) with publisher AMP pages, AMP will enhance <amp-consent>. It will allow for richer interaction between the publisher page, vendors, CMP and ad extensions on AMP pages that need to know about the consent status. AMP must make such an API for CMPs because AMP doesn’t allow custom JavaScript to run on the page and therefore a CMP must integrate with the AMP framework to integrate with a publishers page.
Data Flow Desing

The following section explains each step in terms of data structure and API.
Read data from localStorage (Step 1)
Data includes the stored consent string and CMP stored information.
Pass information to CMP endpoint (Step 2)
The following data with be passed through a POST request
{
'consentInstanceId': string,
'consentStr': string,
'pubConfig': object,
'cmpStoredData': string,
}
CMP endpoint response (Step 3)
Endpoint returns a JSON object
{
'promptIfUnknown': boolean,
'sharedData': object,
'forcePrompt': boolean, //optional
}
Initiate the UI iframe (Step 4)
Data will be stringified and passed via the iframe name attribute
JSON.stringify({
'publicConfig': object,
'cmpStoredData': string,
'consentStr': string,
})
Iframe returns user decision (Step 5)
UI iframe will pass the consent information back to <amp-consent> via postMessage
window.parent.postMessage({
type: 'consent-response',
cmpStoredData: '',
consentStr: '',
action: 'accept/reject/dismiss'
}, '*');
consentStr is required to pass the value to vendors.
action is optional. When specified, it instructs components that don’t understand consent string to load or not based on the publisher’s configurations.
cmpStoredData value will be stored per the CMP request
Store consent information (Step 6)
Store the consentStr and the cmpStoredData to localStorage
Pass consent information (Step 7)
AMP components on the AMP page (vendors in the format <amp-ad type=${vendorName})> can access consent information with function call
getConsentPolicySharedData(ampdoc, policyId)
Where the function returns an object that merge the value of consentStr and sharedData
{
'consentStr': string,
'sharedData': object
}
Blocking Behaviors
Default Blocking Behaviors
When a CMP is present on the page, AMP runtime behavior will default to:
- Block all
<amp-ad>components on the page from rendering - Send request to the CMP endpoint to ask whether consent is required
- If no -> Stop here
- Check if there’s a response stored in the AMP runtime, or the CMP endpoint returned with a response
- If yes -> Unblock
<amp-ad>and pass the response to them - If no -> Prompt the consent collect dialog in a foreign iframe
- If yes -> Unblock
- Get the response from the prompted iframe Store the response as instructed.
- Unblock all
<amp-ad>components (unless the publisher specifies not to by adding thedata-block-on-consentattribute) and passesthe response to them.
Special Cases
Publishers can override the default behavior and customize the blocking behaviors by tagging the components manually.
- If a publisher wants to avoid ad blocking with a CMP,: Use
<amp-ad data-block-on-consent=”_never”> - If the publisher wishes to block a component other than
<amp-ad>: Use the existingdata-block-on-consentattribute. However, the value of the returned action (accept/reject/dismiss), depends on the agreement between the publisher and the CMP.
Prompt Window
External Iframe
AMP consent will load and render the CMP’s prompt UI in a cross domain iframe, where the CMP will have full control. However, AMP runtime will control the life cycle of the iframe, dictating when to load or unload it.
- The iframe will be loaded if a user consent is required but missing, or if a user wants to manage their consent at any point.
- The iframe will be unloaded once a user decision has been made and the prompt UI needs to be hidden.
Default placeholder
AMP will apply a placeholder before the CMP iframe loads to improve user experience. The placeholder will not block the user from interacting with the rest of the page. UX design will be added once ready.
Iframe Size and Placement
AMP will make the prompt UI interstitial by default. CMP and publishers will NOT be able to customize the size and the placement of the iframe. AMP will create a modal layer and place the iframe with default aspect width and height ratio in the center.
Consent String
Consent string contains the user decision and will be stored and passed to vendors. Vendors will interpret the consent string and respond accordingly.
Format
Because different CMPs want to store different consent strings for customized vendors in addition to the IAB consent string, AMP will not enforce format on the consent string, or attempt to interpret the consent string before passing the information to vendors. AMP would require CMP to indicate their string as IAB so that vendors can understand. Please note in MVP, not API will be provided to vendors, and vendors need to interpret consent string themselves.
Storage Limit
When the cached AMP page is served from the google.com. All information will be stored under the google.com domain. Because of it, AMP consent has to be very cautious of the storage usage.
In order to be space efficient, AMP restricts the size of total stored value to an upper limit of 300 bytes. That includes the consent string and the CMP private stored string, if one exists. CMPs should work with their partner vendors to compress their consent string.
In the case that a CMP asks AMP to store information that exceeds the size limit, AMP will:
- Erase the current stored value
- Log an error
- Unblock
<amp-ad>components and make the consent string information globally accessible to all AMP components the consent string information but w/o storing the value for next visit.
Access
The consent string is made available to all AMP components on the page and to the CMP.
-
To AMP components and vendors
AMP components can call where the policyId can be interpreted from the data attribute.
getConsentPolicySharedData(ampdoc, policyId)3P ad that integrate with AMP can find the string at (similar to supported sharedData)
window.context.consentString -
To CMP
-
CMP will have access to the consent string. Per their request a CMP will also have access to the CMP stored data. Note that passing CMP stored data is not in scope with the initial implementation.
-
The stored value will be divided into two parts.
- Standard Consent string
- Private CMP stored string
Where consent string can be shared to all components, stored string will only be shared with the CMP.
-
CMP Integration
A CMP named foo_bar will integrate with AMP in the following way.
Check in configuration
Add the configuration as part of the <amp-consent> codebase. This will allow AMP to recognize the CMP, perform steps to check if consent is necessary, handle storage and UI.
'foo_bar': {
‘storageKey’: ‘cmp_foo_bar’,
'checkConsentHref': 'https://foo-bar.com/amp/endpoint',
'promptUISrc': 'https://foo-bar.com/cmp.html',
}
storageKey instructs AMP runtime to store the consent information under this unique key name. Note: AMP will append prefix to the key. If not specified, AMP will assume CMP does not require consent string to be stored client side.
Unlike the current DIY approach with <amp-consent>, CMP will be able to specify the storage key value instead of publishers. This is easier for CMP to bump up versions because they have control of the storageKey.
checkConsentHref is a field AMP consent already supports. It allows the AMP consent component to ask the CMP if consent is required for a user. This field is required, as it is the key to instruct AMP runtime to ask for consent and block other components on the page. For more details, please refer to the section here
Note:the existing promptIfUnknowForGeoGroup for CMP integration won’t be provided as AMP expects CMP to host their own endpoint instead of depending on publishers configuration on the <amp-geo> component.
src is the source for the foreign iframe. It is also a required field. Once AMP consent decides to prompt, it will create a foreign iframe with the src given.
Host endpoint
AMP consent will rely on the host endpoint to determine if the prompt is required with the checkConsentHref request.
Consent Dialog
The CMP will need to modify their prompt logic to function in a cross domain iframe. And communicate with the parent host AMP page through the proposed communication APIs.
Publisher’s Configuration
To work with a CMP, publisher’s configuration will need to stay minimal.
<amp-consent id="ABC" type="foo-bar" layout="nodisplay">
<script type="application/json">{
“cmp”: {
“token”: xxx
}
}</script>
</amp-consent>
Type Attribute
A type attribute with a valid CMP name value instructs the <amp-consent> component to load the CMP config.
CMP Object
All configuration within the cmp object will be passed to the CMP, both with checkConsentHref and iframe (added to the name attribute).
PostPromptUI
CMP’s support to postPromptUI has not been discussed yet. Right now publishers can still put their own postPromptUI element on the page and reference the element.
<amp-consent id="ABC" type="foo-bar" layout="nodisplay">
<script type="application/json">{
"postPromptUI": "postPromptUI"
}</script>
<div id="postPromptUI">
Post Prompt UI
<button on="tap:ABC.prompt" role="button">Manage</button>
</div>
</amp-consent>
Other topics
Below is a list of topics we have talked about but not covered in the current design. We may look into supporting it in the future.
Allow publishers to still use the <amp-geo> component to reduce one roundtrip of latency
Provide support for CMP to store consent server side but not client side
Hi @jeffnordlund-ghost @jawadst @janwinkler, @waschnick and @consentmanager. Since you've previously expressed interest in amp-consent's ability to integrate with CMPs, we'd love to have you participate in our design review this Wed @ 1PM PT where we'll go over this component and it's design. Details in #17357. Please feel free to leave feedback on this issue in the mean time.
@jasti Thanks for pinging me, I'll definitely join!
Few thing I recall from the design review
- The concern about blocking analytics vendors
- There's no good way to support that with the current design
- Would require analytics offline mode to store events before user giving consent
- To follow up with some analytics vendors and see if they wish to be blocked.
- The concern about vendor list changes
- To introduce dirty bit to force ask user consent the next time they visit the page
- Decided to support the integration with
<amp-geo>with CMP integration as it provides faster experience for users that doesn't require consent. - storage limit concern
- CMP use the client side storage as their primary source of storage.
- We'll start with 300 bytes limit and work on the LRU/LRR to expand the storage limit.
Hi @jeffnordlund-ghost @jawadst @janwinkler, @Waschnick and @consentmanager
we are looking for a CMP to integrate with the amp-consent API. Please let me know if you are interested and we can schedule a VC to go over integration details.
yes please :-)
Hi @lannka
We also have an IAB certified CMP, deployed in several sites, what we'd like to integrate with AMP. I'd appreciate a lot if you could keep me in the loop regarding this
Thanks!
@lannka Happy to help! We already have a first setup running with the existing amp-consent at Didomi so happy to see how the new version would perform with that.
Sure, we would like to explore a better integration with the amp-consent api.
Thanks all. @consentmanager @oliverfernandez @jawadst @jeffnordlund-ghost If you have a launched CMP product, could you share a link?
Also what's your timezone so we can schedule a VC.
Its http://www.consentmanager.net Timezone is CET
You can find and example of our CMP working here (mobile only): https://nospensees.fr/
My timezone is CET as well
@consentmanager @oliverfernandez @jawadst @jeffnordlund-ghost Thank you all for the interest. We scheduled a meeting on Thursday. Time: 2018-09-13 15:30 UTC (add to Google Calendar) Location: Video conference via Google Hangouts
To #17983 for meeting details. Please let us know if you plan to attend or suggest a different time. Thanks.
@zhouyx works for me
@consentmanager @jawadst @jeffnordlund-ghost in case you didn't see. are you able to join us tmr?
Yes, will be there
@lannka That works for me as well
Sorry, I’ve been out of the office for a bit and just catching up.
I might be able to join (if it hasn’t happened yet). My timezone is MST (in the US). I thought I saw a mail with the date/time earlier but I’m not seeing it now. When are you looking to schedule this?
Thanks!
- Jeff
From: Hongfei Ding [email protected]
Reply-To: ampproject/amphtml [email protected]
Date: Wednesday, September 12, 2018 at 7:59 PM
To: ampproject/amphtml [email protected]
Cc: Jeff Nordlund [email protected], Mention [email protected]
Subject: Re: [ampproject/amphtml] I2I: Support CMP Integration with
@consentmanagerhttps://emea01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fconsentmanager&data=02%7C01%7Cjeff.nordlund%40crownpeak.com%7C238b63efda5f4c0ce4ff08d6191c8797%7Ca5a244c1af69471fb4c7ae6e94586df5%7C0%7C0%7C636724007657104766&sdata=FhEa0FQB1GAo274LLa7aoFrA4JYEfjbKQp2CiUA5e0s%3D&reserved=0 @jawadsthttps://emea01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fjawadst&data=02%7C01%7Cjeff.nordlund%40crownpeak.com%7C238b63efda5f4c0ce4ff08d6191c8797%7Ca5a244c1af69471fb4c7ae6e94586df5%7C0%7C0%7C636724007657104766&sdata=93UCkKp%2BfaLczXwEepx2z1pnCa5xtPOBdgs8Er3oR04%3D&reserved=0 @jeffnordlund-ghosthttps://emea01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fjeffnordlund-ghost&data=02%7C01%7Cjeff.nordlund%40crownpeak.com%7C238b63efda5f4c0ce4ff08d6191c8797%7Ca5a244c1af69471fb4c7ae6e94586df5%7C0%7C0%7C636724007657114774&sdata=CotWh9hfJRYk6FyXcih5dn7LPY9EYyI5auTbQoSGS3c%3D&reserved=0 in case you didn't see. are you able to join us tmr?
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHubhttps://emea01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fampproject%2Famphtml%2Fissues%2F17742%23issuecomment-420857254&data=02%7C01%7Cjeff.nordlund%40crownpeak.com%7C238b63efda5f4c0ce4ff08d6191c8797%7Ca5a244c1af69471fb4c7ae6e94586df5%7C0%7C0%7C636724007657124782&sdata=utwcKcqXU5G3AceOkBp6OjjtPQwttlG%2BOSGPONV3g6c%3D&reserved=0, or mute the threadhttps://emea01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fnotifications%2Funsubscribe-auth%2FAIP0R6Xu9gS6KxkFQthsnMuxDlUDMQbKks5uabv7gaJpZM4WOiEN&data=02%7C01%7Cjeff.nordlund%40crownpeak.com%7C238b63efda5f4c0ce4ff08d6191c8797%7Ca5a244c1af69471fb4c7ae6e94586df5%7C0%7C0%7C636724007657124782&sdata=6YtJsqegpX%2B674jw1irTeMZN9Gll8M%2F9pSF57yzDJ3Y%3D&reserved=0.
Empower - September 26-27 2018 In New York
@zhouyx There is an IAB Techlab call at that time that a lot of us are likely to attend. Can we do Friday instead?
Thank you @jawadst for the heads up. Would the same time on Friday, 2018-09-21 15:30 UTC work for everyone? If so I'll go ahead and change the invitation.
Please let us know. Thanks
Works for me