Vidyard allows you to pass engagement data from your videos directly into Google Analytics as set of viewer events.
Specifically, you can capture the number of times a viewers reach set milestones in your video (i.e. 25, 50, 75, 90%). This information is recorded in the events tracking section of Google Analytics in the following manner:
- Event Category > Player Title
- Event Action > Video Title
- Event Label > 0/25/50/75/90 (depending on the number of viewers that reach each percentage of the video)
You can then use these values to determine the number of viewers that watched a certain percentage of a video(s).
Pass data to GA from videos embedded on your own webpage
In addition to both the video embed code (inline or lightbox only) & the GA tracking code, you'll need to add an extra script to your webpage so that Vidyard can pass engagement milestones as events.
- Ensure your Google Analytics tracking script has been added on the page where your video is embedded.
- In the <body> of the page, add the following additional Vidyard script:
<script type = "text/javascript">
window.onVidyardAPI = (vidyardEmbed) => {
vidyardEmbed.api.addReadyListener((_, player) => {
var scriptTag = document.createElement('script');
scriptTag.src = "//play.vidyard.com/v0/google-analytics.js";
document.body.appendChild(scriptTag);
}, )
}
</script>
Pass data to GA from videos on a branded sharing page or hub
You can also share videos on a Vidyard-hosted branded sharing page or hub. Here's how you add the Google Analytics Tracking script to these pages:
- Sign in to Vidyard
- From the dashboard, select Channels, then click on sharing page or hub
- When editing a sharing page or hub, select the Integrations tab
- Enter your Google Analytics property ID to add the GA tracking code to your hub (UA-XXXXXXXX-X)
- Optionally, toggle Push views to Google Analytics Tracking to also pass video engagement milestones as viewer events
- Select Add
- Learn more about adding tracking scripts to sharing pages
- Learn more about adding tracking scripts to video hubs
Push additional viewer events to Google Analytics
If you want to capture additional viewer events (i.e. when someone pauses, seeks, or concludes a video), you can use the Vidyard Player API to log and pass this information to Google Analytics.
The following example captures an event whenever a viewer clicks play, pause, or watches to the end of a video (or a number of videos in a playlist):
<script type="text/javascript">
window.onVidyardAPI = (vidyardEmbed) => {
vidyardEmbed.api.addReadyListener((_, player) => {
var scriptTag = document.createElement('script');
scriptTag.src = "//play.vidyard.com/v0/google-analytics.js";
document.body.appendChild(scriptTag);
//The below code will send Play, Pause and End Reached events for the first Vidyard player available within your HTML
var video = VidyardV4.players[0];
video.on("play", function() { gtag('event', video.metadata.name, {'event_category': 'Videos','event_label': 'Play'})});
video.on("pause", function() { gtag('event', video.metadata.name, {'event_category': 'Videos','event_label': 'Pause'})});
video.on("playerComplete", function() { gtag('event', video.metadata.name, {'event_category': 'Videos','event_label': 'End Reached'})});
}, )
}
</script>