1

Im trying to send a email template along with a URL whose click count should be tracked using SparkPost APIs?

Example: if I give www.google.com its has to change to

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>"
  }
}
Grokify
  • 15,092
  • 6
  • 60
  • 81
Puneeth Kumar
  • 182
  • 2
  • 14

1 Answers1

0

To enable "click tracking", set options.click_tracking=true field in your request. You have already done this but it looks like your links in the content.html are not HTML anchors (<a> tags) but just plain text links.

SparkPost will only track HTML anchors so I suggest changing this:

http://www.example.com

to this:

<a href="http://www.example.com">www.example.com</a>

Ewan Dennis
  • 396
  • 1
  • 3
  • This doesn't work, the link still gets changed to http://go.sparkpostmail1.com/f/a/EgvUoS2LdGPzMx... and when I click on the link, I get a "this site can't be reached" error. – Lewy Blue Oct 28 '18 at 08:45