Google Analytics

Introduction

This plugin allows you to track your media content in Google Analytics. It support VoD, livestreams as well as ads tracking. The plugin uses Google Analytics event tracking to record a number of different playback related events. The OVP analytics tracking is not replaced by usage of this plugin.

Prerequisites

Flowplayer Native, ads plugin if you want to measure ads and platform integration plugin if you want to use macro replacement for titles and similar.

Manual Javascrip setup

Load the plugin and the library from google next to the core player and any other plugins (ads, platform integration) you require. You will also need to add the Google Analytics analytics.js file on the same page as the player to make the plugin work.

<!-- Google Analytics -->
<script>
<script async src='//www.google-analytics.com/analytics.js'></script>
<script src="//cdn.flowplayer.com/releases/native/3/stable/flowplayer.min.js"></script>
<script src="//cdn.flowplayer.com/releases/native/3/stable/plugins/google-analytics.min.js"></script>

Player and plugins exist in different release versions. Please see the release channel documentation.

OVP managed async player

Include the plugin inside the "plugins": array with inline JSON.

Configuration (mandatory)

You can configure the plugin with top level configuration option ga in both the manual Javascript setup and inline JSON for async players. Itis not supported in iframe embeds.

The following properties are available:

    • property
    • description
    • ga_instances string
    • Array with the Google Analytics Ids that should be tracked.
    • media_title string
    • Use string directly or [media_name] as a placeholder for media title in metadata event. This is sent to Google Analytics as the eventLabel.
    • event_actions string
    • Optional replace of default action names. Leave empty if you want the default labels. This is sent to Google Analytics as the eventAction.
    • event_categories string
    • Optional replace of default category names. Leave empty if you want the default labels. This is sent to Google Analytics as the eventCategory.

Example of top level configuration:

ga: {
    ga_instances: ["UA-XXXXXX-X"],
    media_title: "[media_name]",
    event_categories: {live: "my_live_label"},
    event_actions: { live_start: "my_live_start_label"},
    custom_data: { dimension0: "my dimension value", metric0: "my metric value"}
}

Default labels:

These are the default labels for each event category and event action.

Event categories

    • event
    • label default
    • live:
    • "Live"
    • videos:
    • "Videos"

Event actions

    • property
    • description
    • fullscreen_enter
    • "fullscreen_enter"
    • fullscreen_exit
    • "fullscreen_exit"
    • video_player_load
    • "video_player_load"
    • video_start
    • "video_start"
    • video_click_play
    • "video_click_play"
    • video_pause
    • "video_pause"
    • video_resume
    • "video_resume"
    • video_mute
    • "video_mute"
    • video_unmute
    • "video_unmute"
    • video_25_percent
    • "video_25_percent"
    • video_50_percent
    • "video_50_percent"
    • video_75_percent
    • "video_75_percent"
    • video_complete
    • "video_complete"
    • live_start
    • "live_start"
    • live_click_play
    • "live_click_play"
    • live_pause -"live_pause"
    • live_resume
    • "live_resume"
    • live_mute
    • "live_mute"
    • live_unmute
    • "live_unmute"
    • live_complete
    • "live_complete"
    • ad_start_preroll
    • "ad_start_preroll"
    • ad_start_midroll
    • "ad_start_midroll"
    • ad_start_postroll
    • "ad_start_postroll"
    • ad_completed_preroll
    • "ad_completed_preroll"
    • ad_completed_midroll
    • "ad_completed_midroll"
    • ad_completed_postroll
    • "ad_completed_postroll"
    • ad_skipped_preroll
    • "ad_skipped_preroll"
    • ad_skipped_midroll
    • "ad_skipped_midroll"
    • ad_skipped_postroll
    • "ad_skipped_postroll"

Replace default labels:

It's possible to override the default labels for the event categories and event actions by specifying the event action/category in the config, for example: video_player_load: "my_custom_load_action".

Notice that when replacing the default labels all events that you want to track must be specified in the config including event actions were you don't want to change the label.

Ad positions

If you want information on the position of your ad, i.e if its the first, second, third etc preroll you are sending, please use the replace default labels, and make sure that you include '[x]' in your custom ad_start_preroll, example ad_startpreroll[x], and the plugin will ensure that the [x] is replaced so that the ad_start_sequence is ad_start_preroll_1, ad_start_preroll_2 etc. This is only applicable for the ad_start-events, but also includes ad_start_midroll and ad_start_postroll, with separate counters for all three events.

Tracking a subset of events:

It is possible to track only a subset of the events that is available in this plugin. Just add the event that should be tracked to the config and the plugin will only track those events.

Example that only tracks different start and complete events:

ga: {
    ga_instances: ["UA-XXXXXX-1"],
    event_actions: {
        video_start: "video_start",
        video_complete: "video_complete",
        live_start: "live_start",
        ad_start_preroll: "ad_start",
        ad_start_midroll: "ad_start",
        ad_start_postroll: "ad_start"
    }
}

Example with default tracking as typed in the Flowplayer platform add tracker fields

id: UA-538XXXX-X

trackPageView: false

trackEvents: false

config: {"media_title": "[media_name]"}

Demo

Codepen

Results