Class: AnalyticsAPI

AnalyticsAPI()

Analytics API class with methods for firing analytics events on ibm.com

Constructor

new AnalyticsAPI()

Source:

Methods

(static) initAll()

Initializes all analytics global tracking init functions

Source:

(static) initDynamicTabs()

This instantiates an event listener to trigger an event if the Carbon Tabs component is being interacted with by the user

Source:
Example
import { AnalyticsAPI } from '@carbon/ibmdotcom-services';

function init() {
  AnalyticsAPI.initDynamicTabs();
}

(static) initModals()

This instantiates an event listener to trigger an event if the Carbon Modal component is being interacted with by the user

Source:
Example
import { AnalyticsAPI } from '@carbon/ibmdotcom-services';

function init() {
  AnalyticsAPI.initModals();
}

(static) initScrollTracker()

If scroll tracking is enabled, this method will fire an event for every 400px user scrolls down the page. Only the deepest depth will fire the event (e.g if user scrolls back up the page, the event will not be triggered)

Deprecated:
  • Yes
Source:
Example
import { AnalyticsAPI } from '@carbon/ibmdotcom-services';

function init() {
  AnalyticsAPI.initScrollTracker();
}

(static) registerEvent(eventData)

This method checks that the analytics script has been loaded and fires an event to Coremetrics

Parameters:
Name Type Description
eventData object

Object with standard IBM metric event properties and values to send to Coremetrics

Source:
Example
import { AnalyticsAPI } from '@carbon/ibmdotcom-services';

function fireEvent() {
   const eventData = {
       type: 'element',
       primaryCategory: 'MASTHEAD',
       eventName: 'CLICK',
       executionPath: 'masthead__profile',
       execPathReturnCode: 'none',
       targetTitle: 'profile'
   }
   AnalyticsAPI.registerEvent(eventData);
}

(static) triggerModalHide(executionPath, targetTitle)

Triggers the HIDE event for the modal

Parameters:
Name Type Description
executionPath string

Target ID

targetTitle string

Target innerText

Source:

(static) triggerModalShow(executionPath, targetTitle)

Triggers the SHOW event for the modal

Parameters:
Name Type Description
executionPath string

Target ID

targetTitle string

Target innerText

Source:

(static) triggerTabSelected(executionPath, targetTitle)

Triggers to CLICK event for the dynamic tabs

Parameters:
Name Type Description
executionPath string

Target ID

targetTitle string

Target innerText

Source:

(static) videoPlayerStats(data)

Sends video player metrics data

Parameters:
Name Type Description
data object

event data from the video player

Source:
Example
import { AnalyticsAPI } from '@carbon/ibmdotcom-services';

function init() {
   const data = {
      playerType: 'kaltura',
      title: 'Folgers Coffee',
      currentTime: 1,
      duration: 60,
      playerState: 1,
      mediaId: '1_9h94wo6b',
   };

   AnalyticsAPI.videoPlayerStats(data);
}