Video related analytics are an important part of a successful online video strategy. It can tell you which content works best for your audience and help with identifying viewing issues.
Our Google analytics integration will help you track video-centric data coming from Radiant Media Player in both real-time or "next-day" reporting. We have done most of the heavy lifting for you, essentially you just need to enter your Google Analytics property ID as an input setting and the player will start sending logs to your Google Analytics back-end.
Our integration is based on Google Universal Analytics (gtag.js) since player version 5.11.0. By default the player sends non-interaction events. Also note that events are sent with disable pageview measurement. Our integration is compatible with Google Analytics 3 and 4.
You can also refer to our analytics API for more advanced use-cases and custom integration.
gaTrackingId: String
Google Analytics property ID or GA_MEASUREMENT_ID. Typically looks like UA-XXXXXXXX-Y or G-XXXXXXXXXX. Default: ''
.
gaTrackingIdAlt: String
Google Analytics property ID or GA_MEASUREMENT_ID alternate in case you need to be sending measurement to an additional Google Analytics property. Typically looks like UA-XXXXXXXX-Z or G-XXXXXXXXXX. Default: ''
.
gaCategory: String
Set the Google analytics tracking category. Typically the object that was interacted with (e.g. 'Video'). Default: 'RMP'
.
gaLabel: String
Set the Google analytics label for each events. Use it to uniquely identify your content (e.g. 'Fall Campaign'). Default:
'RMP label'
.
gaEvents: Array
Lets you customise which events should be sent to Google Analytics. Default: ['ready', 'playerstart', 'bufferstalled', 'ended', 'error', 'adimpression', 'adplayerror',
'adloaderror']
.
gaAnonymizeIp: Boolean
When gaAnonymizeIp
is set to true, hits sent to Google Analytics will have
anonymized
IP addresses. This can help with compliance to specific privacy laws like GDRP. Default: false
.
getGALabel()
rmp.getGALabel();
This methods returns a
String
representing the current label used for Google Analytics.
setGALabel(newLabel)
rmp.setGALabel('new video title');
This methods takes as an input a non-empty String
and sets this input to be used as the current label for Google Analytics.
getGACategory()
rmp.getGACategory();
This methods returns a
String
representing the current category used for Google Analytics.
setGACategory(newCategory)
rmp.setGACategory('new video category');
This methods takes as an input a non-empty String
and sets this input to be used as the current category for Google Analytics.
sendGAEvent(eventName)
rmp.sendGAEvent('levelswitching');
This methods takes as an input a non-empty String
representing a player or custom event and sends this event to Google Analytics according to current player configuration. See below for a complete usage example.
<script src="https://cdn.radiantmediatechs.com/rmp/7.11.1/js/rmp.min.js"></script>
<div id="rmp"></div>
<script>
const src = {
hls: 'https://your-hls-url.m3u8'
};
const settings = {
licenseKey: 'your-license-key',
src: src,
width: 640,
height: 360,
contentMetadata: {
poster: [
'https://your-poster-url.jpg'
]
},
// Our Google Analytics settings
gaTrackingId: 'GA_MEASUREMENT_ID',
gaCategory: 'E-learning video',
gaLabel: 'How to start with HTML5 video',
gaEvents: ['ready', 'playerstart', 'bufferstalled', 'ended', 'error', 'adimpression', 'adplayerror', 'adloaderror']
};
const rmp = new RadiantMP('rmp');
rmp.init(settings);
</script>
Our implementation is based on gtag.js - Measure Google Analytics Events. Refer to this documentation for more information. Events can be tracked in both realtime and on-demand (e.g. "next-day") reporting in your Google Analytics 3 back-end:
In Google Analytics 4 back-end:
Note that Google Analytics imposes Limits and Quotas. As such the data collected by our Google Analytics implementation may only be partial - if you go over your account limit Google decides when to collect data or not. Our implementation takes this into account and allows to be customised to just send the events you are after. If you have a high volume of monthly video views you may consider upgrading to a Google Analytics 360/premium account for better analytics data accuracy.
Below is the list of default tracked events when a valid gaTrackingId
setting is provided:
ready
: the player has reached the ready state. This event only fires once per player session.playerstart
: this event fires when the first frame of content or pre-roll ad, if any, is presented to the viewer. When using related, playlist or the setSrc API method this event will fire each time a new item has started within
the player.bufferstalled
: the player is not playing content because it needs to get more data from the streaming server. When player resumes content because of
bufferstalled
a buffernotstalledanymore
is sent.
ended
: the player has reached the end of the content. This event may fire multiple times per player session. When loop
setting is used this event may not fire. error
: fires when a fatal error is encountered by the player (often due to a network issue where the player is unable to fetch content).adimpression
: fires when the impression URL has been pinged. This event may fire multiple times per player session.adplayerror
: the player could not player the creative returned from the ad-server.adloaderror
: the player could not load a creative as a result of the VAST request. This could be due to lack of inventory or network errors.imasdkloaderror
: the Google IMA SDK library has failed to load. No ad will be render in such case. This would mainly be due to an ad-blocker or less often a network error.Additional events for gaEvents
setting:
enterfullscreen
: the player has entered fullscreen mode. This event may fire multiple times per player session.exitfullscreen
: the player has exited fullscreen mode. This event may fire multiple times per player session.seeking
: the player has received a seek order. This event may fire multiple times per player session.fullminutewatched
: one full minute of content has been watched.pause
: the player has been paused, this could be due to a user interaction or a programmatic pause(). A resume
event fires when content starts again.adclick
: the player has registered a click for an ad. This event may fire multiple times per player session.If the 'context' event is also provided through the
gaEvents
setting, the player will also send data about the context in which it is rendered. Note that 'context' event requires 'ready' event to be registered as well. The value of the context event can be one of the following (the
related context event only fires once per player session):
html5-hls
: the player is loaded in HTML5 mode with HLS.html5-dash
: the player is loaded in HTML5 mode with DASH.html5-mp4
: the player is loaded in HTML5 mode with MP4 progressive download (H.264/AAC).html5-webm
: the player is loaded in HTML5 mode with WebM progressive download.
html5-m4a
: the player is loaded in HTML5 mode with M4A (audio-only) progressive download.html5-mp3
: the player is loaded in HTML5 mode with MP3 (audio-only) progressive download.html5-ogg
: the player is loaded in HTML5 mode with OGG (audio-only) progressive download.html5-outstream
: the player is loaded in HTML5 mode with outstream ads (no content).nosupport
: the player displays a no-support message to the viewer because it has no valid playback option.Through the sendGAEvent
API method it is possible to send custom events to your Google Analytics account. In the following example we will send a new event each time one full minute of content has been consumed by the viewer. We will
be using the getTimeViewed
analytics API method to get this information.
<script src="https://cdn.radiantmediatechs.com/rmp/7.11.1/js/rmp.min.js"></script> <div id="rmp"></div> <script> const src = { hls: 'https://your-hls-url.m3u8' }; const settings = { licenseKey: 'your-license-key', src: src, width: 640, height: 360, contentMetadata: { poster: [ 'https://your-poster-url.jpg' ] }, // Our Google Analytics settings gaTrackingId: 'GA_MEASUREMENT_ID', gaCategory: 'E-learning video', gaLabel: 'How to start with HTML5 video', gaEvents: ['context', 'ready', 'playerstart'] }; const rmp = new RadiantMP('rmp'); rmp.init(settings); // Here we start our custom script let lastDifferential = 0; // fullminutewatched event will be sent each time differential threshold has been reached (60000 ms === 1 minute) const sendingThreshold = 60000; // We will use an interval checking our differential threshold every 500 ms setInterval(() => { const timeViewed = rmp.getTimeViewed(); if (timeViewed > 0) { const diff = timeViewed - lastDifferential; if (diff >= sendingThreshold) { lastDifferential = timeViewed; console.log('fullminutewatched'); rmp.sendGAEvent('fullminutewatched'); } } }, 500); </script>
©2015-2022 Radiant Media Player. All Rights Reserved.