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




Best answer by timothy-permutable 24 May 2022, 11:20

View original

10 replies

Userlevel 4
Badge +7

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: 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: :) 




Userlevel 7
Badge +10

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?




Hi @Saish Redkar  @Zhenia Semenina  


Thank you for your reply


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 



Badge +10

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?


Userlevel 1
Badge +1

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.

Thanks in advance!


Badge +10

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

Userlevel 1
Badge +1

Ah yes good call thank you!

Userlevel 1
Badge +1

@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?


Thanks again!

Badge +10

Hi again! No I don’t think batch upload is the right approach - the mobile SDK has an “offline” configuration setting so I think it’s better to use that, and then simply send the events through when they are online again. However, I’m not up to date on this topic, so I suggest you make a support ticket or separate forum post and get advice from the Amplitude technical team.