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
4 REPLIES 4

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.

 

 

Calculating age in AudienceStream when date_of_birth is captured via API

Bronze Contributor
Bronze Contributor

Hi @ruipedromachado , I am trying to use the same setup. One questionn, how do you test if the age is being calculated?

Calculating age in AudienceStream when date_of_birth is captured via API

Tealium Employee

Hi @ruchit0622 

Steps:

  • Follow the setup
  • start a trace
  • send an event with the trace id and the data of birth
  • check the enrichments in trace, the processing result of the "Calculated Age" attribute should have the correct value

You should see something similar to my screenshot.


PS: Tealium as since then added the "Integer" option to the Number attribute. Might want to use that one instead as it might provide the age without the decimal value.

Calculating age in AudienceStream when date_of_birth is captured via API

Bronze Contributor
Bronze Contributor

Thank you @ruipedromachado 

Public