Reputation: 192
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
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": "[email protected]",
"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": "[email protected]"
},
"subject": "Big Christmas savings!",
"reply_to": "Christmas Sales <[email protected]>",
"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>"
}
}
Upvotes: 1
Views: 661
Reputation: 396
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>
Upvotes: 0