Expand my Community achievements bar.

What does the "Export APIs to Window object" option in Launch do for the Media 3.x Extension?

Avatar

Level 2

For the Media Analytics 3.x extension, there's an option to toggle on `Export APIs to Window object`. The documentation isn't clear on the purpose of this configuration. Can someone please help explain when this should be enabled?

Topics

Topics help categorize Community content and increase your ability to discover relevant content.

1 Reply

Avatar

Community Advisor

Based on my reading of the extension's source code and Media Analytics' documentation:

In a normal JavaScript implementation, Media Analytics would expose a "ADB" object. That object has a "ADB.Media" key that itself exposes certain functions that are used with Media Analytics tracking.

The "Export APIs to Window object" toggle seems to make the properties and functions provided in "ADB.Media" to be available at a global window scope.

In the extension's setting, you need to set a variable name. I think this can be whatever you want, e.g. "MyMediaAnalytics". So with the "Export APIs to Window object" toggle turned on and with this variable name, the result is that in your web page, you should have the following:

 

window.MyMediaAnalytics = {
  Media: {
    Event : ADB.Media.Event,
    MediaType : ADB.Media.MediaType, 
    StreamType : ADB.Media.StreamType,
    PlayerState: ADB.Media.PlayerState,
    MediaObjectKey : ADB.Media.MediaObjectKey,
    VideoMetadataKeys : ADB.Media.VideoMetadataKeys,
    AudioMetadataKeys : ADB.Media.AudioMetadataKeys,
    AdMetadataKeys : ADB.Media.AdMetadataKeys,
    version : ADB.Media.version,

    createMediaObject : ADB.Media.createMediaObject,
    createAdBreakObject : ADB.Media.createAdBreakObject,
    createAdObject : ADB.Media.createAdObject,
    createChapterObject : ADB.Media.createChapterObject,
    createQoEObject : ADB.Media.createQoEObject,
    createStateObject: ADB.Media.createStateObject,
    getInstance: ADB.Media.getInstance
  }
}

 

So, for example, if in a normal Media Analytics JavaScript implementation, you need to set a tracker with ADB.Media.getInstance(), then you would run:

 

var tracker = window.MyMediaAnalytics.Media.getInstance();

 

Note: as I've disclaimed at the start, the above is based on my reading of the extension's source code. I suggest that you try this out by enabling the toggle and providing a variable name, then running "window.[variable name]" in your browser console to see if you get back the expected object like I've listed above.