【问题标题】:How to change normal urls to SparkPost Custom URL in SparkPost API using PHP?如何使用 PHP 在 SparkPost API 中将普通 URL 更改为 SparkPost 自定义 URL?
【发布时间】:2017-01-23 11:40:30
【问题描述】:

我正在尝试发送电子邮件模板以及应使用 SparkPost API 跟踪其点击次数的 URL?

示例:如果我给 www.google.com 它必须更改为

http://go.sparkpostmail1.com/f/a/EgvUoS2LdGPzMx-AURKwZA~~/AABUGAA~/RgRZK0BSP0EIAGukLuGW3OxXA3NwY1gEAAAAAFkGc2hhcmVkQgoAAVK7SFdpNVEbUhFuaWNvbGFzQGR1cmFuZC5jaAlRBAAAAABEUWh0dHBzOi8vZGlzaGx5Lm1lbnUvZC9XYXNoaW5ndG9uL1JlZ2VudF9UaGFpL0Jhc2lsX0phZS81NjBmMzk5MmQ0YWUxNTAzMDBmZWZmMGIiLEcCe30.

POST /api/v1/transmissions?num_rcpt_errors=3

 {
  "options": {
    "start_time": "now",
    "open_tracking": true,
    "click_tracking": true,
    "transactional": false,
    "sandbox": false,
    "ip_pool": "sp_shared",
    "inline_css": false
  },
  "description": "Christmas Campaign Email",
  "campaign_id": "christmas_campaign",
  "metadata": {
    "user_type": "students",
    "education_level": "college"
  },
  "substitution_data": {
    "sender": "Big Store Team",
    "holiday_name": "Christmas"
  },
  "recipients": [
    {
      "address": {
        "email": "wilma@flintstone.com",
        "name": "Wilma Flintstone"
      },
      "tags": [
        "greeting",
        "prehistoric",
        "fred",
        "flintstone"
      ],
      "metadata": {
        "age": "24",
        "place": "Bedrock"
      },
      "substitution_data": {
        "customer_type": "Platinum",
        "year": "Freshman"
      }
    }
  ],
  "content": {
    "from": {
      "name": "Fred Flintstone",
      "email": "fred@flintstone.com"
    },
    "subject": "Big Christmas savings!",
    "reply_to": "Christmas Sales <sales@flintstone.com>",
    "headers": {
      "X-Customer-Campaign-ID": "christmas_campaign"
    },
    "text": "Hi  \nSave big this Christmas in your area ! \nClick http://www.example.com and get huge discount\n Hurry, this offer is only to \n ",
    "html": "<p>Hi  \nSave big this Christmas in your area ! \nClick http://www.example.com and get huge discount\n</p><p>Hurry, this offer is only to \n</p><p></p>"
  }
}

【问题讨论】:

    标签: php api url sparkpost click-counting


    【解决方案1】:

    要启用“点击跟踪”,请在您的请求中设置 options.click_tracking=true 字段。您已经这样做了,但看起来content.html 中的链接不是 HTML 锚(&lt;a&gt; 标记),而只是纯文本链接。

    SparkPost 将仅跟踪 HTML 锚点,因此我建议更改此设置:

    http://www.example.com

    到这里:

    &lt;a href="http://www.example.com"&gt;www.example.com&lt;/a&gt;

    【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-07-26
    相关资源
    最近更新 更多