Uber is a company built around the customer experience; from the slick app to professional drivers, every step is designed to convey a polished brand and experience.  One of my favorite parts of the Uber experience is the receipt email you get after taking a ride. And that’s not just because I’m an email buff – Uber does an exceptional job of including dynamic content in the subject line of every ride receipt.

Take a look at a snapshot of my inbox:

Dynamic Content in Uber ride receipts

Dynamic Content in Uber ride receipts

With every receipt you receive from Uber, the subject line dynamically includes a simplified version of the time of day. Instead of, “Your Sunday 8:15AM PST trip with Uber“, Uber simplifies it to just “Your Sunday Morning trip with Uber“. This is a simple example of how important Uber views the customer experience, and a great example of dynamic content.

What’s Dynamic Content?

Dynamic content is content that changes for each individual recipient. In the Uber example, a calculation is performed on the time of day and instead of the date and time being shown, it’s replaced with a simple string like “Monday afternoon”. Each time Uber sends a receipt email, a template engine renders the email with the dynamic content.

Think of it as variable replacement – or merge tags – on steroids. Another great example of dynamic content is changing an image in every email depending on what city your recipient is based in.

Why Does Dynamic Content Matter?

Email, especially transactional email, is a direct extension of your product, so it functions as a reflection of how much you care about your user experience. Dynamic content allows you to customize every email to each customer’s unique interaction with your product or service. An email triggered by taking an action on your site should feel like a reward to the customer for engaging, and using dynamic content in your emails is a great way to move in that direction.

In short, you’ve gone to great lengths to make sure every other facet of your online presence has some life to it, it’s time to stop overlooking your emails.

I’m Sold! So How Do I Send Email Like Uber?

It’s really easy… if you’re using a template engine like Sendwithus. There are definitely ways to get this working with other systems, but you can drop the following code into a Sendwithus template and have it working right away.

First up, let’s talk about how we’re going to break down the day. This might change in different countries – (and Sendwithus’s internationalization support can handle it!) – but this breakdown will cover most of North America:

Time of Day Simplified Form
5am to 12p Morning
12p to 5pm Afternoon
5pm to 8pm Evening
8pm to midnight Night
midnight to 4am Late Night

We’re going to assume you’re sending a transactional email with a unix timestamp variable called “event_time”.In your Sendwithus editor, open up the template you want to add dynamic content to, and drag open the subject line box (see below):

drag here

Copy and paste the following code into the subject line box:

{% set hour = int(event_time|timestamp_to_time|datetimeformat("%H")) %}
{% set day = event_time|timestamp_to_time|datetimeformat("%A") %}
{% if hour >= 5 and hour < 12 %} {% set daytext = "Morning" %} {% elif hour >= 12 and hour < 17 %} {% set daytext = "Afternoon" %} {% elif hour >= 17 and hour < 20 %} {% set daytext = "Evening" %} {% elif hour >= 20 and hour < 24 %}
{% set daytext = "Night" %}
{% else %}
{% set daytext = "Late Night" %}
{% endif %}
{{ day }} {{ daytext }}

Go ahead and save your template and you’re ready to go! To get an idea of what this will look like in production, send a test email directly from your app, or use our built-in previews. Open up the preview pane and add a value for the “event_time” (in this example I’m using 1424197820)

add variable

Add event_time and Show in Browser

Here’s an example of what one of my tests looked like:


Example “Tuesday Late Night” dynamic content

Wrapping Up

This is just one example of how dynamic content can be used to make transactional email really great. We can already see many breakout companies like Uber and AirBnB put a real emphasis on the email experience, and this trend is definitely here to stay. There are many other creative ways to use dynamic content, but this, in particular, is a fairly easy way to make things just a little more personal.

If you’ve seen any amazing uses of dynamic content, or want to know if something else is possible, hit us up either in the comments below or on Twitter.