We have finished developing a CMP according to IAB TCFv2 and are struggling to integrate it with AMP, because amp-consent doesn't make the consent string available to the CMP prompt and ads.
Publisher code:
<amp-consent id="myUserConsent" layout="nodisplay">
<script type="application/json">{
"consentInstanceId": "consent-id",
"consentRequired": true,
"promptUI": "consentDialog",
"postPromptUI": "post-consent-ui",
"checkConsentHref": "https://open-cmp.local:5003/consent/check",
"onUpdateHref": "https://open-cmp.local:5003/consent/update"
}</script>
<div class="popupOverlay" id="consentDialog">
<amp-iframe layout="fill" src="https://open-cmp.local:5003/demo/amp/cmp-frame.html"
sandbox="allow-scripts allow-same-origin">
<div placeholder>Loading</div>
</amp-iframe>
</div>
<div id="post-consent-ui">
<button on="tap:myUserConsent.prompt()">Update Consent</button>
</div>
The Iframe is sending back the consent string according to the user's settings:
window.parent.postMessage({
type: 'consent-response',
info: "the consent string",
action: 'accept'
}, '*');
According to AMP documentation, the consent string is made available to amp-ad and also to the CMP prompt when the user wants to make changes:
Client information passed to iframe When the iframe is created, the following information will be passed to the iframe via the name attribute.
but window.name is always set to a plain string which contains the name of the iframe, i.e. amp_iframe0, there is no JSON like data. I also tried window.context which is always undefined.
The second challenge is, how can I make sure that the consent string is made available in amp-ad and to other components? I tried a amp-iframe, but the consent string isn't there.
All the articles, discussions and docs in the web are a little bit confusing/outdated/inconsistent, I really appreciate if someone could point me in the right direction.