Flowplayer + Piwik

Hi All,

First of all, I am a newbie, and have just started playing with Javascript. I am looking at integrating piwik with flowplayer.

My desire:
Be able to track when visitors start/stop videos, the time of the video and then what they did afterwards. I can then use this for A/B testing … which videos are better at getting people to convert, and at what points within the video do they defect.

What I’ve done:

Customized Flowplayer, added 2 piwik goals (video start and video stop) with the “Goal can be updated more than once per visit”.

Question:

I am now thinking of adding a custom variable (video time) which is updated anytime the video is started or stopped, and then using piwikTracker.trackGoal(1 for start, 2 for stop) to get the time into the database, which I could then query.

However, I can’t figure out how to set the custom variables. I tried both of the below:

On each start/stop:
1)


try {
	var piwikTracker = Piwik.getTracker(pkBaseURL + "piwik.php", 1);
	piwikTracker.setCustomVariable(1, "tm", this.getTime(), "page" );
	piwikTracker.trackGoal(2);
	piwikTracker.trackPageView();
	piwikTracker.enableLinkTracking();
} catch( err ) {}

Or


piwikTracker.setCustomVariable(1, "tm", this.getTime(), "page" );
piwikTracker.trackGoal(2);

What is the right way? Any advice?

Thank you!
David

P.S. I will provide a description of my methods once I get this working.

I think the problem here is, that ‘this’ refers to the piwikTracker object which has no getTime() function. In your flowplayer script you should assign the time value to a (global) variable and use that instead. Like:


[...]
timePlayed = myFlowplayer.getTime(); // assuming that your flowplayer object is named 'myFlowplayer'
[...]
piwikTracker.setCustomVariable(1, "tm", timePlayed, "page" );
[...]

Use Firefox with the Firebug Console for debugging.

We now have a Media Analytics plugin that tracks Videos & Audio!

More information is available here: http://www.media-analytics.net/ The plugin gives useful insights into media / video / audio analytics and adds many new reports, widgets and segments to Piwik.

Works with HTML5 video & audio, Vimeo and YouTube out of the box. Support for other players can be added easily and is documented in the developer docs. We are also happy to add support for more players upon request, please ping us. After installation the plugin will in most cases directly start tracking data see the setup guide

For a full list of features check out https://plugins.piwik.org/MediaAnalytics . Docs are available at FAQ, User Guide, Developer docs