Skip to main content
Solved

Reference event timestamp in a derived property?

  • September 16, 2024
  • 4 replies
  • 220 views

Forum|alt.badge.img

Is there any way to reference the time of an event in a derived property formula?

 

I am trying to create a derived property that calculates the difference in time between a date in a user property (the users account creation date) and the date of the event being measured. I have gotten it to work using the TODAY() function, but I can’t seem to find any way to reference the event time itself. TODAY() only works if looking at the last N days, but I can’t use it to create historical trends. 

Thanks

DIVIDE(
	MINUS(
		TODAY()
        ,
        DATE_TO_LONG(
			REGEXEXTRACT(
				PROPERTY(
					'first_insert_date',
					'user'
				),
				"^\d{4}-\d{2}-\d{2}"
			)
		)
	),
	86400000
)

 

Best answer by Thao Nguyen

Hi Haytham,

Thank you for writing in. Happy to help!

Currently, the event timestamp is not directly available for use in derived properties. However, there are a couple of workarounds you can consider.

1. Use the `server_upload_time` property: This property represents the time when the event data is received by Amplitude's servers. If your events are being ingested in real-time, the `server_upload_time` and `event_time` would be very close to each other. Here's an example of how you can use the `server_upload_time` property:

DIVIDE(
	MINUS(
		PROPERTY('server_upload_time','amplitude_user')
        ,
        DATE_TO_LONG(
			REGEXEXTRACT(
				PROPERTY(
					'first_insert_date',
					'user'
				),
				"^\d{4}-\d{2}-\d{2}"
			)
		)
	),
	86400000
)

2. Create a custom property to track the event time: If you need to use the exact `event_time` in your calculations, one workaround could be to instrument a custom event property to track the event time on the client side, and then use this custom property in your derived property definition.

I hope this helps. Please don't hesitate to let me know if you have any questions.

Best regards,
Thao


P.S. Checkout upcoming events and user meetups on our events page.

View original
Did this topic help you find an answer to your question?

4 replies

Forum|alt.badge.img+5
  • Team Member
  • 92 replies
  • Answer
  • September 17, 2024

Hi Haytham,

Thank you for writing in. Happy to help!

Currently, the event timestamp is not directly available for use in derived properties. However, there are a couple of workarounds you can consider.

1. Use the `server_upload_time` property: This property represents the time when the event data is received by Amplitude's servers. If your events are being ingested in real-time, the `server_upload_time` and `event_time` would be very close to each other. Here's an example of how you can use the `server_upload_time` property:

DIVIDE(
	MINUS(
		PROPERTY('server_upload_time','amplitude_user')
        ,
        DATE_TO_LONG(
			REGEXEXTRACT(
				PROPERTY(
					'first_insert_date',
					'user'
				),
				"^\d{4}-\d{2}-\d{2}"
			)
		)
	),
	86400000
)

2. Create a custom property to track the event time: If you need to use the exact `event_time` in your calculations, one workaround could be to instrument a custom event property to track the event time on the client side, and then use this custom property in your derived property definition.

I hope this helps. Please don't hesitate to let me know if you have any questions.

Best regards,
Thao


P.S. Checkout upcoming events and user meetups on our events page.


Forum|alt.badge.img
  • Author
  • Novice
  • 3 replies
  • September 18, 2024

Thank you, the server_upload_time isn’t exactly accurate for me but is close enough, I’ll use this approach!

 

It would be nice to get event_time added to the available properties to reference without additional instrumentation. Feels like it should be possible if server_upload_time is?


Forum|alt.badge.img+5
  • Team Member
  • 92 replies
  • September 19, 2024
Hi Haytham,

You are welcome! I understand that using the `server_upload_time` might not be the ideal solution, but I'm glad to hear that it's close enough for your current requirements.

If you have any other questions, please do not hesitate to contact us. We will gladly address them!

Best regards,
Thao


P.S. Checkout upcoming events and user meetups on our events page.

Hi, we are using a somewhat basic setup for our application but we are not able to see any values when checking for “server_upload_time”. Is there something that we need to enable to see the values? Is there any other method to get a timestamp or at least a date where the event was created?

Thanks,

Martin


Reply


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings