2

Hoping someone can help us sort out this issue. It's clear that we had about 1000 visits to a post today that contains an embedded youtube video. Visitors spent an average of 3:35 minutes on the page, which has got to mean that most people watched the video, since the video is 4 minutes long: or, at least the majority of visitors must have watched enough of the video to count as a view. However, the video has only 375 views according to youtube.

The video is just regularly embedded on wordpress. There's a bit of intro text, but that's it (so no other reason to stay on the post for 3+ minutes if not for watching the video). So.... what's going on here!? Why is the view count so low?

My only thought is that maybe on certain devices the video autoplays or something like that, that might negate a view count? Anyway, if anyone has ideas please share! Thanks.

Here are the related link, and a screenshot of visits vs. view count.

The post: http://veganoga.com/weight-loss/fighting-sugar-carb-cravings/

And screenshot: enter image description here

migrated from wordpress.stackexchange.com May 23 '16 at 14:31

This question came from our site for WordPress developers and administrators.

1

Adding this bit of info. This screenshot shows a 48 hour period counted from wordpress and from youtube. You can see that the view chart matches (in shape), but the youtube count is much lower. The highest spike is counted at 162 views in an hour on wordpress, but youtube counts only 56 views during that same one hour period. So only about 1/3 of post views are actually resulting in video view count.... but if that was actually the case (i.e. if only 1/3 of visitors were clicking 'play' on the video), then surely the avg. time on the page for visitors would be much less than the 3:35 recorded by analytics.

enter image description here

  • I don't think this is an answer - you should add this info to your question (click the edit link) :) – Tim Malone May 24 '16 at 7:50
0

If a user comes to a page and spends 3 minutes watching a video then closes the page, they will have 1 page view with zero time on site. That is because Google Analytics only counts time on page as between when a user loads the page to when they load the next page. If a user closes the browser window or visits a bookmark next, Google Analytics never gets a report of how long they were on the page.

It is possible to send Google Analytics "events" that let it know that a user is on the page watching the video. On my video pages I use the YouTube JavaScript API to listen for when the user plays or pauses the video. When that happens, I have JavaScript that sends events to the Google Analytics server. I also send an event for being engaged in the video (watching 30 seconds) and ending the video (watching 80%).

This also allows you to visit the event reports in Google Analytics and get much more info about many users actually watching your videos. Here are my scripts (which require jQuery):

function logeventga(category, action, label, value, callback, nonAction){
    console.log("Event: " + category + " " + action + (label ? (" " + label) : "") + (value ? (" " + value) : "")); // allow
    var event = {
        'eventCategory': category,
        'eventAction': action
    };
    if (label) event['eventLabel'] = label;
    if (value) event['eventValue'] = value;
    if (callback) event['hitCallback'] = callback;
    if (nonAction) event['nonInteraction'] = 1;
    if (typeof ga == 'function' && ga.hasOwnProperty('loaded') && ga.loaded === true) {
        ga('send', 'event', event);
    } else if (callback) {
        callback.call();
    }
}

var videoengagetime = 30;
var tag = document.createElement('script');
tag.src = "//www.youtube.com/iframe_api";
var firstScriptTag = document.getElementsByTagName('script')[0];
firstScriptTag.parentNode.insertBefore(tag, firstScriptTag);

function onYouTubeIframeAPIReady(){
    $('.youtubevideo').each(function(){
        var vid = $(this);
        var player = null;
        var videoid = vid.attr('id');
        var vidcontainer = vid.parent();
        var clicktoplay = vidcontainer.parent().children(".video-click-play");
        if (clicktoplay.length > 0) {
            var beforestartvideo = null;
            if (!vidcontainer.is(":visible")) {
                var pagewidth = $(window).width();
                // in light box
                vidcontainer.detach();
                var vidclose = $('<button class=video-close>X</button>');
                var lightbox = $('<div class=video-lightbox></div>');
                lightbox.append(vidclose).append("<div class=clear></div>").append(vidcontainer);
                var fullscreen = $('<div class=video-fullscreen></div>');
                vidcontainer.show();
                $("body").append(lightbox).append(fullscreen);
                var width = pagewidth * .95;
                if (width > 1000) width = 1000;
                var height = width * 9 / 16 + 30;
                lightbox.css('width', width).css('height', height);
                beforestartvideo = function(){
                    fullscreen.css('height', $(document).height());
                    fullscreen.show();
                    lightbox.css('top', ($(window).height() - lightbox.outerHeight()) / 2 + $(window).scrollTop());
                    lightbox.css('left', ($(window).width() - lightbox.outerWidth()) / 2);
                    if (player === null || typeof player.playVideo != 'function') {
                        // If the video isn't ready to play yet, try again soon
                        setTimeout(startvideo, 200);
                    } else {
                        player.playVideo();
                    }
                };
                var closevid = function(){
                    player.pauseVideo();
                    fullscreen.hide();
                    lightbox.css('left', '-999em');
                };
                vidclose.click(closevid);
                fullscreen.click(closevid);
            }
            var startvideo = null;
            startvideo = function(){
                if (beforestartvideo != null) beforestartvideo.call();
                if (player === null || typeof player.playVideo != 'function') {
                    // If the video isn't ready to play yet, try again soon
                    setTimeout(startvideo, 200);
                } else {
                    player.playVideo();
                }
            };
            clicktoplay.click(startvideo);
        }
        player = new YT.Player(videoid, {
            videoId: videoid,
            events: {
                'onStateChange': function(event){
                    var timestamp = player.getCurrentTime();
                    var duration = player.getDuration();
                    var fractionDone = 0;
                    if (duration > 0) fractionDone = timestamp / duration;
                    switch (event.data) {
                        case YT.PlayerState.PLAYING:
                            player.logvidevent(player.playHappened ? 'resume' : 'play');
                            player.playHappened = true;
                            setTimeout(function(){
                                var interval = null;
                                interval = setInterval(function(){
                                    if (player.getCurrentTime() >= videoengagetime) {
                                        clearInterval(interval);
                                        player.engaged();
                                    }
                                }, 250);
                            }, (videoengagetime) * 1000);
                            break;
                        case YT.PlayerState.ENDED:
                            player.ended();
                            break;
                        case YT.PlayerState.PAUSED:
                            player.engaged();
                            if (!player.endHappened && fractionDone >= 0.8) player.ended();
                            else player.logvidevent('pause');
                            break;
                    }
                }
            }
        });
        player.playHappened = false;
        player.endHappened = false;
        player.engagedHappened = false;
        player.ended = function(){
            if (this.endHappened) return;
            this.engaged();
            this.logvidevent('end');
            this.endHappened = true;
            if (typeof videoOnEnd == 'function') videoOnEnd.call();
        };
        player.engaged = function(){
            var timestamp = this.getCurrentTime();
            var duration = this.getDuration();
            var fractionDone = 0;
            if (duration > 0) fractionDone = timestamp / duration;
            if (timestamp < videoengagetime && fractionDone < 0.8) return;
            if (this.engagedHappened) return;
            this.logvidevent('engaged');
            this.engagedHappened = true;
            if (typeof videoOnEngaged == 'function') videoOnEngaged.call();
        };
        player.logvidevent = function(name){
            logeventga('video', name, this.getVideoUrl());
        };
    });
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy