Using Google Analytics

Prev Next
Note: Google has deprecated the use of "Universal Analytics." As of July 1, 2023 you must use GA4 tags instead.

You can link the player to your Google Analytics account to receive analytics data regarding Play, Stop, Pause, and Resume events.

Analytics is controlled in the embed code for the media player in the var tdPlayerConfig section. If you plan to use Google Analytics, add the analytics section from the code example below to the embed code, then customize the properties.

        var tdPlayerConfig = {
               analytics: {
            active: true,
            debug: false,
            appInstallerId: 'tdinstallapp',            
            trackingId: 'G-AABBCCD64L',
            trackingEvents: [ 'play', 'stop', 'pause', 'resume', 'all' ],
            sampleRate: 5,     
            category: 'Triton SDK' 
      },
      coreModules: [{
            id: 'MediaPlayer',
            playerId: 'td_container'
      }],
      playerReady: onPlayerReady,
      configurationError: onConfigurationError,
      moduleError: onModuleError,
      adBlockerDetected: onAdBlockerDetected
    };

Properties

Customize the following properties to enable Google Analytics on your player:

Property
Type/OptionsDescription

active

Boolean (true|false)

true = log to Google Analytics.

false = do not log to Google Analytics.

debug

Boolean (true|false)

true = data is sent to the Google Analytics debug endpoint.

false = data not sent to the Google Analytics debug endpoint

appInstallerId

(String)

Optional. E.g., com.platform.vending

trackingId

(String)

Your unique GA4 tracking tag.

trackingEvents

(String)

List of events to track. ([ 'play', 'stop', 'pause', 'resume', 'all' ])  Default is 'all'.

category

(String)

The Google Analytics event category.

sampleRate

(0-100)

Percentage of users to be sampled for tracking. Default is 5.