googlearchive/sample-media-pwa

Add analytics

Opened this issue · 6 comments

  • Event for watching a video
  • Event for finishing a video
  • Event for downloading a video for offline
  • Page visit

@johnpallett Any more?

duration of average playback would be good as well (not just 'finished' event). Otherwise LGTM

How do you capture "exit of video" and fire a "playback duration" if the webpage is being closed? Would that be a service worker type method?

How do you capture "exit of video" and fire a "playback duration" if the webpage is being closed?

You could do this in a window.onbeforeunload handler, right?

duration of average playback

Could we have median playback time per video rather than (or as well as) average playback?

A few other possible stats:
• Tap/click on a video thumbnail (i.e. for more information, before watching the video).
• Tap/click on play but playback fails (by some measure of 'fail').
• Tap/click on slider (scrub bar).
• Nice to have: record analytics events when the user is offline.

@samdutton I didn't think you could call an async function (such as report to analytics) from onbeforeunload and guarantee that it would fully execute?

I love how the related WebWorker version https://developer.mozilla.org/en-US/docs/Web/API/WorkerNavigator/sendBeacon
is just a massive load of NOPE for implemented on browsers.