Track clicks & opens

Learn how to track links click and emails opening using Unipile API.

Unipile allow you to be notified when an email is open or a link is clicked by the recipient using webhooks.


Setup

1. Configure a webhook

Configure a webhook to receive the wanted events:

  • tracking.open to be notified when an email is open
  • tracking.click to be notified when a link is clicked

2. Send your email from Unipile

To make this works, send your Emails with Send an Email method and provide:

  • An html content (only plain_text won't work)
  • Tracking options with links: true to track clicked links and opens: true to track opened emails.
  • An optional label to be sent in the webhook payload. This can be used to identify the sent mail.
  • An optional custom_domain pointing to https://tracking.unipile.com/ to keep a white label on links tracking.

You can also specify those options on Create a Draft method then send it with Send a Draft.

await emailsApi.sendEmail({
  path: {
    account_id: "acc_123456789",
  },
  body: {
    to: [
      {
        display_name: 'John Doe',
        email: '[email protected]',
      },
    ],
    subject: 'Hello',
    html: '<a href="https://unipile.com">This link will be tracked</a>',
    tracking_options: {
      opens: true,
      links: true,
      label: 'marketing'
    },
  },
});
emails_api.send_email(
    "acc_123456789",
    {
        "to": [
            {
                "display_name": "John Doe",
                "email": "[email protected]",
            }
        ],
        "subject": "Hello",
        "html": '<a href="https://unipile.com">This link will be tracked</a>',
        "tracking_options": {
            "opens": True,
            "links": True,
            "label": "marketing",
        },
    },
)
curl --request POST \
     --url https://api.unipile.com/v2/account_id/emails/send \
     --header 'accept: application/json' \
     --header 'content-type: application/json' \
     --data '
{
  "to": [
    {
      "display_name": "John Doe",
      "email": "[email protected]"
    }
  ],
  "subject": "Hello",
  "html": "<a href=\"https://unipile.com\">This link will be tracked</a>",
  "tracking_options": {
    "opens": true,
    "links": true,
    "label": "marketing"
  }
}
'

3. Handle events

In your webhook handler, you should now receive events with the following payload if the recipient opens or click a link in the email.

{
  "ip": "127.1.1.1",
  "user_agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/127.0.0.0 Safari/537.36",
  "date": "2025-08-14T14:30:00Z",
  "label": "marketing"
}
{
  "url": "https://mylink.com",
  "ip": "127.1.1.1",
  "user_agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/127.0.0.0 Safari/537.36",
  "date": "2025-08-14T14:30:00Z",
  "label": "marketing"
}

What’s Next