How to track how many seconds a user was listening to a song using Google Analytics?

So, basically I have a simple javascript player when the user clicks on a song play and I track it with this code:

_gaq.push(['_trackEvent', 'player', 'play', 'songName', '0']);

      

This works great, now every 10 seconds I run this code again and I am wondering if there is a way to tell Google that this is the same song being listened to by the same user in just a few seconds.

maybe something like this:

_gaq.push(['_trackEvent', 'player', 'play', 'songName', '10']);

      

and then:

_gaq.push(['_trackEvent', 'player', 'play', 'songName', '20']);

      

and so on until it's over, but so far Google seems like they are all different events. Has anyone come across something like this before? any ideas?

+3


source to share


2 answers


AFAIK not a very easy way to do this in GA (actually it's pretty easy in other reporting tools like Omniture), but hey, you get what you pay for! But here are some suggestions ...

Instead of transmitting the current song position, skip how much was used from the previous event. In other words, 10 values ​​appear every 10 seconds. Then, in your reports in a metric group, you can use the Content> Event Value metric to display the total. The main disadvantage of this is that it will tell you how much of the song was listened to in general, but it doesn't really tell you how far the listeners were listening. For example, if he says "100", then it can be 1 person listening for 100 seconds or 10 people listening for 10 seconds. Sure, there are ways to get a little more granularity like the average consumption in general, but there are no real buckets to talk about.

An alternative is to create buckets to achieve the% milestones. Most people make increments of 10% or 25%. This is the most common way to do it as it reduces the number of queries made in GA and makes cleaner reports, fewer values ​​to sort (and if you think about it, knowing how many people listened to 36 seconds versus 37 seconds of something. probably not very efficient).

It will look like this:

Initial playback

_gaq.push(['_trackEvent', 'player', 'songName', 'play']);



25% listened

_gaq.push(['_trackEvent', 'player', 'songName', '25%']);

50% listened

_gaq.push(['_trackEvent', 'player', 'songName', '75%']);

100% listened

_gaq.push(['_trackEvent', 'player', 'songName', '100%']);

+4


source


as I said in my comment. just fire the start event and if the user clicks the stop button or leaves the page (onbeforeunload) click the stop event.

var isPlaying = false;
// the play start event
somestartbutton.onclick = function () {
   isPlaying = true;
  _gaq.push(['_trackEvent', 'player', 'songName', 'play']);
};


// the play start event
somestopbutton.onclick = function () {
  if (isPlaying) {
    isPlaying = false;
    _gaq.push(['_trackEvent', 'player', 'songName', 'stop']);
  }
};

// before the window is unloaded, which means the user leaves the page
window.onbeforeonload = function () {
  if (isPlaying) {
    isPlaying = false;
    _gaq.push(['_trackEvent', 'player', 'songName', 'stop']);
  }
}

      



of course you have to refactor this a bit, and DRY a little bit, but it should just give you an idea of ​​how it can solve your problem.

0


source







All Articles