Calculating age in AudienceStream when date_of_birth is captured via API

Gold Contributor
Gold Contributor

I have an offline event firing into Tealium via the HTTP API – not through TIQ.

I’m able to capture DOB from that and use it to set a date attribute but I’d like to use that to calculate age.

Without having an option such as javascript’s date.now(), I’m not sure how to go about doing this.

Any help from the hive mind would be amazing.

Head of Data Activation
Mediacom
1 REPLY 1

Calculating age in AudienceStream when date_of_birth is captured via API

Tealium Employee

Hi @PhilipWright ,

That can be accomplished, however there is a caveat.

Try the following:

  1. Create a "Visitor" attribute of type DATE and call it "Last event timestamp". Enrich it with the "Set date to current timestamp". This ensures you will have always the timestamp for the current event
  2. Create a "Visitor" attribute of type DATE and call it "Birthdate". Enrich it with the value that the imported data brings (event attribute?). (PS: choose the correct date format whilst enriching it)
  3. Create a "Visitor" attribute of type NUMBER and call it "Age in days". Enrich the number from the date attribute with the "Set difference between 2 dates", and chose the dates from step 1 and step 2.
  4. Create a "Visitor" attribute of type NUMBER and call it "Age multiplier". Enrich the number with a "Set number" static value of "0.002738"
  5. Create a "Visitor" attribute of type NUMBER and call it "Age calculated". Enrich the number with a "Set product" and choose the numbers from step 3 and step 4.

This gives you the correct years, however the caveat is that its a floating point and therefore it will have decimals.

 

 

Public