Tracking Email Reply CTAs

Justin Paulin
Engineering @ BuildZoom
4 min readDec 20, 2017

Here at BuildZoom, we occasionally send out emails asking for information in a reply. All replies are forwarded to our customer service system, where they’re handled by a real person. Limitations in this system, however, make it difficult to track which specific email is successful in soliciting replies when we send multiple emails to a single user.

In this post, I’ll be going over how we’re planning on solving this problem.

Tracking Emails

In order for us to track outbound emails, we need to have some way of identifying the email that can survive a reply (which can mutate the subject line, leave out the body, or come from another email address if the user has email forwarding setup).

When choosing where to include your unique identifier, you have a few different options, each with their advantages and disadvantages.

Custom Headers

Using custom headers as a unique identifier will involve setting a unique Message-ID header in each of your outbound emails. This will be invisible to the user (unless they look at their email headers), however, may not be as reliable as other methods, as some email clients will strip out headers when an email is replied to or forwarded.

Custom Reply-To Email Address

A custom reply-to email address can act as an effective unique identifier, as it will be easy to parse, and is the most reliable method, as it will not be stripped out in a reply, and will be respected by all major email clients.

An example of a custom reply-to email address would be person+YOURUNIQUEID@buildzoom.com. Everything between the + and the @ can be easily parsed and tracked.

A custom reply-to email address may, however, reveal the fact that your emails are automated, as the reply-to email will be visible to the user.

Recipient

You can also use the recipient as a unique identifier, but you won’t be able to attribute replies when you’ve sent multiple emails (ie. a follow-up) to a single email address. This method is much easier to implement, however.

Hidden ID in Email Text

Finally, you can use a hidden identifier (ie. text in white font on a white background) in the body of the email to uniquely identify emails.

This method will make it easy to attribute replies manually, however, the ID may be stripped out if the user replies to the email and doesn’t send the body of the original email in their reply. Additionally, it may look a bit suspicious if the user highlights the identifier, making it visible.

Accessing Emails

Once you’ve started sending out emails with your unique identifiers, you’ll need some way to read and process your replies. In this post, we’re going to assume that you’re using either an email box as a support ticket system, or are using helpdesk software (like Zendesk or HelpScout) where email replies are turned into support tickets; so we’ll go over a few ways you can silently record reply statistics, while maintaining your existing support workflow.

POP3 Message Processing

POP3 is a commonly used email protocol that lets you easily retrieve email from a server. We can use POP3 by forwarding inbound emails to a second email address, and enabling POP3 on that second mailbox.

We can then use a library like poplib or pop to pull all messages from this mailbox, process them (by reading our unique identifier and saving the details), and delete them.

This method requires you to run the message checker periodically to poll the email box through a cron job or something similar; as the server maintains the message queue — We just need to process the latest messages whenever we have time.

This method will be slower in returning results (it’ll depend on your run interval), however, it’ll perform a lot better; especially when there are large numbers of emails being received.

Piped Email

An alternative to POP3 involves piping inbound emails into a script. When email piping is set up, when any inbound emails are received, a script will be run with the email headers and body as an input. The script can then perform various tasks using the email data.

This can be done by setting up a pipe recipe in procmail, or by using smtpd to copy all inbound emails to a specific address to a script.

You can then use the email headers and body passed into the script to determine the unique identifier and record the reply.

This method will result in much quicker results, as the script will run whenever a new email is received. On the other hand, if a lot of email is received, this method can result in poor performance.

Conclusion

In conclusion, the best choice for us will use custom reply-to email addresses, and POP3 message processing. This is because custom reply-to addresses are the most durable and customizable, and because POP3 message processing will allow us to easily scale and handle large volumes of email without requiring any refactoring.

--

--

Justin Paulin
Engineering @ BuildZoom

3A Comp Eng @uWaterloo, currently interning @buildzoom. Previously @nus-iss, @Enflick, and @cibc.