Question

I have a Drupal website that has many smaple audio files on many pages. Some users come, listen to a sample, or listen to all of them and then leave.

But Google analytics does not track these clicks, even though in the option enabled:

Track downloads (clicks on file links) for the following extensions 7z|aac|arc|arj|asf|asx|avi|bin|csv|doc|exe|flv|gif|gz|gzip|hqx|jar|jpe?g|js|mp(2|3|4|e?g)|mov(ie)?|msi|msp|pdf|phps|png|ppt|qtm?|ra(m|r)?|sea|sit|tar|tgz|torrent|txt|wav|wma|wmv|wpd|xls|xml|z|zip

Which includes the mp3 files that I'm playing.

Then on Google Analytics in the Events section I can bearly see 3 mp3 downloads, and when I check my Apache log file, I have tens of clicks on mp3 files every day.

I'm using the soundmanager2 player that works as a link and with the help of Javascrip, Flash and CSS plays the mp3 files. http://www.schillmania.com/projects/soundmanager2/

How could I track these clicks on the soundmanager player? If needed I can install another statistics module than google analytics...

Many thanks

Was it helpful?

Solution

Depending the display mode you use and the type of player, the tracking to integrate is different.

Display Media

Here no custom tracking needs to be added. The Google Analytics Drupal module with Track download links enabled does the job.

SoundManager player

If you use any of the available players, you need to add a custom javascript code and add a callback on the play event which is triggered on the first play of the SoundManager player(s).

The javascript looks as follows:

// Add callback on play event
threeSixtyPlayer.events.play = function() { 
    var url = this.url, // retrieve URL for active played MP3
        file = url.substring(url.lastIndexOf('/')); // only keep filename of MP3

    // Push an event to GA
    _gaq.push(['_trackEvent', 'mp3', 'play', file.substring(1)]);
}

The event that is pushed to Google Analytics looks like this:

[mp3,play,Maid with the Flaxen Hair.mp3?uuid=525c67793bcd5]

Depending the used player, you should update and use to correct available instance.

SoundManager2 Page Player

pagePlayer.events.play = function() { ...

SoundManager2 UI 360

threeSixtyPlayer.events.play = function() { ...

SoundManager2 Inline player

inlinePlayer.events.play = function() { ...

SoundManager2 MP3 Basic player

basicMP3Player.events.play = function() { ...
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top