Birthday Email: A Real-Life Example of an Online Marketing Extension

   —   

Online Marketing has a set of powerful features covering most of your requirements. There are, however, certain scenarios in which you might need to extend the system a little bit. This article shows you an example of how to do just that.

Birthday Email

One of the most common questions I get during my online marketing classes is about birthday emails to contacts. The client wants to send out an email wishing the contact all the best. There are a few ways of implementing this in the system, but the most straightforward way is to create a scheduled task that will be executed once a day. This task will be responsible for logging an activity for each contact with a birthday on that day. I don’t recommend sending the email as part of the task, since the marketing department might want to customize the conditions under which the email is sent out, perform additional actions, or do follow-ups. They can achieve this simply by creating an automation process that will be triggered by our birthday activity. The scheduled task could look something like this:

public string Execute(TaskInfo ti) { // Get all contacts which have a birthday set (TIP: This can be optimized to retrieve only contacts which have birthday today, but be careful with the date/time formats) var contacts = ContactInfoProvider.GetContacts().Where("ContactBirthday is not null"); var currentDate = DateTime.Today; if (!DataHelper.DataSourceIsEmpty(contacts)) { // Loop through the individual items foreach (ContactInfo contact in contacts) { // Check if the contact has birthday today if (contact.ContactBirthday.Date == currentDate) { ActivityInfo isBirthday = new ActivityInfo() { ActivityActiveContactID = contact.ContactID, ActivityOriginalContactID = contact.ContactID, ActivityCreated = DateTime.Now, ActivityType = "HasBirthday", ActivityTitle = contact.ContactDescriptiveName + " celebrates birthday today" }; // log the Has birthday activity ActivityInfoProvider.SetActivityInfo(isBirthday); // process triggers ActivityInfoProvider.ProcessTriggers(isBirthday, true); } } } return null; } }

Then you just register it in the back end and set the frequency of the execution to once a day (ideally during low traffic time).

1.png

You also need to create an activity for this task. I called mine “Has birthday”:

2.png

You can now create a birthday wish automation process based on this activity:

3.png

And this is what the activity will look like in the activity list of a given contact:

4.png

The mentioned example, activity, and task can be imported into your Kentico 9 installation by downloading and importing this package.

Please share your custom rules and activities or any other extensions you’ve implemented for the Online Marketing module in the comments section below.

Share this article on   LinkedIn

Boris Pocatko

Senior Solution Architect for Kentico

Comments