Building audiences with relative date ranges for timely and personalized outreach

In this recipe, we will create logic for pregnancy trimesters so we can properly personalize the content and timing of messaging related to pregnancy milestones. These messages can help mothers better understand the changes in their bodies, be nurtured with information to aid in healthy pregnancy, celebrate development milestones, and get appointment scheduling reminders.

Lindsey Mark

Made by Lindsey Mark

What do you need?

  • Twilio Engage

Easily personalize customer experiences with first-party data

With a huge integration catalog and plenty of no-code features, Segment provides easy-to-maintain capability to your teams with minimal engineering effort. Great data doesn't have to be hard work!

Get started for free

While this use case is specific to human pregnancy, the logic can be applied to a multitude of important date range use cases. 

Healthcare examples:

  • Recall appointment scheduling - annual preventative care, dental cleanings, eye exams

  • Message related to procedure eligibility & propensity to elect

  • Healthy habit formation and reinforcement

Commercial examples:

  • Renewal dates

  • Trial dates

  • Birthday campaigns

  • Ongoing account engagement milestones

Use Case Summary

I recently had the pleasure of working with a customer whose mobile app is focused on engaging with women experiencing three distinct trimesters of pregnancy. They aim to engage women throughout pregnancy and motherhood with helpful resources aligned to their pregancy trimesters, postpartum experiences, and childhood development milestones. We started by focusing on pregnancy trimesters. The mother’s due date is collected as part of the account profile, and it is passed as a user trait using an Identify call in Segment. 

How Segment would capture this data

Segment can capture properties related to an individual, such as their birthday, renewal date, or baby due date. These dates are sent in as traits on Identify Calls to Segment.

In the example below, birthday is a reserved value and is intended to be the user's birthday. I’ve given an example of an expecting mother who was born in 1998 and is expecting her third child later this year. 

Note: The customer I was working with flattened their data as a property on the profile to align to their current marketing solution. This approach can also be used leveraging Track events to allow for greater scalability overtime with multiple birth pregnancies. 

Identify Call Example for expecting Mother

{ "userId": "19980403", "traits": { "email": "", "birthday": "1998-04-03", "baby":{ "dueDate": "2023-06-15", "childOrder": "3", "gender": "male" } } }

Solutioning for Pregnancy Trimesters

First I looked at WebMD’s pregnancy calculator for inspiration. Sorting out the date ranges for trimesters involved a good amount of calculation to identify the proper number of days related to each trimester.

Human Pregnancy Trimesters in weeks:


Trimester Durations then needed to be converted to the number of days related to the pregnancy dueDate, which is passed on the profile. The number of days will be used in the audience builder to pass which trimester the user is in. 

Note: I’m not a medical professional, please forgive any minor errors in date calculations!


Sending Test User Data

I created three pregnant users and sent data into Segment to test this use case. These calculations were performed in early April. 

  • Mother T1 - T1(first trimester) - due in 30 weeks - due Nov 2

  • Mother T2 - T2(second trimester) - due in 20 weeks - due Aug 24

  • Mother T3 - T3(third trimester) - due 10 weeks - due June 15


For an example of how to identify the expectant mother, see the section "Identify Call Example for expecting Mother" above.

After sending the data, I verified that each profile was created in Segment. We will refer back to the table above to ensure each user is properly aligned to the corresponding trimester audience.  

Creating Audiences

In building these audiences with relative dates, I select the Baby’s “Due Date” which differs per the user’s profile. Once the date range is selected, I ensure that the proper Mother’s profile appears on the right side of the Audience preview. The proceeding screenshots will return the Mother in the proper trimester based on the relative audience dates selected.

Audience for Third Trimester 
  • Query: baby.dueDate (within next) 86 days

  • Returns: Mother 3T (in third trimester)

Audience for Second Trimester
  • Query: baby.dueDate (within next) 183 days & excludes parameters for due within next 86 days. 

  • Returns: Mother 2T (in second trimester)


Optional Logic If the prior audience was saved you can use “and not who are a part of third trimester audience” as a parameter instead of baby.dueDate within next “86” days, shown below. 

Shown using “not in Trimester 3 audience”

First Trimester Audience
  • Query: baby.dueDate (after next) 184 days

  • Returns: Mamabear1 (in first trimester)


After each audience is created, you’ll want to spot check the date using the audience preview. Once you’re confident in the audience, you can configure a destination to send the data to various destinations such as marketing platforms and analytics tools. 

Wrapping up

This guide shared how to create audiences using relative date ranges in Segment. This allows for more tailored and timely message personalization, which can be broadly applied to a multitude of date-range focused lifecycle marketing use cases.

Note: If you are managing data related to healthcare you may want to consult with your legal teams to ensure you’re following internal guidelines around the use of PII and PHI, specifically when sending behavioral or health data to ad networks. 

Getting started is easy

Start connecting your data with Segment.