I have no idea what code I need to place in the document referenced by the URL for checkConsentHref.
I've used the example code from https://amp.dev/documentation/examples/user-consent/basic_user_consent_flow/?format=websites.
I know the checkConsentHref should be my own url, but what document needs to go in that location and what code should go in it?
<amp-consent layout="nodisplay" id="consent-element">
<script type="application/json">
{
"consents": {
"my-consent": {
"checkConsentHref": "https://example.com/api/show-consent",
"promptUI": "consent-ui"
}
}
}
</script>
</amp-consent>
I expect there to be some function at checkConsentHref location to take some kind of action.
I found a good explanation here: About consent
A CORS endpoint can be specified via the checkConsentHref
attribute. The amp-consent component
will check via a POST request if the consent UI needs to be shown. The response to this request should look like this:
{
"promptIfUnknown": true
}
#or
{
"promptIfUnknown": false
}
So you can add there e.g https://ampbyexample.com/samples_templates/consent/getConsent
First time I saw this url, I thought that it is only exapmle, but it works.
This url store information about showing the consent. You can check it in your JS
console.
https://ampbyexample.com/samples_templates/consent/getConsent
will returns "promptIfUnknown": true
or "promptIfUnknown": false
based on previous user action
I do not know If it is a good practice to use this "example" url instead own.