Just a few years ago, websites mainly used text or graphic content. This was explained quite simply: the low speed of Internet connections did not allow more powerful resources to be used to influence the audience. Today, connection speed is no longer an obstacle, and video content is used on the vast majority of Internet resources.
Due to the growing popularity of video content, many website owners, when promoting websites, face the question: “How can video views on a website be tracked?”
As a rule, this question arises in order to determine and evaluate the target audience’s interest in video content. Thus, tracking interaction with video is, in the vast majority of cases, configured to determine three main criteria of user engagement:
- The visitor clicked “play” and started watching — the video attracted their interest, meaning they wanted to watch it.
- The visitor watched the video up to a certain point and stopped the video — whether or not their expectations were met.
- The visitor watched the video to the end — the video was enjoyable, interesting, or informative.
Today, there are several simple ways to configure video view tracking on a website using “Google Analytics”. All methods involve using the tracking code together with additional JavaScript code. This interaction helps not only control video playback but also send information in the form of events (track Event) directly to the tracking code.
It should be noted that each of the methods described below has a number of limitations, and currently there is no universal way to track information related to video views on a website. This should definitely be taken into account when choosing a configuration method for your web resource.
Option 1
This method is the simplest, but the Jquery library must be connected to the page containing the video.
First of all, you need to specify a link to the Js script in the code of the page containing the video. In practice, the insertion code looks as follows:
<script src=”//code.jquery.com/jquery-1.7.2.js”></script> <script type=”text/javascript” src=”/path/to/lunametrics-youtube.js”></script>
Next, using the standard YouTube code and an iframe, the video needs to be embedded on the page.
This makes it possible to track how many times the video was played and how many times it was watched to the end, providing a clear understanding of visitors’ interest in watching the video.
The main disadvantage of this method is that only one video can be connected to the “Google Analytics” tracking code. In addition, this tracking option is not suitable for tracking visitors who use mobile devices.
Option 2
This method is slightly more complicated than the previous one and differs in several features described below.
To implement this method, you need to specify a script file and additional code with the video ID on the page where the video content will be located. It looks approximately as follows:
<script src=”path/to/youtube.ga.min.js”></script> <script> var configYouTubePlayer = { videoID: ‘Rk6_hdRtJOE’ // The YouTube video ID. }; </script>
In addition, you need to place a DIV with “id = ytplayer” where the video will be located on the page. It will then be replaced by the script with an iframe containing the video:
<div id =”ytplayer”></div>
The specific feature of this method is that a greater amount of information can be tracked, such as:
- How viewing starts (playback) and how viewing ends — (started \ paused \ completed video).
- Viewing completion percentage — (when viewing reaches 25%, 50%, or 75% of the entire video).
NB!
– HTML5 must be supported by the browser!
– The event is tracked only on the first playback!
– The opt_noninteraction parameter is set to true, so events related to viewing video content do not affect the bounce rate!
– Only one video can be tracked, as with the first option, but there is an opportunity to choose which one to track!
– It is impossible to watch the video using mobile devices!
– Visitors who have JavaScript disabled will also be unable to see the video!
Option 3
This option is the most complicated, and its implementation requires the use of the YouTube API.
The following script needs to be inserted into the page where the video is located:
<script> var tag = document.createElement(‘script’); tag.src = “http://www.youtube.com/player_api”; var firstScriptTag = document.getElementsByTagName(‘script’)[0]; firstScriptTag.parentNode.insertBefore(tag, firstScriptTag);
var player; function onYouTubePlayerAPIReady() { player = new YT.Player(‘player’, { height: ‘390’, width: ‘640’, videoId: ‘Y8B9gMvcfQY’, events: { ‘onReady’: onPlayerReady, ‘onStateChange’: onPlayerStateChange } }); } function onPlayerReady(event) { /// event.target.playVideo(); } function onPlayerStateChange(event) { if (event.data ==YT.PlayerState.PLAYING) {_gaq.push([‘_trackEvent’, ‘Page Name’, ‘Video Name’, ‘Play’, player.getVideoUrl() ]); } if (event.data ==YT.PlayerState.ENDED) {_gaq.push([‘_trackEvent’, ‘Page Name’, ‘Video Name’, ‘Watch to End’, player.getVideoUrl() ]); } } </script>
After that, you need to specify the video ID in the video ID parameter and specify Page Name and Video Name in _trackEvent in any desired form.
Place the following DIV where the video is located:
<div id=”player”></div>
As a result of implementing this method, it is possible to track the start of video playback and whether the video was watched all the way to the end. For greater convenience when analyzing statistics, you can specify your own name for the video content.
All three options are currently suitable methods for tracking video views on a website. Undoubtedly, each of them has its own strengths and weaknesses, and after considering them, you can choose the method that will be best suited for collecting information under specific conditions.
Of course, there are many other ways to embed your own video on a website. In such cases, the tracking method will directly depend on the choice of player used to place video content on the pages of the web resource.
For example, Flow Player has source code with a plugin for connecting “Google Analytics”. The step-by-step instructions can be found here: http://flash.flowplayer.org/plugins/flash/analytics.html
Information on integrating “Google Analytics” into the Adobe Flash video player is available here: https://developers.google.com/analytics/devguides/collection/other/flashTrackingIntro?csw=1
For HTML5 video: http://www.elisa-dbi.co.uk/blog/how-to-integrate-google-analytics-in-video-html5-and-goodbye-to-flash/
The next step is to configure the event as a goal. To do this, you need to:
- In “Google Analytics”, click the “Administrator” tab.
- Go to the “Goals” tab and create a goal.
- Enter the goal name and select the “Event” type.
- Fill in the goal fields as follows:
- Category — identical.
- Action — identical.
- Label — identical.
- Value — identical.
- Click “Save”.
Summing up the above, it can be concluded that modern web analytics tools offer several effective ways to track visitors’ interaction with video content on a website.
Depending on the conditions, as well as the goals and objectives of the online project, choosing the most appropriate option that will provide the necessary amount of information for analysis and further optimization should not be particularly difficult.