Track clicks & opens

Learn how to track link clicks and email opens using the Unipile API.

Unipile allows you to be notified through webhooks when an email is opened or a link is clicked by the recipient.


Setup

1. Configure a webhook

Configure a webhook to receive the wanted events:

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

2. Send your email from Unipile

To enable tracking, send your email with the Send an Email method and provide:

  • An html content (only plain_text won't work)
  • Tracking options with clicks: true to track link clicks and opens: true to track email opens.
  • An optional label to be sent in the webhook payload. This can be used to identify the sent mail.
  • An optional custom_domain to use a verified and application-enabled white-label domain for click and open tracking. Before using it, follow Custom Domains and point its CNAME record to track.lnk-fllw.com.

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,
      clicks: true,
      label: 'marketing',
      custom_domain: 'tracking.example.com'
    },
  },
});
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,
            "clicks": True,
            "label": "marketing",
            "custom_domain": "tracking.example.com",
        },
    },
)
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,
    "clicks": true,
    "label": "marketing",
    "custom_domain": "tracking.example.com"
  }
}
'

Exclude a link from click tracking

When click tracking is enabled, Unipile rewrites links in the HTML content so clicks can trigger tracking.click.
To leave a specific link unchanged, add the data-disable-tracking attribute to its <a> element:

<a href="https://example.com/privacy" data-disable-tracking>Privacy policy</a>

The presence of the attribute disables click tracking for that link, regardless of its value. Other links in the same
email remain tracked, and open tracking is not affected.


3. Handle events

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

{
  "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

Did this page help you?