• Is there an already documented or plugin-ed method for doing this? Would love to see reports on play/usage of embedded media players.

Viewing 2 replies - 1 through 2 (of 2 total)
  • Thread Starter alanft

    (@alanft)

    there appears to be some way of doing it with a global var of _wpmejsSettings. I’m working towards using that nicely, but for now and for the record I’ve managed to get plays registered as GA events by hacking the wordpress/wp-includes/js/mediaelement/wp-mediaelement.js file. You can add some lines to the ‘finished setting up media’ callback function setting.success like this…

    settings.success = function (mejs) {

    mejs.addEventListener( ‘play’, function () {
    _gaq.push([‘_trackEvent’,’MediaElement’,’Play’,this.src]);
    }, false );
    }

    Hey,

    Just to add some useful information to this topic as it pointed me in the right direction.

    if( typeof _wpmejsSettings !== undefined )
    {
      _wpmejsSettings.success = function(element){
        // Add event listeners as per medialement.js docs
        element.addEventListener( 'play', function( e ) {
          // Do anything for this event
        }, false);
      };
    }

    I used the above javascript code to overwrite the success function, the same approach could be used for any of the mediaelement.js options.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Mediaelement hooks? (eg to fire Google Analytic _trackEvent)’ is closed to new replies.