amp-htmlaccelerated-mobile-page

Disable default behavior while obtainig user consent


Suppose I want to prompt the amp-consent layer only if the user require it by himself, and not to show it up as long no option has been obtained.

My endpoint consists mostly of this code as proposed by the AMP itself:

echo json_encode(['promptIfUnknown' => 'false/true']);

I'm not sure, but for some reasons changing the name "promptIfUnknown" to something else for example "whatever" behaves in the required manner but i would rather apply it in the right way.

Is there any possibilty to disable the default functionality?


Solution

  • Any particular reason you're echoing it and encoding it with PHP and not just breaking out of your PHP tags to set up your amp-consent JSON?

    Also in your current configuration false/true are being output as a string and not a boolean value. I just pasted your echo into a PHP document I had open real quick and this is the output:

    {"promptIfUnknown":"false\/true"}
    

    false/true is being read as a string. The expected output for AMP should be something like:

    {"promptIfUnknown": true/false}
    

    Which would then return either a 1 or 0 depending on whether the prompt is required.