Giter VIP home page Giter VIP logo

videojs-ga's Introduction

videojs-ga

LOOKING FOR A MAINTAINER: I am looking for a maintainer for this project

Google Analytics plugin for video.js

Getting Started

Download videojs and videojs.ga

In your web page:

<video id="video" src="movie.mp4" controls></video>
<script src="video.js"></script>
<script src="dist/videojs.ga.min.js"></script>
<script>
videojs('video', {}, function() {
  this.ga(); // "load the plugin, by defaults tracks everything!!"
});
</script>

Please note that the Google Analytics script must be loaded before the ga plugin

Options

You can provide options to the plugin either by passing them in the javascript or in the html.

player.ga({
  'eventsToTrack': ['fullscreen', 'resize'],
  'debug': true
});
<video id="video" src="movie.mp4" controls data-setup='{"ga": {"eventsToTrack": ["error"]}}'></video>

The plugin will take in priority options provided in the javascript, followed by the ones provided in html and finally the defaults.

The following options are supported:

####eventCategory

This is the category sent to GA. If you don't know what it is please check GA's doc default: 'Video'

####eventLabel

This is the label sent to GA. If you don't know what it is please check GA's doc default: basename of the video path so if the path is http://s3.amazonaws.com/pouet.mp4 the label would be pouet

####eventsToTrack

The events you want to track. Most of this events are videojs events. Some of them might reflects my needs. I'm open to add some more if you care to provide a good use case or a pull request. default: every events [ 'loaded', 'percentsPlayed', 'start', 'end', 'seek', 'play', 'pause', 'resize', 'volumeChange', 'error', 'fullscreen']

Most of the events are selft explanatory, here's the ones that may need more details:

  • percentsPlayed: will send an event every X percents. X being defined by the option percentsPlayedInterval.

####percentsPlayedInterval

This options goes with the percentsPlayed event. Every percentsPlayedInterval percents an event will be sent to GA. default: 10

####debug

If set to false, console logs will be ommited default: false

ga.js and analytics.js

This plugin supports the ga.js and the newer analytics.js Google Analytics libraries. It autodetects the library you use.

See information in google

To view the data on Google, access your account in analytics, in left panel click in Behavior > Events > Top Events.

TODO

  • track the engine used (html5/flash) along with the source (ogg, mp4, ...)
  • track the time to download the video

videojs-ga's People

Contributors

breim avatar dominic-p avatar hosiawak avatar jakiestfu avatar mickey avatar pdebruic avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

videojs-ga's Issues

sendbeacon "percentsPlayedInterval" instead of "percent"

Hi.

As a videojs user now I need to get some information about "percent played" on some of my websites.

I've tried your code and it works, but I think the way it sends the percent played is not the easiest way to understand the information; I mean, when somebody plays 10% I get 10 as a value on my analytics. But if the video continues playing and reach 20% then "percent" = 20 is sent, so analytics shows "30" (10+20). I think the script should send 10 always if "percentplayedinterval" is set to 10. I was thinking about changing this piece of code

  for percent in [0..99] by percentsPlayedInterval
      if percentPlayed >= percent && percent not in percentsAlreadyTracked

        if "start" in eventsToTrack && percent == 0 && percentPlayed > 0
          sendbeacon( 'start', true )
        else if "percentsPlayed" in eventsToTrack && percentPlayed != 0
          sendbeacon( 'percent played', true, percent)

to this:

  for percent in [0..99] by percentsPlayedInterval
      if percentPlayed >= percent && percent not in percentsAlreadyTracked

        if "start" in eventsToTrack && percent == 0 && percentPlayed > 0
          sendbeacon( 'start', true )
        else if "percentsPlayed" in eventsToTrack && percentPlayed != 0
          sendbeacon( 'percent played', true, percentsPlayedInterval)

but before doing it I'd like to know if I'm omitting anything important, because you chase to use "percent" instead of "percentsPlayedInterval" on "sendbeacon" and probably you have your reasons.

Thank you for your time and your great project.

"Share" events?

Could you build out the functionality of the events that are trackable? We have a use case where we need to track interactions with the "Share" button and then the social network buttons on the share screen.

Detect Live and replace percentsPlayed with smthng like timePlayed

— Send timePlayed event in Live mode.
— Configure timePlayedInterval in minutes.

By the way, I used plugin for live and got "Uncaught Error: MediaSource.addSeekableRange() can only be invoked when the duration is Infinity". As far as I understand that it is related to the percentsPlayed event.

Maintainer wanted!

I am looking for a maintainer for videojs-ga because I am currently not using videojs anymore at all. This makes it hard to test changes and decide on architecture topics.

Please let me know in the comments if you are using it and are willing to take over maintenance.

Thank you!

Error Events in Google Analytics

Hey, I'm using videojs-ga and all events are saved in Google Analytics.

But, I'm getting error events, which are either playlist or not set.

Please, can anyone explain what do these errors actually refer to?

Loadedmetadata has no correspondance in defaultsEventsToTrack

Hi,

The defaultsEventToTrack contains 'loaded', but the underlying beacon is sent if eventsToTrack contains 'loadedmetadata', in the loaded function. So by default, no loadedmetadata beacon is sent to GA.

Could you rename loaded into loadedmetadata in defaultsEventToTrack?

dist/videojs.ga.js does not contain licene header

In contrast to dist/videojs.ga.min.js this file does not contain a license header.
In our case we use our own minification process and thus prefer to use the file videojs.ga.js (also for easier debugging in development environments in case) and it would be really nice if the license header would be there, too.
Thank you

How to extend/replace the sendbeacon function?

Hi,

This is a JS-noob question but I'm hoping someone can point me in the right direction.

I'd like to intercept the sendbeacon() function (reason: custom auditing, adblocked GA, etc...).

Can you advise on the correct way of doing that please? I tried

 player.ga().sendbeacon = function(action, nonInteraction, value) {
		console.log('intercepted');
	};

but that doesn't work.

Thanks

Michal

Tracking Percent Played

Just out of curiosity, how are you making sense of the percent played? Based on what I'm seeing the plugin is sending the percent played as 10, 20, 30, and so on. On the google analytics side you end up with an average value based on these different events.

So let's say 3 users that watch up to 30, 40, and 50 percent. The follow values will be sent:
User 1 sends -10, 20, 30
User 2 sends 10, 20, 30, 40
User 3 sends 10, 20, 30, 40, 50

The average played for these three users should be (30+40+50)/3=40. However, what you end up with in Google Analytics is (10+20+30+10+20+30+40+10+20+30+40+50)/12=25.83 which is quite far off from what is expected.

Multiple videos / video identifier

Question / feature request:

I'm tracking analytics for multiple videos on my site. Is there a way I can send a unique video ID to Google with each event?

eventAction customization

Not sure if it's here, and I'm missing it. But being able to customize the the eventAction name for each event would be valuable to us.

bower version is old

This might be my lack of experience with Bower but when I set up my pointer in my bower.json file to point to your git repo, it always pulls up a version 0.2.0 which is pointing to commit 72087286. I've cleared my bower cache and tried reinstalling but no joy.

I know you don't have a bower.json file in your repo to set up direct bower support (as I understand it) but I would have expected it to pull the latest commit.

searching bower for your package shows that it knows about the latest commit from 3 months ago. I'm confused why it wouldn't install that version.

I've attached some screenshots of my clearing my bower cache and installing fresh, then what the .bower.json file reports after installation.

Any thoughts?

(e)

screen shot 2014-05-13 at 6 01 27 pm
screen shot 2014-05-13 at 6 02 54 pm

Custom Events

This is more of a question. We have other plugins that we've made like a share module, chromecast, etc. We'd like to send events from these plugins also to GA. This might not be how Video JS plugins work, but is there any public method I can call from other plugins to send additional events?

Version 5

Hi!
Is it possible to update plugin to work with latest 5 version of the player?
Best Regards!

Get Parent URL?

I'm trying to track embeds on other domains. The videojs sits in an iframe from my domain. Is this possible for it to report impressions and plays by domain?

Cheers!
Ryan

How to get user specific data of video in Google analytics.

I've successfully created a player using HLS and Video JS, But Now facing some issue please guide me to resolve it

Issues:-

  1. How to start with 144p, Means whenever new video gets loaded start loading the lowest quality rather switching between 720, 480, 360, 240p, For that, I've tried "startLevel: 0" inside HLS configuration. But Looks does not work.

  2. I am trying to get analytics of the videos played by users so for that I am trying to us "videojs-ga" Plugin but Its sends details about the Videos played as good as I want but can anyone guide me how can I also send data about user to the analytics like "Username", "Email Id"

Simply we want to track each video played by used on our site with his/her details. So please guide me How can I achieve it.

I am using a WordPress Installment. If there is any plugin or any short of snippet available please let me know.

Support Google Universal Analytics

Please provide support for Google's new Universal Analytics tracker, analytics.js. I think all that is required is to use ga('send', … ) instead of the _gaq.push([…]) syntax.

Piwik !

Why develop a plugin of a open source project on a closed tool ?
Please consider using Piwik which is a real open source alternative

Can't see any tracking

Hello Mickey,

I've been trying to apply your plugin without success. Could you have a look at the code below and tell me if you see anything wrong with it?

This is the html defining the video element:

 <video id="xxx" class="video-js vjs-default-skin" controls preload="none" width="576" height="324" poster="img/cover-video-1.jpg" data-setup='{"ga": {"eventLabel": "The xxx Video", "gaLibrary": "analytics.js"}}'>
       <source src="http://xxx.mp4" type="video/mp4" />
       <source src="http://xxx.webm" type="video/webm" />
       <source src="http://xxx.ogv" type="video/ogg" />
 </video>

And this is the JavaScript at the bottom of the file:

 <script src="js/video-js/video.js"></script>
 <script src="js/video-js/videojs.ga.min.js"></script>
 <script>
       videojs('xxx', {}, function() {
       this.ga({'eventsToTrack': ['loaded', 'start', 'end', 'play', 'pause', 'fullscreen', 'resize', 'error']});
       });
 </script>

The video plays alright, and I've made sure all the scripts are in the right directories. Any clue why the events are not being tracked? Thank you very much in advance,

Maddy

play/pause not always tracking due "seeking"

I'm not sure what's here exactly at fault, but the play/pause events in my case are not tracked because "seeking" is "true" all the time.

The workflow I see is the following:

  1. user initiates playing the video, play gets triggered for the first time
  2. in this case, currentTime === 0 which means the play beacon gets not sent; but that's ok (I guess), the start event was triggered before anyway. But nevertheless, seeking gets set to true
  3. if the user now hits pause, the check looks like this: if currentTime != duration && !seeking. Since now seeking has been set to true and I don't see code setting it to false, play/pause will never trigger sendbeacon

I removed the seeking = true in play and in my limited testing it worked.

player.techName is undefined when using minified video.js

I noticed that the script uses this.techName, but I don't think that property is exported for use in the minified version. I get "undefined" in my GA reports.

Maybe some logic could be implemented that checks for player.Html5 and player.Flash instead of the techName property. You can see the list of exported properties in the exports.js file in the main video.js repo.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.