Install Media Analytics using JavaScript install-web-sdks

The information on this page describes how to install the web standalone SDK and set up JavaScript.

Alternatively, you can use the Adobe Media Analytics extension to implement Analytics, as described in Implement Analytics using the Media Analytics extension.

Prerequisites prerequesites

  • Obtain valid configuration parameters

    These parameters can be obtained from an Adobe representative after you set up your analytics account.

  • Implement AppMeasurement and Experience Cloud Identity Service for JavaScript in your media application

    For more information, see Implementing Analytics Using JavaScript and Implementing Experience Cloud Identity Service.

  • Include the following APIs in your media player

    • An API to subscribe to player events - The Media SDK requires that you call a set of simple APIs when events occur in your player.
    • An API that provides player information - This includes information about currently playing media, ads, and chapter.

Set up JavaScript 3.x set-up-javascript

  1. Add your downloaded library to your project. Create local references to the classes for convenience.

    1. Expand the MediaSDK-js-v3*.zip file that you downloaded.

    2. Verify that the MediaSDK.js file exists in the libs directory.

    3. Host the MediaSDK.js file.

      This core JavaScript file must be hosted on a web server that is accessible to all pages on your site. You need the path to these files for the next step.

    4. Reference MediaSDK.js on all site pages.

      Include MediaSDK for JavaScript by adding the following line of code in the <head> or <body> tag on each page. For example:

      code language-html
      <script type="text/javascript" src="https://INSERT-DOMAIN-AND-PATH-TO-CODE-HERE/MediaSDK.js"></script>
      
    5. To quickly verify that the library was successfully imported, check ADB.Media is exported on Window object.

      note note
      NOTE
      The JavaScript SDK is compliant with the AMD and CommonJS module specifications, and MediaSDK.js can also be used with compatible module loaders.
  2. Create an instance of AppMeasurement and configure visitor.

    The Media SDK configuration requires an instance of AppMeasurement with visitor configured.

    code language-js
     var appMeasurement = new AppMeasurement("<rsid>");
     appMeasurement.visitor = visitor;
     appMeasurement.trackingServer = "<visitor_namespace>.sc.omtrdc.net";
    
  3. Configure Media SDK

    Media SDK should be configured once per webpage and the configuration applies to all the tracker instances created.

    note important
    IMPORTANT
    Media SDK (3.x) uses Media Collection API for tracking media which is different from the HB endpoint used in 2.x SDKs. Contact your Adobe representative to get more information.

    Here is a sample MediaConfig initialization:

    code language-js
    
     // Create MediaConfig object (same as above)
     var mediaConfig = new ADB.MediaConfig();
     mediaConfig.trackingServer = Configuration.MEDIA_COLLECTION_ENDPOINT;
     mediaConfig.playerName = Configuration.PLAYER_NAME;
     mediaConfig.channel = Configuration.CHANNEL;
     mediaConfig.appVersion = Configuration.APP_VERSION;
     mediaConfig.debugLogging = false;
     mediaConfig.ssl = true;
    
     ADB.Media.configure(mediaConfig, appMeasurement);
    
  4. Create the MediaTracker instance.

    After configuring Media SDK, tracker instances for tracking media content can be created using getInstance API.

    code language-js
    
    var tracker = ADB.Media.getInstance();
    
    note important
    IMPORTANT
    Make sure that your tracker instance is accessible and does not get deallocated until the end of the media session. This instance will be used for tracking all the following events for that session.

Migrate from JavaScript 2.x to 3.x

For detailed information about migrating from 2.x to 3.x, see 2.x to 3.x Migration.

For legacy content, see Legacy implementations

recommendation-more-help
c8eee520-cef5-4f8c-a38a-d4952cfae4eb