Skip to content

Instantly share code, notes, and snippets.

@spra85
Created October 24, 2017 23:13
Show Gist options
  • Save spra85/7de0ecf03f506efd8f4cbc2b0a7823ea to your computer and use it in GitHub Desktop.
Save spra85/7de0ecf03f506efd8f4cbc2b0a7823ea to your computer and use it in GitHub Desktop.
FMG SDK GA notes

FMG SDK notes on direct GA implementation

Mapping of GA dimensions to object properties

Should be a central configuration in the SDK that contains a mapping of dimension[1,2,33,44,etc] to what metadata key they should be using to retrieve the value.

For instance, given the following central config mapping:

{
    dimension45: 'video_id'
}

The assumption can be made that a metadata object, when referenced inside the GA module, can assign dimension45 as follows:

let someMetadataObject = { video_id: 12345 };

// GA assignment
const dimensions = {
    dimension45: someMetadataObject.video_id
};
ga('set', 'dimensions', dimensions);

The configuration should contain metadata keys for all custom dimensions referenced in the FMG Video Events google doc here (https://docs.google.com/spreadsheets/d/1J650M0T-_iBLixzHuxq_MxUk3-T5KI13BFPCpEqi07M/edit#gid=615414060)

Different ways that metadata values can be passed in

Through the playVOD method of the SDK

For instance, on this line of mcpVideoPlayer.es6:

https://github.com/gawkermedia/kinja-mantle/blob/master/public/javascripts/module/mcpVideoPlayer.es6#L139

we're calling playVOD:

FMG.playVOD(videoConfig);

We should be able to pass into videoConfig any keys we want to be used, e.g.

FMG.playVOD({ metadata: { videoId: 12345, embedLocation: 'featured', contentType: 'permalink' } });

Set via metadata response from the video metadata hub response

The metadata is set once the ajax promise resolves here: https://github.com/univision/FMG-Video-SDK/blob/41799d589ebee21b6b6d639429510d02d7042503/src/app/scripts/modules/video-metadata-hub.js#L34

Snippet:

this.metadata[isPlaylist][mcpId] = promise = GlobalConfig.$.ajax(request);

Certain fields (like Video Length Seconds) should be provided as part of the video metadata hub response and mapped accordingly to GA dimensions

Another example, should be the Video Player Name & Version. For instance, JWPlayer-7.12.6.

Specific GA events to capture

All of the events we should be capturing are defined in the FMG Video Events doc here (https://docs.google.com/spreadsheets/d/1J650M0T-_iBLixzHuxq_MxUk3-T5KI13BFPCpEqi07M/edit#gid=1463713420).

If it's helpful, several of these are already implemented as separate modules inside of the Onion bulbs-elements repo (with tests):

Plugin: https://github.com/theonion/bulbs-elements/blob/master/elements/bulbs-video/plugins/google-analytics.js

Tests: https://github.com/theonion/bulbs-elements/blob/master/elements/bulbs-video/plugins/google-analytics.test.js

FMG SDK google analytics tracker config

The FMG SDK should provide a config option to pass in a GA tracker name, but default to using none, e.g.: None

window.ga('send', 'event', 'Video Play', 'action desc', 'label');

Option player-mcp-12345 passed in:

let playerConfig = {
      googleAnalyticsTracker: 'player-mcp-12345'
};

FMG.playVOD(playerConfig);

Results in the following convention for events fired through the SDK GA module:

window.ga('player-mcp-12345.send', 'event', 'Video Play', 'action desc', 'label');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment