Media customers that are interested in tracking the amount of time users spend on their products would be interested in instrumenting a property that measures the duration between two events. With this property, users can then measure various items such as Average Property Value, Median Property Value, or use the duration values in complex formulas in our Event Segmentation: Formulas chart.
To track duration, you would need to capture the timestamp of a Start Event and timestamp of an End Event, calculate the difference between the two timestamps, and then pass in the duration as an event property for the End Event. In our demo account this End Event is called Played Song, and here is an example chart: https://analytics.amplitude.com/demo/chart/new/snewb09
As an example for Page View events, let's say you have a Start Event = 'Viewed Home Page' and an End Event = 'Clicked Signup'. When the user fires the 'Viewed Home Page' event, you can create a variable in your code called
first_timestamp and pass in the current timestamp. When the user is going to fire the 'Clicked Signup' event, you would calculate the difference between the current timestamp and
first_timestamp and pass that value into the 'duration' event property. You would then send the 'Clicked Signup' event with the 'duration' event property. This way, you can segment and filter on the value of the 'duration' event property for the 'Clicked Signup' event to see how long it took users to click that button after viewing your home page.
We also recommend normalizing the 'duration' event property to a numerical value like seconds so that you can perform functions such as property average in the UI.