A neat feature of developing for the Kaltura platform is being able to write code once and have it work regardless of the underling playback system. In this post I walk you through writing a simple google analytics library using the KDP api. I will show how it works for both html5 and kaltura flash kdp players. If your want to just jump into the code you can check out the kaltura google analytics demo page here. If you would like to download this example its available here

To write this plugin we will touch on:

  • Google analytics is of course the popular web site tracking system. It includes a system for tracking custom events, which we will use to register player events.
  • Kaltura KDP player is the dynamic flash player that has an extensive api for accessing events and notifications in javascript.
  • Kaltura HTML5 player library is an html5 player used in the kaltura platform. In addition to supporting the HTML5 api, the library also supports a good portion of the KDP api.

To start we copy the google analytics setup code:

Then we will want to include the kaltura html5 library loader. To include that we simply add the following:

Then on our client page we wait for the kdp player to be ready via the jsCallbackReady call, then instantiate the kGoogleAnalytics object:

Lets take a look at how the kGoogleAnalytics works. kGoogleAnalytics take a list of eventTrackList and validates that list against the full set of notifications supported by the kdp api. Then it binds the events to the kdp player ( which can be an html5 player or flash player underneath ) like so:

Note: Because the flash player listners call in the global namespace, we do some minor tricks to generate a global function name that can be used with the flash listener. If your library was dependent on jQuery you could avoid the local anonymous function closure call with an outer $.each( loop on the the eventTrackList ).

Once the listeners have been added to the player we will receive all the player notifications in the playerEvent method.

Here we generate a tracking event array and send it off to the google pageTracker. Google has started supporting two modes of sending events, via the pageTracker object or via appending to the global _gaq array. Here we support both. We also provide a convince function to monitor google analytic events we are sending.

One last custom event is the quartiles event, here we send beckons for every 1/4th of the video. This is helpful for analyzing fall-off rates and what percentage of the video has been viewed. Here we make use of playerUpdatePlayhead listener event and the ‘evaluate’ function of the kaltura api to get the clip duration. Here you can see how we get at the duration in the getQuartilesStatus function:

Pulling it all together we have the following page, that sends the same google analytic events regardless of if the player is in ‘flash’ or html5 mode.


Share this
Share on FacebookTweet about this on TwitterShare on LinkedInShare on Google+Email this to someone

Website Comments

  1. شركة الصفرات 0566031233

    [url=https://www.youtube.com/watch?v=4NoVGKDyruc&feature=youtu.be]شركة تنظيف فلل بالدرعية[/url]
    [url=https://www.youtube.com/watch?v=ec9I–DcDaU&feature=youtu.be]شركة تنظيف فلل بعنيزة[/url]
    [url=https://www.youtube.com/watch?v=XFdUtgRkoQg&feature=youtu.be]شركة تنظيف فلل ببريدة[/url]
    [url=https://www.youtube.com/watch?v=Ffo_2tT974I&feature=youtu.be]شركة تنظيف فلل بالمذنب[/url]
    [url=https://www.youtube.com/watch?v=VtTOoxGUD8w&feature=youtu.be]شركة تنظيف فلل بعفيف[/url]
    [url=https://www.youtube.com/watch?v=s-1ccCDwlZA&feature=youtu.be]شركة تنظيف فلل بالغاط[/url]
    [url=https://www.youtube.com/watch?v=lxUZ0Xiq60E&feature=youtu.be]شركة تنظيف فلل بثادق[/url]
    [url=https://www.youtube.com/watch?v=ZuZVdKyP3hs&feature=youtu.be]شركة تنظيف فلل بالدوادمى[/url]
    [url=https://www.youtube.com/watch?v=GdwmJYBRqrQ&feature=youtu.be]شركة تنظيف فلل بالمزاحمية[/url]
    [url=https://www.youtube.com/watch?v=CnU7qBcg5io&feature=youtu.be]شركة تنظيف فلل بالقويعية[/url]
    [url=https://www.youtube.com/watch?v=xEZQHmfvwWk&feature=youtu.be]شركة تنظيف فلل بوادي الدواسر[/url]
    [url=https://www.youtube.com/watch?v=rJtforBpz-0&feature=youtu.be]شركة تنظيف فلل بالدلم[/url]
    [url=https://www.youtube.com/watch?v=VQyanQ25wrM&feature=youtu.be]شركة تنظيف فلل برماح[/url]
    [url=https://www.youtube.com/watch?v=jPKunu-fSEc&feature=youtu.be]شركة تنظيف فلل بالأفلاج[/url]
    [url=https://www.youtube.com/watch?v=q5_qCTHD0ZQ&feature=youtu.be]شركة تنظيف فلل بحريملاء[/url]
    [url=https://www.youtube.com/watch?v=ZivrcTJC47E&feature=youtu.be]شركة تنظيف فلل بالزلفي[/url]
    [url=https://www.youtube.com/watch?v=rjh7aDrG5Pg&feature=youtu.be]شركة تنظيف فلل بضرما[/url]
    [url=https://www.youtube.com/watch?v=RNBoekMz8JQ&feature=youtu.be]شركة تنظيف فلل بشقراء[/url]
    [url=https://www.youtube.com/watch?v=k4XV1cQn21g&feature=youtu.be]شركة تنظيف فلل بالسليل[/url]
    [url=https://www.youtube.com/watch?v=n6opzU4XCkw&feature=youtu.be]شركة تنظيف فلل بالقصيم[/url]
    [url=https://www.youtube.com/watch?v=uEBFy9fdGyU&feature=youtu.be]شركة تنظيف فلل بحوطة بني تميم[/url]
    [url=https://www.youtube.com/watch?v=NTrVQKc2zmk&feature=youtu.be]شركة تنظيف فلل بالحريق[/url]
    [url=https://www.youtube.com/watch?v=phHnxQz3c2I&feature=youtu.be]شركة تنظيف فلل بالمجمعة[/url]
    [url=https://www.youtube.com/watch?v=3TRj63RPlu4&feature=youtu.be]شركة تنظيف فلل بمرات[/url]
    [url=https://www.youtube.com/watch?v=bikUYPos3BU&feature=youtu.be]شركة تنظيف فلل بالرس[/url]
    [url=https://www.youtube.com/watch?v=C7uk7eRVLLQ&feature=youtu.be]شركة تنظيف فلل شرق الرياض[/url]
    [url=https://www.youtube.com/watch?v=N5oZJRf02uM&feature=youtu.be]شركة تنظيف فلل غرب الرياض[/url]
    [url=https://www.youtube.com/watch?v=tQ2Vn4J7P_k&feature=youtu.be]شركة تنظيف فلل شمال الرياض[/url]
    [url=https://www.youtube.com/watch?v=xW3MR2fSDlU&feature=youtu.be]شركة تنظيف فلل جنوب الرياض[/url]
    [url=https://www.youtube.com/watch?v=xV9Eve9vFYI&feature=youtu.be]شركة تنظيف فلل وسط الرياض[/url]

  2. Stephy

    I checked the source of the demo example, there is no
    Is the library loader replaced by the mwEmbedLoader.php now or I’m misunderstanding something?

  3. Do more

    Thanks for this Post
    What do I get with these analytics? Does this show bandwidth usage and partner activity usage too? I just want bandwidth usage and partner activity usage report? Will it work? By default I am unable to get bandwidth_usage reports in kaltura’s analytics tab. Please tell
    Thanks in advance

  4. Michael Dale

    I have updated the links to the sample page. jsCallbackReady might might get fired if you have an old version of jQuery. You can post the page in question to the kaltura forms and I can take a look at it. The sample page link should be working as well. You can take a look at that as an example.

  5. OeM

    Hi! I really like this solution, however I can’t get it to work. First of all, the demo page seems to have been removed. Also, when running the downloadable example on my local computer, no events are being listed. When trying to implement this feature on my own project, jsCallbackReady are only called from the Flash-version of the player, and not when running in html5-mode. Any ideas?

Post a comment