Send a birthday email sending-a-birthday-email

This use case presents how to plan sending a recurring email to a list of recipients on the day of their birthday.

To set up this use case, we created the following targeting workflow:

Birthday workflow: Scheduler, query, March 1st test, Fork with leap year query, Union, then Delivery.

This (daily run) workflow selects all recipients that have their birthday on the current date.

To do this, create a campaign and add a campaign workflow.

Then follow the steps detailed below.

Identify recipients whose birthday it is identifying-recipients-whose-birthday-it-is

After configuring the Scheduler activity so that the workflow starts every day, identify all of the recipients whose date of birth equals the current date.

To do this, apply the following steps:

  1. Drag and drop a Query activity into the workflow and double-click it.

  2. Click the Edit query link and select Filtering conditions.

    Targeting and filtering dimension window with Recipients selected and Filtering conditions highlighted.

  3. Click the first cell of the Expression column and click Edit expression to open the expression editor.

    Filter conditions editor with an empty Expression cell and the Edit expression button displayed.

  4. Click Advanced selection to select the filtering mode.

    Field to select window listing Recipients fields, with the Advanced selection button highlighted.

  5. Select Edit the formula using an expression and click Next to display the expression editor.

  6. In the list of functions, double-click Day, which is accessible via the Date node. This function returns the number representing the day corresponding to the date passed as a parameter.

    Edit the expression window with Day() in the edit zone and the Day function selected in the list of functions.

  7. In the list of available fields, double-click Birth date. The upper section of the editor then displays the following formula:

    code language-none
    Day(@birthDate)
    

    Click Finish to confirm.

  8. In the query editor, in the first cell of the Operator column, select equal to.

    Filter conditions with day of birth date as expression and the Operator drop-down open with equal to selected.

  9. Next, click the first cell of the second column (Value), and click Edit expression to open the expression editor.

  10. In the list of functions, double-click Day, which is accessible via the Date node.

  11. Double-click the GetDate function to retrieve the current date.

    Edit the expression window showing Day(GetDate()) with the Day and GetDate functions highlighted in the function list.

    The upper section of the editor displays the following formula:

    code language-none
    Day(GetDate())
    

    Click Finish to confirm.

  12. Repeat this procedure to retrieve the month of birth corresponding to the current month. To do this, click the Add button and repeat steps 3 to 10, replacing Day with Month.

    The complete query is as follows:

    Complete query: day of birth date equal to day of current date and month of birth date equal to month of current date.

Link the result of the Query activity to an Email delivery activity to send an email to the list of all of your recipients on their birthday.

Include recipients born on February 29th (optional) including-recipients-born-on-february-29th--optional-

If you want to include all recipients who were born on February 29th, this use case presents how to plan sending a recurring email to a list of recipients for their birthday - whether it is a leap year or not.

The main implementation steps for this use case are:

  • Selecting recipients
  • Selecting whether or not it is a leap year
  • Selecting any recipients born on February 29th

To set up this use case, we created the following targeting workflow:

If the current year is not a leap year and the workflow is run on March 1st, we need to select all recipients that would have had their birthday yesterday (February 29th) and add them to the recipients list. In any other case no additional action is required.

Step 1: Select the recipients step-1--selecting-the-recipients

After configuring the Scheduler activity so that the workflow starts every day, identify all of the recipients whose anniversary is the current day.

NOTE
If the current year is a leap year, all of the recipients born on the 29th of February are automatically included.

Query activity filter named Month+day of birth equal to current date, matching month and day of birth date to today.

Selecting recipients whose birthday corresponds to the current date is presented in the Identifying recipients whose birthday it is section.

Step 2: Select whether or not it is a leap year step-2--select-whether-or-not-it-is-a-leap-year

The Test activity allows you to check whether or not it is a leap year and whether the current date is March 1st.

If the test is verified (the year is not a leap year - there is no February 29th - and the current date is indeed March 1st), the True transition is enabled and the recipients born on February 29th will be added to the March 1st delivery. Otherwise, the False transition is enabled and only the recipients born on the current date will receive the delivery.

Copy and paste the code below into the Initialization script section of the Advanced tab.

function isLeapYear(iYear)
{
    if(iYear/4 == Math.floor(iYear/4))
    {
        if(iYear/100 != Math.floor(iYear/100))
        {
            // Divisible by 4 only -> Leap Year
            return 1;
        }
        else
        {
            if(iYear/400 == Math.floor(iYear/400))
            {
                // Divisible by 4, 100 and 400 -> Leap year
                return 1;
            }
        }
    }
    // all others: no leap year
    return 0;
}

// Return today's date and time
var currentTime = new Date()
// returns the month (from 0 to 11)
var month = currentTime.getMonth() + 1
// returns the day of the month (from 1 to 31)
var day = currentTime.getDate()
// returns the year (four digits)
var year = currentTime.getFullYear()

// is current year a leap year?
vars.currentIsALeapYear = isLeapYear(year);

// is current date the first of march?
if(month == 3 && day == 1) {
  // today is 1st of march
vars.firstOfMarch = 1;
}

Advanced tab of the test activity with an initialization script defining the isLeapYear function.

Add the following condition in the Conditional forks section:

vars.currentIsALeapYear == 0 && vars.firstOfMarch == 1

Test tab March 1st and NOT a leap year, with True condition vars.currentIsALeapYear == 0 && vars.firstOfMarch == 1.

Step 3: Select any recipients born on February 29th step-3--select-any-recipients-born-on-february-29th

Create a Fork activity and link one of the outbound transitions to a Query activity.

In this query, select all of the recipients whose date of birth is February 29th.

Query selecting recipients born on February 29th: month of birth date equal to 2 and day of birth date equal to 29.

Combine the results with a Union activity.

Link the results of the two Test activity branches to an Email delivery activity to send an email to the list of all of your recipients on their birthday, even to those born on February 29th during a non-leap year.

Create a recurring delivery creating-a-recurring-delivery-in-a-targeting-workflow

Add a Recurring delivery activity based on the birthday email template that you want to send.

CAUTION
For the workflows to execute, the technical workflows relating to the Campaign package must be started. For more on this, refer to the List of technical workflows section.
If the approval steps are enabled for the campaign, the deliveries will only be sent once these steps have been confirmed. For more on this, refer to the section.

Birthday workflow: Scheduler, query, March 1st test, Fork with leap year query, Union, then Delivery.

recommendation-more-help
campaign-help-automation