SOLVED

Re: Multiple products Anniversary Email

Go to solution
JeffHensiek
Level 4

Multiple products Anniversary Email

Hello Marketing Nation.

 

I'm running into an issue and would like your collective thoughts on this one.

 

We're looking to send an email based on an anniversary date.  Yes, there are several threads about this type of scenario... however, this one is different - and here's why.

 

We're a financial institution/Bank and we provide checking accounts, savings accounts, mortgages, etc.  We're trying to send an email based on the members anniversary date - the date of when they opened their first product.  Someone could have multiple 'account open date' values and we're looking to identify the oldest date and trigger the membership email based on that date.  

 

We currently use a custom object to bring in our product related data.  This includes the 'open date/create date' of the accounts.  The challenge is that an individual record may have multiple 'open dates' because they have multiple products with us and they would have a unique open date for each product.

 

I've been able to build out a filter/smart list that can pull in all of the potential accounts that an individual may have (and this captures all of the 'open dates' as well).  What I'm looking to get a handle on is how to filter through the accounts and identify the oldest 'open date/create date'.  Once this step is solved, then we'll go one step further and quantify this value (e.g., if the oldest account was opened January 1, 2020 - then they have been a member for "x" years).  This additional value (the 'member for 'x' years' value) is something that we'll want to use as a token in the email.

 

Thoughts on how to approach this further?

Thanks all.

Jeff

 

Jeff Hensiek
Marketing Automation Program Manager
2 ACCEPTED SOLUTIONS

Accepted Solutions
Darshil_Shah1
Level 10 - Community Advisor + Adobe Champion

Re: Multiple products Anniversary Email

Well, you don't need to dynamically create the field, you can create it from the Admin > Field Management section on the Person object. Once you've created the field, you can do a list import with the field set to the next anniversary date. This field will then be updated to the person's next anniversary date by the Change Date Value flow step in the send email campaign using the token {{system.date}} + 1.

 


 

For example, if I have two individuals with the following open dates... how would I populate the date field?

Person 1 - original open date of 10/11/2015

Person 2 - original open date of 10/11/2020

 

The field values that I'd need to populate would be:

Person 1 - 'Next Account Opening Anniversary Date' - 10/11/2023

Person 2 - 'Next Account Opening Anniversary Date' - 10/11/2023


Yes- that's correct!

 


 

AND, I'd also like to call out the number of years they've been with us.  So, I'll want to create another field that is "years of membership" and it should populate like this (based on today's date of 10/11/2023):

Person 1 - "years of membership" - 8

Person 2 - "years of membership" - 3


Well, yes, but instead of creating a score field, you can also create an Email script token to count the number of years from the original open date of the apt custom object record (that'd be one less custom field you'd have to create and maintain). There are several threads on the nation on calculating the number of years based on a date if you search. To give you an idea, you would have to sort the custom object list in ascending order as per the account open date field, get the account open date of the record at the 0th index of this sorted list, calculate the number of years till today, and display it in the email.

 

You'd have to add this email script token in the email where you want to display the number of years. See the sample script below for your reference- replace the custom object and field name with the apt API names you're using in your instance. Just as an FYI, this script doesn't specifically handle the case where the number of years is 0 (it just displays 0 years), if you want to display any alternative text, you can do so by a simple conditional statement (we can help you with the same if need be).

 

#set( $defaultTimeZone = $date.getTimeZone().getTimeZone("America/New_York") )
#set( $defaultLocale = $date.getLocale() )
#set( $calNow = $date.getCalendar() )
#set( $ret = $calNow.setTimeZone($defaultTimeZone) )
#set( $calConst = $field.in($calNow) )
#set( $ISO8601DateOnly = "yyyy-MM-dd" )
#set( $ISO8601DateTime = "yyyy-MM-dd'T'HH:mm:ss" )
#set( $ISO8601DateTimeWithSpace = "yyyy-MM-dd HH:mm:ss" )
#set( $ISO8601DateTimeWithMillisUTC = "yyyy-MM-dd'T'HH:mm:ss.SSS'Z'" )
#set( $ISO8601DateTimeWithMillisTZ = "yyyy-MM-dd'T'HH:mm:ss.SSSZ" )

#set( $sortedList = $sorter.sort($accountObjectList,"accountOpenDate:asc"))
#set( $calJoinDate = $convert.toCalendar(
  $convert.parseDate(
    $sortedList.get(0).accountOpenDate, 
    $ISO8601DateOnly, 
    $defaultLocale, 
    $defaultTimeZone 
  )
))

#set( $differenceInYears = $date.difference($calJoinDate,$calNow ).getYears() )
#set( $friendlyLabel = $display.plural($convert.toInteger($differenceInYears),"year") )
You have been with for ${differenceInYears} ${friendlyLabel} now!

 

Hope you find this helpful. Let us know if you have questions.

View solution in original post

Darshil_Shah1
Level 10 - Community Advisor + Adobe Champion

Re: Multiple products Anniversary Email

Yes, you can refer to the Marketo's developer documentation. Additionally, there are several velocity-related questions on the nation that I personally have learned a lot from. There's Sandy's blog of course- https://blog.teknkl.com/tag/velocity Apache velocity's documentation is also a cool place, especially if you want to start from the very basics and want to refer a very thorough material. Velocity is a basically Java-based template engine. People with previous development experience find it easier to write and troubleshoot velocity codes compared to the ones who are just starting to write code

View solution in original post

7 REPLIES 7
Darshil_Shah1
Level 10 - Community Advisor + Adobe Champion

Re: Multiple products Anniversary Email

Well, you can create a custom date field (say: Next Account Opening Anniversary Date) on the Person object, then for each person with at least 1 CO record backfill the field with the Open Date of the oldest account, and the date needs to be the next anniversary date (not the actual date). You can backfill using a simple list import. You'd want to run a batch daily campaign for people whose Next Account Opening Anniversary Date is today, send them the email, and update the Next Account Opening Anniversary Date field with {{system.date}} + 1 year. I'd say, if you wish to display the number of years in the email since they opened the account, you can create an Score type field that stores the number of years since they opened their first account and increment it by 1 in the campaign flow. I know this solution requires creating 2 custom fields, so I'd wait for any alternate suggestion from the community that is more optimized and potentially requires fewer custom fields.

SanfordWhiteman
Level 10 - Community Moderator

Re: Multiple products Anniversary Email

You don’t need the Score field because you can compute the # of years in Velocity.

Darshil_Shah1
Level 10 - Community Advisor + Adobe Champion

Re: Multiple products Anniversary Email

Oh yes, of course! Pick the correct CO record (sort the CO list in ascending order based on the account open date and pick the 0th record), and compute the number of years between the system date and the account open date of that particular CO record. Thanks, Sandy!

JeffHensiek
Level 4

Re: Multiple products Anniversary Email

Velocity - this is new to me.  Is this a good reference for Velocity?

 

https://developers.marketo.com/email-scripting/

 

Jeff Hensiek
Marketing Automation Program Manager
Darshil_Shah1
Level 10 - Community Advisor + Adobe Champion

Re: Multiple products Anniversary Email

Yes, you can refer to the Marketo's developer documentation. Additionally, there are several velocity-related questions on the nation that I personally have learned a lot from. There's Sandy's blog of course- https://blog.teknkl.com/tag/velocity Apache velocity's documentation is also a cool place, especially if you want to start from the very basics and want to refer a very thorough material. Velocity is a basically Java-based template engine. People with previous development experience find it easier to write and troubleshoot velocity codes compared to the ones who are just starting to write code

JeffHensiek
Level 4

Re: Multiple products Anniversary Email

I like where you're headed with this.

 

I'm not super code savvy, so, help me along a little here.

 

How would I dynamically create the field you're suggesting?

 

For example, if I have two individuals with the following open dates... how would I populate the date field?

Person 1 - original open date of 10/11/2015

Person 2 - original open date of 10/11/2020

 

The field values that I'd need to populate would be:

Person 1 - 'Next Account Opening Anniversary Date' - 10/11/2023

Person 2 - 'Next Account Opening Anniversary Date' - 10/11/2023

 

AND, I'd also like to call out the number of years they've been with us.  So, I'll want to create another field that is "years of membership" and it should populate like this (based on today's date of 10/11/2023):

Person 1 - "years of membership" - 8

Person 2 - "years of membership" - 3

Jeff Hensiek
Marketing Automation Program Manager
Darshil_Shah1
Level 10 - Community Advisor + Adobe Champion

Re: Multiple products Anniversary Email

Well, you don't need to dynamically create the field, you can create it from the Admin > Field Management section on the Person object. Once you've created the field, you can do a list import with the field set to the next anniversary date. This field will then be updated to the person's next anniversary date by the Change Date Value flow step in the send email campaign using the token {{system.date}} + 1.

 


 

For example, if I have two individuals with the following open dates... how would I populate the date field?

Person 1 - original open date of 10/11/2015

Person 2 - original open date of 10/11/2020

 

The field values that I'd need to populate would be:

Person 1 - 'Next Account Opening Anniversary Date' - 10/11/2023

Person 2 - 'Next Account Opening Anniversary Date' - 10/11/2023


Yes- that's correct!

 


 

AND, I'd also like to call out the number of years they've been with us.  So, I'll want to create another field that is "years of membership" and it should populate like this (based on today's date of 10/11/2023):

Person 1 - "years of membership" - 8

Person 2 - "years of membership" - 3


Well, yes, but instead of creating a score field, you can also create an Email script token to count the number of years from the original open date of the apt custom object record (that'd be one less custom field you'd have to create and maintain). There are several threads on the nation on calculating the number of years based on a date if you search. To give you an idea, you would have to sort the custom object list in ascending order as per the account open date field, get the account open date of the record at the 0th index of this sorted list, calculate the number of years till today, and display it in the email.

 

You'd have to add this email script token in the email where you want to display the number of years. See the sample script below for your reference- replace the custom object and field name with the apt API names you're using in your instance. Just as an FYI, this script doesn't specifically handle the case where the number of years is 0 (it just displays 0 years), if you want to display any alternative text, you can do so by a simple conditional statement (we can help you with the same if need be).

 

#set( $defaultTimeZone = $date.getTimeZone().getTimeZone("America/New_York") )
#set( $defaultLocale = $date.getLocale() )
#set( $calNow = $date.getCalendar() )
#set( $ret = $calNow.setTimeZone($defaultTimeZone) )
#set( $calConst = $field.in($calNow) )
#set( $ISO8601DateOnly = "yyyy-MM-dd" )
#set( $ISO8601DateTime = "yyyy-MM-dd'T'HH:mm:ss" )
#set( $ISO8601DateTimeWithSpace = "yyyy-MM-dd HH:mm:ss" )
#set( $ISO8601DateTimeWithMillisUTC = "yyyy-MM-dd'T'HH:mm:ss.SSS'Z'" )
#set( $ISO8601DateTimeWithMillisTZ = "yyyy-MM-dd'T'HH:mm:ss.SSSZ" )

#set( $sortedList = $sorter.sort($accountObjectList,"accountOpenDate:asc"))
#set( $calJoinDate = $convert.toCalendar(
  $convert.parseDate(
    $sortedList.get(0).accountOpenDate, 
    $ISO8601DateOnly, 
    $defaultLocale, 
    $defaultTimeZone 
  )
))

#set( $differenceInYears = $date.difference($calJoinDate,$calNow ).getYears() )
#set( $friendlyLabel = $display.plural($convert.toInteger($differenceInYears),"year") )
You have been with for ${differenceInYears} ${friendlyLabel} now!

 

Hope you find this helpful. Let us know if you have questions.