Documentation

Google Analytics

Introduction

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 and on-demand reporting. As of Radiant Media Player 9 our integration is compatible with Google Analytics 4 - Google Analytics 3 could still work but is no longer supported with our player.

With Radiant Media Player 9 we no longer automatically load and configure Google Analytics client-side JavaScript library - this part needs to be done on your side, on the page where the player stands and prior to initializing the player. This allows for more advanced configuration of Google tag (gtag.js). This approach is also compatible when using Google Tag Manager.

You can also refer to our analytics API for more advanced use-cases and custom integration.

Google Analytics player settings

enableGAVideoTracking: Boolean

By default we do not enable Google Analytics tracking. Make sure to load and configure Google tag (gtag.js) on your page before initializing the player and enabling this setting. Default: false.

gaEventParameters: object

In Google Analytics 4, event parameters are passed as an object while sending custom event data to Google Analytics back-end. This setting allows to provide additional information for each event that the player sends to Google Analytics. This can be useful to pass video or series title to identify specific content with custom dimensions in Google Analytics back-end. See below for an example. Default: {}.

gaEvents: Array

Lets you customise which events should be sent to Google Analytics. Default: ['ready', 'playerstart', 'bufferstalled', 'ended', 'error', 'adimpression', 'adplayerror', 'adloaderror'].

Google Analytics player API

getGaEventParameters()

rmp.getGaEventParameters();

This methods returns an Object representing the current event parameters sent to Google Analytics with each event.

setGaEventParameters(eventParameters)

rmp.setGaEventParameters({
  'video_title': 'title_dev_ga_4',
  'series_title': 'dev_serie'
});

This methods takes as an input an Object and sets this input to be used as the current event parameters for each event sent by the player to Google Analytics.

Player code example

<!-- Google tag (gtag.js) - this needs to be included explicitly since Radiant Media Player 9+ (you may also use Google Tag Manager - see below) -->
<script async src="https://www.googletagmanager.com/gtag/js?id=G-XYZXYZXYZX"></script>
<script>
  window.dataLayer = window.dataLayer || [];
  function gtag() { dataLayer.push(arguments); }
  gtag('js', new Date());
  gtag('config', 'G-XYZXYZXYZX');
</script>
<!-- Radiant Media Player library -->
<script src="https://cdn.radiantmediatechs.com/rmp/9.15.10/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
    enableGAVideoTracking: true,
    gaEventParameters: {
      'video_title': 'title_dev_ga_4',
      'series_title': 'dev_serie'
    },
    gaEvents: ['ready', 'playerstart', 'bufferstalled', 'ended', 'error', 'adimpression', 'adplayerror', 'adloaderror']
  };
  const rmp = new RadiantMP('rmp');
  rmp.init(settings);
</script>

Using Google Tag Manager

When using Google Tag Manager with Google Analytics 4 you may not explicitly add Google tag (gtag.js) to your page. Instead Google Tag Manager automatically loads the appropriate script. For this to work with our player we however need to close the gap with Google Tag Manager in adding a little bit of code to our page, just after the Google Tag Manager script (typically this would be in the <head> of your page):

<script>
  window.dataLayer = window.dataLayer || [];
  function gtag() { window.dataLayer.push(arguments); }
  gtag('js', new Date());        
</script>

This should allow proper communication between our player and Google Analytics 4 servers when using Google Tag Manager.

Viewing data in Google Analytics 4 back-end

With Google Analytics 4, the way to view events data based on parameters has changed. While it is still possible to see in Reports > Realtime some level information about event parameters, you will have to learn how to use custom dimensions to get the most of Google Analytics 4 back-end.

Creating custom dimensions can be done in Admin > Property > Custom definitions and clicking the "create custom dimensions" button. For each event parameter you will need to create a custom dimension. More information on custom dimensions can be found on Google support site. Note that it may take 24H before a custom dimension can start presenting data in Google Analytics 4 back-end.

Once you have created your custom dimensions and can verify that the player is correctly sending data to Google Analytics servers, you can start exploring those data. Go to Explore > Free form (or any other kind of exploration) and within the "Variables" column of the exploration you should be able to select your custom dimensions in the "DIMENSIONS" cell. For example you could use the following combination:

  • ROWS: Event name
  • COLUMNS: Video title
  • VALUES: Event count

Note that Google Analytics imposes Limits and Quotas for its free analytics service. Paid solutions from Google may offer larger limits and quotas.

Player events for Google Analytics

Below is the list of default tracked events when enableGAVideoTracking setting is enabled and Google Analytics client-side JavaScript library is loaded:

  • 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.
  • adparserloaderror: the Google IMA SDK or rmp-vast 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):

  • hls: the player is loaded in HTML5 mode with HLS.
  • dash: the player is loaded in HTML5 mode with DASH.
  • mp4: the player is loaded in HTML5 mode with MP4 progressive download (H.264/AAC).
  • webm: the player is loaded in HTML5 mode with WebM progressive download.
  • m4a: the player is loaded in HTML5 mode with M4A (audio-only) progressive download.
  • mp3: the player is loaded in HTML5 mode with MP3 (audio-only) progressive download.
  • ogg: the player is loaded in HTML5 mode with OGG (audio-only) progressive download.
  • 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.
Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 3.0 License.

©2015-2024 Radiant Media Player. All Rights Reserved.