amp-html - 如何在 amp 电子邮件中收集和存储动态数据?
问题描述
我对放大器很陌生。我无法理解用户响应数据如何对 amp 电子邮件发件人可见。例如,如果有一个表单,发件人将如何收集 amp 邮件收件人在表单中输入的数据
解决方案
AMP for Email 与 HTML 电子邮件非常相似,只是它让电子邮件发件人支持许多新功能。它可以包含您在问题中提到的表单提交等功能,除了交互式元素等......
AMP 的发件人需要有自己的后端系统来收集 AMP 电子邮件中提交的表单。例如,请参见以下实现:
<!doctype html>
<html ⚡4email>
<head>
<meta charset="utf-8">
<script async src="https://cdn.ampproject.org/v0.js"></script>
<script async custom-element="amp-form" src="https://cdn.ampproject.org/v0/amp-form-0.1.js"></script>
<script async custom-template="amp-mustache" src="https://cdn.ampproject.org/v0/amp-mustache-0.2.js"></script>
<style amp4email-boilerplate>body{visibility:hidden}</style>
<style amp-custom>
h1 {
margin: 1rem;
}
</style>
</head>
<body>
<form method="post"
action-xhr="https://example.com/subscribe" target="_top">
<fieldset>
<label>
<span>Email:</span>
<input type="email"
name="email"
required>
</label>
<br>
<input type="submit"
value="Subscribe">
</fieldset>
<div submit-success>
<template type="amp-mustache">
Subscription successful!
</template>
</div>
<div submit-error>
<template type="amp-mustache">
Subscription failed!
</template>
</div>
</form>
</body>
</html>
上面的代码包含一个基本的 AMP 电子邮件,其表单允许用户使用他们的电子邮件进行订阅。当用户提交表单时,电子邮件 id使用该方法发送到标签action-xhr
属性中给定的 URL。form
POST
如果操作成功,submit-success
则显示该块。否则submit-error
显示块。实现非常简单直接。您可以查看此链接以更好地理解这一点。
推荐阅读
- python-3.x - 调用函数时的变量
- ios - rn-fetch-blob - 对于没有扩展名 pdf 的文件,idownload 无法在 ios 上运行
- rust - 当我知道没有更多对其当前内容的引用时,如何对切片进行变异?
- three.js - Threejs存储和加载相机位置和方向
- docker - 无法使用 Serilog 在 Docker 上启动 .NET Core 3.1 Worker 服务
- lua - 我如何将这 2 个不同的 Lua 脚本合并到一个中?它适用于我的罗技鼠标,我无法组合这 2 个切换脚本
- javascript - 每次用户输入任何内容时,将对象永久存储在浏览器中
- java - QDSL 在实体与 ID 上调用 .eq()
- google-apps-script - Google 表格脚本:未调用函数
- c - 使用 C 语言和打开 MP 超过特定矩阵长度时的未定义行为