【问题标题】:Can I add script tags to sendGrid templates?我可以将脚本标签添加到 sendGrid 模板吗?
【发布时间】:2017-01-31 12:12:03
【问题描述】:

我正在尝试将以下脚本添加到 sendgrid 模板中

<script type="application/ld+json">
{
  "@context": "http://schema.org",
  "@type": "EmailMessage",
  "potentialAction": {
    "@type": "ViewAction",
    "target": "https://watch-movies.com/watch?movieId=abc123",
    "name": "Watch movie"
  },
  "description": "Watch the 'Avengers' movie online"
}
</script>

保存 sendgrid 模板时,它显示已保存成功,但实际上刷新时并没有保存。我猜 sendgrid 不允许将脚本添加到电子邮件中。 我的目的是添加 gmail 操作(请参阅 https://developers.google.com/gmail/markup/reference/go-to-action

【问题讨论】:

    标签: sendgrid


    【解决方案1】:

    编辑:再次阅读 Google gmail documentation。我的猜测是,出于安全原因,Sendgrid 可能会删除脚本标签,因此您可以使用 div 标签来代替,并结合以下我的建议。

    <div itemscope itemtype="http://schema.org/EmailMessage">
      <div itemprop="potentialAction" itemscope itemtype="http://schema.org/ViewAction">
        <link itemprop="target" href="https://watch-movies.com/watch?movieId=abc123"/>
        <meta itemprop="name" content="Watch movie"/>
      </div>
      <meta itemprop="description" content="Watch the 'Avengers' movie online"/>
    </div>
    

    我目前在通过 sendgrid 为 gmail 添加号召性用语时面临类似的挑战。

    我认为有 3 种不同的选择:

    首先,如果您想添加自定义 html,您可能需要import it as a module。这里是some examples

    这里有另外两个潜在的解决方案:

    1. 使用The Code Editor 创建一个新模板
    2. 导入您之前使用The Design Editor 创建的模板
    3. 在代码编辑器中将架构脚本 sn-p 添加到您的模板中

    你也可以试试editing the HTML head

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-05-02
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多