Solved

# How to calculate listen time in audio app..

Dear Community members

I have a following query. we are an audiobook summary app. and wants to do the following

1. Calculate audiobook listen time of each user for every audio.
2. calculate the total listen time of each user in a certain period of time.
3. create a behaviour cohort based on a certain listen time (eg >20 min)

would highly appreciate the help

Hey there,

Thanks for writing in!

The best way to implement it would be to track the duration / time listened as a property and then build our Segmentation chart that looks at properties.

E.g you could build a chart like this: https://analytics.amplitude.com/demo/chart/new/5i08o9i that looks at the duration and get’s you a sum / distribution / average etc.

I’ve seen quite a few customers that track ‘total listening time’ as a user property (incrementing it each time a user listens to something) and then tracking duration of every ‘play’ event so you can now by how many seconds to increment your total listening time for the user, so you could play around with that!

Maybe our Sample media taxonomy can also come in handy: https://help.amplitude.com/hc/en-us/articles/5447828227867#h_59e31f23-aa87-4a2e-81e5-c7f2b6f320f5 :)

Best,

Zhenia

Hey @Hemant

As Zhenia suggested, most of your use cases above can be tackled using the duration property on your desired events.

Adding to Zhenia’s suggestions, here’s a post which talks about instrumenting a duration property in your app

You can group by User ID in that chart to get the sum/average per user, but this will not be ideal for all your user IDs due to the group by limits.

For you cohort, you can use the total sum property on duration over your desired time interval. Something like this :

Another thing you can explore if you have access to it is Computations. This can enable aggregations/counts on the duration property and you can query it with more granularity.

Thank you @Saish Redkar and @Zhenia Semenina  for reply.

But my query is that as

duration = current time stamp - first event time stamp.

But if a user is playing an audio and they just kill the app. than how will “current time stamp” value be calculated and uploaded?

Regards

Hi @Saish Redkar  @Zhenia Semenina

But my question is that duration is calculated as the difference between current time stamp and first time stamp. but what if a listener is listening to an audio , turns their screen off.and after some time just kills the app. without opening it

In this case is there any process to calculate the duration ? as there is no ‘current time’ also there is no time to upload the duration to amplitude.

Best Regards

Hi Hemant,

Your question then relates mainly to how the “duration” property tracking is implemented, than how duration is calculated.

I’ve implemented similar events in the past (e.g. for video progress with Vimeo), and you should try to “listen” for progress update events from your audio player, and then fire an event like {“audio-elapsed”,elapsed_time:”20”}. You could for example listen for updates every minute, and then even if they kill the app you will know that your calculated duration is accurate to within 1 minutes.

How exactly to “listen” for updates depends on the audio player library you are using. What are you using in your app?

Best,

Hi @timothy-permutable , thanks for covering this!  But how can you then associate which particular media title received the audio listening time?

So for example to understand if a user listened to 3 mins of one media and 1 min of another media.

Jon

You would then simply add the title or id of the media as another event property for that event :)

Ah yes good call thank you!

@timothy-permutable , one additional question.  We are working on offline management  for when a user is consuming content without network connection.  We’d like to store our event/analytics info locally and then send this data to Amplitude on reconnect.  Is it best to do this via Batch Event Upload?