Email templates and open and click tracking
Write the email once, send it a million times, and see who opened it and what they clicked.
Save a template
A template is a subject and an HTML or text body, or both, with {{placeholders}} where each recipient's values go. Save it once, in the console under Templates or by API, and send it by its id. Its variables list names every placeholder it uses.
curl -X POST https://api.woyra.io/v1/templates \
-H "Authorization: Bearer $WOYRA_KEY" -H 'Content-Type: application/json' \
-d '{
"name": "Receipt",
"subject": "Your receipt, {{name}}",
"html": "<p>Hi {{name}}, you paid {{amount}}.</p>"
}'Send it
Give template_id and the variables for this recipient instead of subject and html. Values are HTML-escaped where they land in the HTML body, so a customer's name can never become markup; they are written as they are into the subject and the text body. A placeholder with no value refuses the send and names it, because "Hi ," reaching a customer is worse than an error. Everything else on a send works with a template: several recipients, scheduling, batches.
curl -X POST https://api.woyra.io/v1/emails \
-H "Authorization: Bearer $WOYRA_KEY" -H 'Content-Type: application/json' -H 'Idempotency-Key: receipt-77' \
-d '{
"from": "billing@yourdomain.com",
"to": "alex@example.com",
"template_id": "tmpl_01J...",
"variables": { "name": "Alex", "amount": "$12.00" }
}'Track opens and clicks
Add track_opens and track_clicks to a send. Opens are recorded by an invisible image in the HTML body; clicks by routing each web link through Woyra on its way to the same address. The first open, and the first click on each link, join the email's timeline and send email.opened and email.clicked to your webhooks, with the link that was clicked. Both are off unless you ask for them.
{
"type": "email.clicked",
"data": {
"email_id": "email_01J...",
"to": "alex@example.com",
"url": "https://yourapp.com/orders/77"
}
}Tracked links are signed: Woyra only ever redirects a reader to the address your email contained, and a link that has been altered is refused rather than followed.
Questions
Can I change a template after sending with it?
Yes. Emails already accepted keep what they were sent with; sends from then on use the new version. Deleting a template refuses any later send that names it.
Does tracking cost anything?
No. An email costs the same tracked or not.
Which links are tracked?
Every http and https link in the HTML body. Mail and telephone links, in-page anchors and the plain-text body are left alone.
Next
Get a test key and run any of this in about ninety seconds.