Search code examples
javascriptvimeouniversal-analytics

Using Universal Analytics events to track video duration with timestamp


I'm currently sending an analytics event each time a video is closed/stopped from a modal. The videos are Vimeo and I'm using the API to watch the duration of the video on the time it is closed.

I'm using a Javascript date to differentiate each duration event.

var duration = 'vimeo play duration on stop';
var datelabel = new Date;

ga('send', 'event', 'Video Stop', 'Duration', datelabel, duration);

Is there a reason my datelabel is not showing up in the analytics dashboard? Am I not allowed to timestamp each duration to break up each play separately in the reports? If I were to use a fixed label, each duration value would be added together in the reports, which is what I DON'T want.

Thanks for reading and any advice is appreciated!


Solution

  • I see a few issues:

    1. new Date returns an object, not a string. Try var datelabel = new Date().toString();.

    2. You cannot pass in a string for event value. Event value only accepts numbers.