Analytics
1.7K members online now
1.7K members online now
Learn how to set up goals and Ecommerce tracking, verify accuracy of attribution traffic sources, and discuss funnel visualization, Multi-Channel Funnels, the Goal Flow Report, and Enhanced Ecommerce
 
Guide Me
star_border
Reply

How to correctly track a HTML5 video's stats in percentages

[ Edited ]
Visitor ✭ ✭ ✭
# 1
Visitor ✭ ✭ ✭

What steps do I need to take to correctly track my HTML5 video's stats such as views, plays, pauses, percentage of video played at 25%, 50%, 75% etc.

 

Is there a specific analytics code I can obtain for this functionality?

 

So far, the only information I can see is the number of times "video played" and "video paused" using the data from the google analytics tutorial.

2 Expert replyverified_user
1 ACCEPTED SOLUTION

Accepted Solutions
Marked as Best Answer.
Solution
Accepted by topic author Health a
August 2016

Re: How to correctly track a HTML5 video's stats in percentages

Top Contributor
# 2
Top Contributor

Hi,

 

Please try the code on the link below, I tested it and it works.

 

https://gist.github.com/placeless/6067714

 

Make sure the id in the code matches your html5 video tag's id:

 

var videoId = document.getElementById('video')

 

<video id="video">

 

Add the script before the closing body tag.

 

Hope this helps.


Arnold Majlath, Google Analytics Top Contributor
Was my response helpful? If yes, please accept it as solution.
Circle Me On Google+ | Visit me @ Redfly Digital

View solution in original post

Marked as Best Answer.
Solution
Accepted by topic author Health a
August 2016

Re: How to correctly track a HTML5 video's stats in percentages

Top Contributor
# 2
Top Contributor

Hi,

 

Please try the code on the link below, I tested it and it works.

 

https://gist.github.com/placeless/6067714

 

Make sure the id in the code matches your html5 video tag's id:

 

var videoId = document.getElementById('video')

 

<video id="video">

 

Add the script before the closing body tag.

 

Hope this helps.


Arnold Majlath, Google Analytics Top Contributor
Was my response helpful? If yes, please accept it as solution.
Circle Me On Google+ | Visit me @ Redfly Digital

Re: How to correctly track a HTML5 video's stats in percentages

Visitor ✭ ✭ ✭
# 3
Visitor ✭ ✭ ✭
Hi Arnold. Thanks for taking the time to reply. This was one of the codes I tried but I'm not sure it worked because I could not see the information on my analytics account. Is there some sort of area where I have to manually add the information from the code? Or does it take it automatically? For example, do I have to add "25% video played" on a new widget as an event label?

Re: How to correctly track a HTML5 video's stats in percentages

Top Contributor
# 4
Top Contributor
Hi,

You can see if the code is working using the Google Tag Assistant or GA debugger Chrome extensions. You can also check under Real Time -> Events. There is a delay in data processing in Google Analytics, it can take a few hours for the data to appear in the standard reports. You don't need to make any changes in GA in order to collect the events.

Let me know if you have more questions.

Arnold Majlath, Google Analytics Top Contributor
Was my response helpful? If yes, please accept it as solution.
Circle Me On Google+ | Visit me @ Redfly Digital

Re: How to correctly track a HTML5 video's stats in percentages

[ Edited ]
Visitor ✭ ✭ ✭
# 5
Visitor ✭ ✭ ✭

It's weird because looking at the code, Google Analytics takes the data for "video paused" and "video played" which is in the code, but the rest of it is being ignored, unless of course there's the possibility that no one finishes the video or gets to 25% which means there's no data to provide.

 

EDIT: I checked real-time events as suggested and it does seem to work but once again, not completely. I asked a coworker to play and watch the whole video. The data in real time showed "video played" but not "25% video watched" 50% video watched, etc, etc

Re: How to correctly track a HTML5 video's stats in percentages

Visitor ✭ ✭ ✭
# 6
Visitor ✭ ✭ ✭

EDIT 2:

I saw in my message someone asked what tutorial I was looking at:

Here's the link

Re: How to correctly track a HTML5 video's stats in percentages

Top Contributor
# 7
Top Contributor
Thanks Health a, that was me that asked re the tutorial. :-)
Bronwyn Vourtis, Google Analytics Top Contributor
Was my response helpful? If yes, please mark it as the ‘Best Answer.’ Learn how here

Re: How to correctly track a HTML5 video's stats in percentages

Top Contributor
# 8
Top Contributor
Hi,

It really seems that the code is not working for 25%, 50% and 75%. I'll check if I can find a solution.

Arnold Majlath, Google Analytics Top Contributor
Was my response helpful? If yes, please accept it as solution.
Circle Me On Google+ | Visit me @ Redfly Digital

Re: How to correctly track a HTML5 video's stats in percentages

[ Edited ]
Visitor ✭ ✭ ✭
# 9
Visitor ✭ ✭ ✭

That would be wonderful Arnold. The funny thing is, the code seems to be fine, no errors. So it's certainly odd it doesn't show up on GA

@Bronwyn V my pleasure! It seems outdated (not just the date) because Google in their tips section recommend using analytics.js over ga.js.

 

The tutorial uses ga.js.

Re: How to correctly track a HTML5 video's stats in percentages

Visitor ✭ ✭ ✭
# 10
Visitor ✭ ✭ ✭
Quick update/heads up:

I changed the order of the code at the bottom right before the end of the script. I added the percentages alone and changed the order of these also. They show now but the data doesnt seem correct. For example, 2 video clicks will watch to 25% but then 50% will show 5 clicks which is not correct. So it appears we're on the right track but just can't seem to get the order correctly.