Customer age calculation
The Customer Age Calculation offers businesses a robust solution to automatically calculate their customers’ age based on the birthdate attribute.
This approach has several noteworthy benefits for businesses:
- Improved Customer Insights: Access to age demographics enables more informed decision-making, enhancing the effectiveness of marketing initiatives and customer engagement strategies.
- Personalized Customer Experiences: Armed with accurate age data, businesses can provide tailored interactions and experiences, such as age-specific discounts, content recommendations, and product suggestions.
- Compliance and Age Verification: In industries governed by age-related regulations, such as age-restricted products or services, this use case serves as a robust tool for age verification, ensuring compliance and safeguarding against unauthorized access.
In this use case, you will verify the presence of the birthdate attribute within a customer’s profile. Upon confirmation, the use case proceeds with a series of precise calculations. In summary, this process simplifies age calculations, it will enrich customer understanding, enable personalized interactions, and contribute to more effective marketing campaigns and age-related compliance. What’s more, this calculation also takes leap years into account.
Prerequisites
- Implement tracking code on your website.
- Import of customer base with birthdate attribute.
Create an expression
Create an expression that will calculate age of a customer based on the birthdate attribute. The logic of the expression is as follows:
-
If a customer’s birthdate in the profile is undefined, this expression returns
null
. -
If a customer’s birthdate in the profile is defined, the expression analyzes the month of the birthdate and the month of current date:
- If the current month is before the month of birth, their age is calculated by this mathematical operation:
current year - year of birth - 1
. - If the current month is after the customer’s month of birth, their age is calculated by subtracting the year of birth from the current year.
- If the current month is the same as the month of birth, the expression checks the day of birth and the day of the current date.
- If the current day is before the birthday, their age is calculated by means of this mathematical operation:
current year - year of birth - 1
. - If the current day is the birthday or after, their age is calculated by means of this mathematical operation:
current year - year of birth
.
- If the current month is before the month of birth, their age is calculated by this mathematical operation:
-
The result is divided by the number of milliseconds in a year. To make it clear, in our example, we multiply 1 day in milliseconds (
86400000
) by the number of days in a year. -
The result is rounded down and presents the age of the customer.
-
Go to Analytics > Expressions > New expression.
-
Enter the name of the expression.
-
As a type of expression, select Attribute.
-
Build the following formula of the expression:
Part 1Part2
Part3
Click to see the video tutorial -
Save the expression.
Check the use case set up on the Synerise Demo workspace
Check the prepared expression directly in the Synerise Demo workspace.
If you don’t have access to the Synerise Demo workspace, please leave your contact details in this form, and our representative will contact you shortly.