User guide

API reference


Tracking links

What is Link Tracking?

Like Open Tracking, Link Tracking is a method of collecting valuable information about how your recipients interact with the emails you send. Unlike Open Tracking, Link Tracking is not limited to HTML, and does not rely on the user allowing images in their email client. Any tracked link that the user clicks on will record statistics, regardless of whether it was clicked from the HTML or Text parts of the email. Link Tracking can also provide helpful diagnostics, such as determining if a particular recipient has clicked a link that was emailed to them.

How does it work? #

When Link Tracking has been enabled, links in your messages will be replaced with new links that route through Postmark servers. When an email recipient clicks on a tracked link, the URL is opened in their default browser. The browser will request the URL from one of our Postmark servers, at which point we record information about the user's location, what browser they are using, and in which part of the email the link was clicked (HTML or Text). While we record this information, we simultaneously redirect the user to the original URL in your email. The tracking domain that the user will see is click.pstmrk.it.

Links tracked by Postmark do not expire. Since services like Gmail retain emails for years, it's possible that your recipients may search for and follow links for a long time into the future. Each tracked link issued by Postmark contains all the necessary information to redirect to the original URL, even if you delete your Postmark Server, so the link you send to your recipients will continue to work for the foreseeable future. Our redirection infrastructure is also globally distributed and redundant, and we built it with the goal of making sure the link redirection is as transparent and fast as possible for your recipients.

Link Security #

All links tracked by Postmark are routed through our servers using HTTPS/TLS. Unlike other link tracking services that use non-encrypted HTTP connections, we ensure that eavesdroppers cannot capture the links sent to your recipients due to the redirection link using a non-encrypted HTTP URL. Transactional emails tend to contain recipient-specific links, so having "full-time" HTTPS for Tracked Links is an important protection that we believe is essential for your most important emails.

Requirements #

Account Approval

One of the pre-requisites for using our link tracking system is that you have created an account and gone through our normal account approval process. Once approved, you will be able to use the link tracking features provided by Postmark. Until your account is approved, no links will be encoded/tracked when sending emails through Postmark.

Proper encoding

Links must be properly encoded for both text and HTML. Including the following requirements:

  • Links must be well-formed, according to RFC-3986.
  • Links in HTML a elements must be HTML-encoded. We automatically HTML-decode the URLs when processing your HTMLBodyDo not HTML-encode links in your TextBody, doing so could potentially result in incorrect tracked links.
  • Links must be properly URL-encoded.
  • Domains with Unicode characters must use punycode to represent them properly in ASCII.
  • Links must include a http or https protocol to be properly tracked.

Please note that if a link that is in an email message is malformed or improperly URL-encoded, we will skip replacing it with a tracked link. This ensures that only links that can be redirected using http-level redirects will be issued by Postmark.

"Open Tag", only

While XML and XHTML allow you to include the href attribute in the closing tag of an element (i.e. </a href="" >), Postmark will not track these links.

Only HTTP and HTTPS are supported

There are many protocols that can be used with links (i.e. ftp://,ssh://,mailto:, etc.). Currently only http and https links will be encoded and tracked by Postmark Link Tracking.

Enabling Link Tracking #

Link Tracking Options

There are several variations of Link Tracking available from Postmark. Depending on your requirements, you can choose from the following options:

  • None - No links will be replaced or tracked. This is the default setting for all messages and new and existing servers.
  • HtmlAndText - Links will be replaced in both HTML and Text bodies. Identical links in either body part will be considered the "same" link, and only count as one unique click, regardless of which body part the recipient clicks from.
  • HtmlOnly - Links will be replaced in only the HTMLBody. This is useful in some cases where you do not want to include encoded tracking links in the plain text of an email.
  • TextOnly - Links will be replaced in only the TextBody. 

Setting the Tracking Type

After you have determined which type of Link Tracking you wish to use, you can enable it in several ways:

  • Server-level - You can set the TrackLinks property for the server where you wish to enable Link Tracking. This setting will be applied to all messages sent by the Server. However, individual messages sent through the API or SMTP may override this setting.
  • Message-level (API) - You can set the TrackLinks property on each message you send through the API. This setting overrides the default setting for the Server.
  • Message-level (SMTP) - You can set the X-PM-TrackLinks header on each message you send through SMTP. This setting overrides the default setting for the Server.

Per-link opt-out

In some cases you may wish to exclude a link from tracking, even if the rest of the message's links should be tracked. To do this, you should add an additional data-pm-no-track attribute to your links in the HTMLBody of your emails. For example:

<a data-pm-no-track href="http://example.com"> Non-Tracked Link </a>

Note that this feature requires that the link be contained and ignored in HTML, but if you have a TextBody with the identical link, it will also not be tracked from the TextBody.