【问题标题】:How to construct AMP cookie consent with the help of amp-story-consent?如何在 amp-story-consent 的帮助下构建 AMP cookie 同意?
【发布时间】:2020-05-21 07:16:03
【问题描述】:

我想向我的 AMP 静态网站添加 Cookie 同意。我想利用amp-story-consent 可以提供给我的模态对话框。我研究了各种各样的例子,也许最完整的是这个:

https://playground.amp.dev/?url=https%3A%2F%2Fpreview.amp.dev%2Fdocumentation%2Fexamples%2Fuser-consent%2Fstory_user_consent&format=websites(示例文档https://amp.dev/documentation/examples/user-consent/story_user_consent/?referrer=ampbyexample.com

我的问题是我只想显示JSON sn-p中定义的标题/消息/供应商

    <amp-story-consent id="consentUI" layout="nodisplay">
      <script type="application/json">
        {
          "title": "Headline",
          "message": "This is some more information about this choice. Here's a list of items related to this choice.",
          "vendors": ["Item 1", "Item 2", "Item 3", "Item 4", "Item 5", "Item 6", "Item 7", "Item 8", "Item 9", "Item 10"]
        }
      </script>
    </amp-story-consent>

加上一个接受和拒绝按钮。经 Cookie 同意,我实际上并没有任何 故事页面 或任何 故事书挡,但 AMP 验证规则似乎要求这样做。这是一个问题。操场上显示了一个拒绝/接受按钮对,我想要一个拒绝/接受对,但我看不到可以在哪里定义。

在裸露的amp-consent 文档中有按钮(请参阅https://amp.dev/documentation/components/amp-consent/ 处的“同意配置”):

<div id="consent-ui">
  <button on="tap:consent-element.accept" role="button">Accept</button>
  <button on="tap:consent-element.reject" role="button">Reject</button>
  <button on="tap:consent-element.dismiss" role="button">Dismiss</button>
</div>

有人有例子或指导吗?


注意https://amp.dev/documentation/components/amp-consent/ 有这个例子 sn-p。它显示“示例:在 AMP 故事中显示提示用户界面”

<amp-consent layout="nodisplay" id="consent-element">
  <script type="application/json">
    {
      "consents": {
        "my-consent": {
          "checkConsentHref": "https://amp.dev/documentation/examples/api/get-consent",
          "promptUI": "consent-ui"
        }
      }
    }
  </script>
  <amp-story-consent id="consent-ui" layout="nodisplay">
    <script type="application/json">
      {
        “title”: "My title",
        “message”: "My example message.",
        “vendors”: ["Item 1", "Item 2", "Item 3", "Item 4"]
      }
    </script>
  </amp-story-consent>
</amp-consent>

如何让它发挥作用? (正如我提到的,我没有任何 故事页面 或任何 故事书挡,正如 sn-p 所建议的那样)。

【问题讨论】:

标签: amp-html cookieconsent gdprconsentform ccpa


【解决方案1】:

您不能在amp-story 之外使用amp-story-consent,它必须有一定数量的amp-story-page 元素。

【讨论】:

  • 我想通了,但是“示例:在 AMP 故事中显示提示用户界面”中的 sn-p 没有任何页面。我开始开发它,我也加入了amp-story,但是对于一个简单的同意对话框来说,它不成比例。我应该往哪个方向走?
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多