In this topic, you will learn the use of the Google Analytics plugin and how it can be implemented using Studio and through custom coding.
Overview
The Brightcove Google Analytics plugin provides functionality to send data to Google Analytics. Note that the plugin supports both Google Analytics 4 and the older Universal Analytics. This document contains seven main content sections, those being:
Requirements: Requirements for using the Google Analytics Plugin v2.1.0 and newer.
Implement using Players module: Steps to follow to implement the plugin using Studio's Players module. Note that at this time configuration in the Players module must be done through the JSON Editor only. The user interface options are for Universal Analytics only.
The Google Analytics plugin first checks for the eventsToTrack option and the trackerID. If they're both present, it initializes GA and then listens for analytics-beacons and/or analytics_request events and on every player event, it checks if the event is present in the list of events to track. If it is, the plugin then gets the custom dimensions (that are also present in the paramsToTrack )associated with the event.
The events that are handled in the GA plugin and the custom dimensions associated with them are:
player_load - common custom dimensions
video_engagement - common custom dimensions + video_duration+video_range+seconds_viewed
video_impression - common custom dimensions
play_request - common custom dimensions
ad_start/ad_mode_begin - common custom dimensions
ad_end/ ad_mode_complete - common custom dimensions
error - common custom dimensions
video_view - common custom dimensions
video_complete - common custom dimensions
Custom dimensions include - video_account, video_player, video_session, video_platform_version, video_tags.
Requirements
Brightcove Player Google Analytics Plugin v2.1.0 and newer requires the following:
Brightcove Player v7.0.0 or newer
Setting Up the Google Analytics 4 account
Create a Google Analytics 4 Property.
Within their Property, create a Web Data Stream. Google also offers other types of “data streams” - iOS data streams and Android data streams, but our GA analytics integration does not support them.
Configuring Google Analytics
To configure Google Analytics integration, follow these steps:
Open the Players module.
Click the player name you want to configure to open the player properties.
Click Third-Party Analytics > Google Analytics in the left navigation menu.
Check Enable Google Analytics.
Click Sign In to Google Account.
Select the Google account to sign in with and enter your credentials if prompted.
Click Allow to let Brightcove access your Google account.
Use the Select Account dropdown to select the Google account to send tracking data to.
Click Save. This will configure the player with the Google Analytics plugin and create any needed custom dimensions in your Google Analytics account.
Make sure to publish the changes to the player.
Implement using Players module
To implement the Google Analytics plugin using the Players module.
In Studio select the Players module.
Click the player to which you wish to add the Google Analytics plugin.
In the Player's property screen select:
Third-Party Analytics -> Google Analytics
Check Enable Google Analytics
Click Sign in to Google Account
Complete the sign in process by entering information for your Google account and which Google Analytics account to send data.
Select a GA4 account Tracking ID in the Google Analytics 4 (GA4) dropdown.
Finish the configuration using the provided form.
Click Save. Publish your player.
Implement using code
To implement a plugin, the player needs to know the location of the plugin code, a stylesheet location (if needed), the plugin name and plugin configuration options. For the Google Analytics plugin:
The location of the JavaScript plugin code (no CSS needed in this instance) is as follows:
The standard configuration options are shown in the following code.
The following shows using the Advanced (embed) code implementation of the player to associate the Google Analytics plugin with a single instance of a player.
Line 1: Gives the video-js tag an id attribute, with some value, in this case myPlayerID.
Line 9: Uses a script tag to include the plugin's JavaScript in the body of the HTML page.
Line 13: Creates a reference to the player.
Lines 14-35: Initializes the plugin and passes in custom options.
The items listed below are plugin options used when configuring the Google Analytics plugin.
tracker: Google Analytics tracker ID.
eventsToTrack: An array that lists the events to send and the names that are used for those events.
Example: "player_load": "My name for player load event"
paramsToTrackGA4: An object that lists the parameters to include in events.
debug: Use true to turn on GA debug URL and visualize console trace. This should not be used in a production environment.
GA4 events and custom dimensions
Any event name used by the player's analytics_event and analytics-beacon events can be used, but the following have special handling in the GA plugin:
ad_end
ad_start
error
play_request
player_load
video_engagement
video_impression
video_view
The following are custom dimensions available for use:
account
platform_version
player
range
seconds_viewed
session
tags
video_duration
Parameters, which you add as custom dimensions in Google Analytics, are associated with event. The following parameters are common to all events:
account
player
session
tags
version
The video_engagement event includes the five parameters listed above, and also adds:
range
seconds_viewed
video_duration
GA4 and UA dual tagging example configuration
At this point in time (early 2023) both Google Analytics 4 and Universal Analytics are valid. The following is an example of dual tagging, where both Google Analytics 4 and Universal Analytics would function.
Dual tagging (both Google Analytics 4 and Universal Analytics)
To ensure that data continues to be collected across Brightcove products with Google Analytics plugins, you must upgrade your Players to use GA4 instead of Universal Analytics.