How To Create A Date-Based Segment in Mautic

How To Create A Date-Based Segment in Mautic

A customer's subscription expires soon, and you want to remind them to renew with a special offer? A contact was inactive for more than six months, and you want to re-engage them? Wondering how you could tailor your marketing communications to those specific user timelines? Find out how in this guide on Mautic date-based segments.

Date-based segments in Mautic allow you to target your contacts, customers or subscribers based on specific time-based events, such as their last purchase, subscription end date, or last activity.

This level of personalization means you can send the right message at the right time, increasing engagement and boosting your campaign results.

💡
What you'll learn

In this blog post, we'll take a deep dive into Mautic date-based segments. I'll explain how date options in Mautic work. We'll look under Mautic's hood as the internals help us understand how relative dates work. You'll learn how to use relative dates for segmentation. Finally, I walk you through examples of different scenarios, and the process of setting them up.

Understanding Date Options in Mautic

Mautic provides two primary ways to work with dates: the standard date picker, which sets a fixed date, and relative date formats.

The standard date picker is a straightforward tool that allows you to specify a certain date. You could create a segment that filters for everyone who hasn't been active in 2023. To do that, you'd create a segment filter Date Last Active | less than | 2023-01-01 00:00.

While this can be helpful, the magic truly happens when you begin using relative date formats.

💡
The “problem” with the standard date picker/fixed date is: They're fixed. To update your segment, you must manually change the date you are targeting.

Relative dates give you the power to define dynamic time frames, making your segment and campaigns more versatile and adaptive. These can be specified using simple notations like "+1 day", "-2 days", "+1 week", or even "3 years ago".

How Setting Relative Dates Works in Mautic
Understanding and using relative dates in Mautic can be intimidating in the beginning. It quickly becomes confusing how a certain relative date resolves to a specific date. Do you think you already mastered it? What specific date will first sunday of august +3 days 12:00 next year result in?

Read more about the notation of relative dates in Mautic

Why is this so much more powerful than fixed dates?

Imagine you want to email subscribers exactly 6 months after they subscribed.

  • Using fixed dates you'd have to change the filter date every day.
  • Using relative dates, you only need to set Date identified | equals | -6 month. Mautic will add every day all contacts who signed up exactly 6 months ago to the segment. On Friday 28th of July 2023 Mautic adds everyone who signed up Jan. 28 2023. On Jul. 29th it'll add everyone from Jan. 29—and so forth. This is truly automated.

If you're hooked, let's dive into how to set up a date-based segment correctly.

Primer: How a Date Is Represented Internally

💡
This section gets a bit technical. It helps to understand the core functionality. You might skip this section and still understand the rest of this article.

To understand how to compare two dates using a relative date, you'll have an easier time if you know how those dates are represented technically.

Technically, a date is represented as a numeric value. An Example:

The current date as of writing this is Friday 28th of July 2023 16:09. It is represented as 1690560590. The same day one year earlier is represented as 1659017352.

This number is called the Unix time or Unix timestamp. It measures the time that has elapsed since 00:00:00 UTC on 1 January 1970 in seconds.

Why is this important for you?

Mainly because you need to understand that a later or future date is always higher than an earlier or past date. Just compare both timestamps. The one from 2023 is higher than the one from 2022.

Implications?

  • A future date is always greater than the current date. Your filter condition has to be greater than.
  • A past date is always lower than the current date. You filter condition has to be lower than.

How To Use a Relative Date For Segmentation

To successfully use relative dates for segmentation in Mautic, it's essential to understand the interaction of three key dates:

  1. Mautic's current system time: This refers to the real-time, Mautic's server's current date and time. It acts as a reference point for calculating relative dates.
  2. The contact's event date: This is a specific date and time associated with a contact, stored in a contact's (custom) field. For instance, Date Last Active is a pre-existing field that Mautic updates every time a contact interacts with your page. Another example could be your hypothetical custom contact field Last Purchase. It marks the date of a contact's most recent purchase. (As this is a custom field, you need to take care of updating it manually or via an automated process.)
  3. The relative date: A relative date is a time span either added to or subtracted from Mautic's current system time. It helps define a point in time or timeframe relative to the current moment.

With these three dates, here's how the process of using a relative date for segmentation works in Mautic:

  • Mautic begins by identifying the timestamp of the current system time. This numeric value serves as a foundation for all subsequent calculations.
  • Next, adds or subtracts your relative date to/from the current system time. This modified time is then used for comparison.
  • Finally, Mautic compares the modified time with the contact's event date. It checks if the modified time is, e.g., greater than, less than, or equals the event date based on how you set up the filter rule.

If the modified system time matches the comparison rule with your contact's event date, then Mautic will execute your action.

💡
Relative date-based segments are contact-specific. A contact becomes a member of an, e.g., re-engagement campaign only they've been inactive for long enough. Other contacts are unaffected.

Here is a table showing you how to set up the date filter for certain targeted points in time:

Targeted time period Contact Field Filter Rule Relative Date
Event in the past, but not older than Date Last Active greater than -3 month
Event in the past, exactly X time ago Last Purchase equals -14 days
Event in the past, and older than Date Last Active less than -6 month
Event in the future, at least X time left Subscription End Date greater than +6 month
Event in the future, exactly in X time Subscription End Date equals +10 weeks
Event in the future, less than X time left Subscription End Date less than +10 days

Seeing this the first time, it might be hard to wrap your head around. Let me explain each of these in detail: