Sending out a happy birthday mail using Sitecore EXM

In this blog I want to show you how to use the Sitecore Email Experience Manager to send out a daily recurring happy birthday email to every contact in your Experience database who is celebrating his birthday.

Sitecore EXM happy birthday

Prerequisites<
For this blog I have used Sitecore 8.0 update 4 installation with Sitecore EXM 3 update 1 in combination with a SOLR configuration for the content search.

How to identify your contacts
The first step to do is to create a list of all contacts who are celebrating their birthday. Therefore you need to create a segmentation list in the List Manager for every contact whose birthday is today. So you need a profile where the birthdate is filled.

Out of the box Sitecore has indexed the birthdate field into the Analytics index. In SOLR this field is called “contact.birthdate_tdt”. One of the problems with this is that filtering on specific date parts out of the box is not easy with Sitecore. So we create a new computed field which stores the MMdd part of the date into SOLR. You can implement the IComputedIndex interface to achieve this goal. For an example on how to create a computed field check my blog about the BestPatternMatches.

When the birthdate is added to the index you need to create a segmentation condition to match all contacts who are celebrating their birthday. You can create a custom condition where the current date will be matched against the contact’s birthday field in the index.

With this code you can implement the BirthDateCondition

Condition
When the condition is created you have to add it to the segmentation rules in the Sitecore database:

Add this field to the segment build section, so the condition is available in the list manager.

How to create a message
Before you can sent out a message, you have to create a custom EXM template in your own design. Just like a webpage, the EXM is setup the same. You have to create a layout with one or more placeholders were you can mix up a set of renderings (rich text, images, call to actions, etc). If necessary you can personalize the complete EXM.

You can also hook in to the recipientPropertyTokenMap and add some specific tokens with custom data, like the age of the recipient. A pretty good example is explained in the following blog on blog.horizontalintegration.com “token replacement”. Now you are able to supply a variable text with “Congratulations! You are now $age$ years old” or something like that.

When your template is ready you should be able to add a custom message in the EXM root and dispatch the message.

How to dispatch your message
One of the new features of Sitecore EXM is to dispatch a message with a recurring schedule. When you set up the message you can add a segmentation list. This list can by dynamically based on the following question: Who is celebrating his birthdate today. This list will therefore be different every day.

To create a recurring schedule on the delivery tab of EXM choose the following option:

Make sure you choose “schedule with recurring delivery” option without having an end date. After processing the “schedule” button an EXM schedule is added to the system folder. Also a related engagement plan and campaign is created for reporting purposes.

Reporting
After the message is sent you want to receive any statistics about how the EXM campaign is running. How many visitors did open the mail, what was the click through rate or how many recipients were productive on this specific message. Therefore Sitecore comes with a default report overview:

You can also open the engagement plan and see more details over there.

One of this issues we have with this report overview is the ability to report on a specific period: at this moment it is not possible to filter based on a date range. So being able to create a comparison of campaign results between a given period and a previous period is not something that is out-of-the-box available. I hope Sitecore will change the way reporting in EXM works.

Conclusion
The recurring dispatch option is a very useful way of dispatching a message to your contacts which have reached a specific situation, like celebrating a birthday.

Onze technische blogs zijn in het Engels. Dit doen wij omdat wij menen dat technische kennis van Sitecore en Sitefinity grensoverschrijdend moet zijn. Wij leren veel van buitenlandse developers, wij delen onze kennis ook graag met hen. Mochten er in de code fouten zitten of punten ter verbetering, dan gaan we graag het gesprek aan.