1:1 Real Time Email Personalisation

email-personalisation

This is something I’ve been thinking over for almost 12 months, and I’ve finally tweaked it to the point where I’m happy to share. The question in my mind was:

Can you present dynamic content on a 1:1 basis to a user in an email based on their location, device, time of day and more?

Suppose someone (who all you knew was their email address) happened to open your email on an android phone, in Sydney, 2 days after you sent your email campaign. Would you want to show him anything different to someone in Brisbane, on a Desktop machine, 2 days earlier? Of course!

You’d want to do this:

personalised-email

So can you do it?

It turns out, the answer is yes. That said, I can’t find anyone doing it… yet.

Some Email Marketing software offers the functionality using CSS stylesheets, but the support across devices is tentative at best, and some of the cooler things like location and time of day won’t work. The method I’m about to show works will work on all email clients, so long as the user loads external images (many clients like iPhone do this by default).

Before I go into some detail, here is what I’m doing in a nutshell:

  • Email references  external dynamic images
  • Images, despite having a file extension of .jpg, are actually PHP files (this is invisible to the email client)
  • PHP code examines information about the user (like IP address, user agent, browser etc) and decides which image to return

Why might you go to all this effort?

  • Tailor an email and it’s messaging to users of iPhones (Stronger Call to Actions to phone)
  • Show Android App information only to users on Androids
  • If a user opens an email a day late and a deal has expired, show a new deal!
  • Show store locations in the the city the user is reading the email

The first thing you need to do is to convince your server to process your image file extensions as PHP. Create a new directory (mines called ‘imgswitcher’) and create a .htaccess file inside with the following content (this file needs to exist in the directory, not at the root of your hosting):

Select Code
1
2
3
AddType application/x-httpd-php .jpg
AddType application/x-httpd-php .png
AddType application/x-httpd-php .gif

This tell your server that when it receives a request for an image in that folder, it actually has to run some PHP code, not try and display it as an image.

Now we just just create a simple file in this folder. I’m going to call it devicepic.jpg and despite the .jpg extension, it actually contains PHP code. It’s going to show a picture of an iPhone, Android or Desktop PC (which I have placed in the same folder).

Here’s the code:

Select Code
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
<?php
$useragent = $_SERVER['HTTP_USER_AGENT'];

$iphone = stripos($useragent, 'iphone');
$android = stripos($useragent, 'android');

if($iphone) {
$name = "./iphone.jpg";
} elseif($android) {
$name = "./android.jpg";
} else {
$name = "./desktop.jpg";
}

$fp = fopen($name, 'rb');

header("Content-Type: image/jpg");
header("Content-Length: " . filesize($name));

fpassthru($fp);

Without going into massive detail with how it works, the script checks the useragent of the requesting email client or browser, and if it contains ‘iphone’ or ‘android’ returns targeted content. A great (and relatively unknown) way of testing is to use Chrome’s built in ability to switch user agents.

Here’s an example of the finished product: http://www.johnsee.com.au/imgswitcher/example/switch.jpg. Try embedding this image in an email and view it on a desktop, iPhone and Android device – you’ll see a different image every time!

What about if we wanted to show a different offer based on the day of the week, similar to the Free Shipping example in my image above:

Select Code
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
<?php
$tz = 10;
$offset = $tz * 3600;
$day = gmdate("l", time() + $offset);

if($day == 'Monday') {
$name = "./monday-99-offer.jpg";
} else {
$name = "./free-shipping-offer.jpg";
}

$fp = fopen($name, 'rb');

header("Content-Type: image/jpg");
header("Content-Length: " . filesize($name));

fpassthru($fp);

Simply extend your logic out for multiple days.

These are both really  oversimplified examples, but from here you should be able to do everything from extending logic to cover lots more devices (I recommend using mobile detect to do proper detection) to creating entire dynamic images on the fly (you might not have a users city in your CRM/Database, but you could detect on the fly with this method and IP location for instance). Time of day combined with city will also allow different images at night, or local deals.

The other great advantage of this method is that all the heavy lifting is handled by your server, not your email client. This means you don’t even need email marketing software to implement the above, you could send the email (with images) from Gmail or Outlook. Perhaps a dynamic email signature in Outlook could change to show the nearest office to the person reading the email?

Let me know what you think. I have a half finished project to turn this into a free web app so there’s no need to be able to code in order to implement which I’d love to finish if there’s a need.

Digital marketer in Brisbane. Passionate about enterprise search, conversion optimisation, Omniture, DSPs, data mining, coding and tech.

2 Comments on "1:1 Real Time Email Personalisation"

  1. Tom,

    I love that you’re trying this out at a grass roots level, fantastic.

    Regarding the ability to do that in general, have you seen Movable Ink before? They provide a pretty reasonable array of dynamic options for email, some of which you mentioned but the sky is the limit with use cases for this sort of technology.

    In general, dynamic email content like you’re suggesting just isn’t on the radar of most businesses. Truth be told, most businesses aren’t ready or even looking at how to optimise their email content to work across multiple platforms such as desktop & mobile – so adding in another layer of complexity is a world away.

    I think the only way this is going to get any traction in the market place, except for large or enterprising businesses looking to push the limits is going to be when it is integrated into other email service providers and made dead simple. I know that Experian CheetahMail have integration with Movable Ink but of course a product like that isn’t suited to every business – so finding a way to deliver that functionality to a broader array of businesses would be awesome.

    Al.

    • Tom Johns says:

      Wow, no I hadn’t. They look like they’re all over it (although it looks very lacking on the free side!) They definitely need to optimise for search… because I did spend a fair amount of time trying to find something out there!

      Agree with all your other points. Email is such low hanging fruit for any business with a decent size marketing database.

Got something to say? Go for it!