Logo

Application collectors

Akamai AMP Media Player

Android Collector

The Akamai AMP Media Player is a configuration option for the Android Collector by Datazoom that makes the following additional data points automatically collectable in real time.

Events

Discrete occurrences driven by user interactions or system actions

Integration instructions

This library uses the amp-core library from Akamai Premier releases:
AMP for Devices - Premier: Android Build  9.9.6 (https://mdtp-a.akamaihd.net/amp-android-sdk/premier )

  1. Add the following maven repository URL in your project's build.gradle file

    // Snapshot Repository
    maven {
        url 'https://gitlab.com/api/v4/projects/18323233/packages/maven'
    }
    
    // Release Repository
    maven {
        url 'https://gitlab.com/api/v4/projects/10353305/packages/maven'
    }
  2. Add the following dependency in your project's build.gradle file's dependencies block

    Lib - AkamaiGoldCollector

    dependencies {
    	implementation 'com.datazoom.android:base-collector-gold:3.6.4'
        implementation 'com.datazoom.android:akamai-gold-collector:2.3.1'
    }
  3. Add following compile options if you don't have it already

    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }
  4. Append the following rules to the proguard-rules files, if you are using them in your app

    -keep class com.dz.collector.android.model.SuccessfulServerResponse**
    -keepclassmembers class com.dz.collector.android.model.SuccessfulServerResponse* {;}
  5. Add AMP Core library to your project 

    The Datazoom collector library uses the amp-core library for data collection.
    We've excluded the amp-core library from the collector library for customer convenience.
    The version and link to download the core library is: AMP for Devices - Premier: Android Build  9.9.6 (https://mdtp-a.akamaihd.net/amp-android-sdk/premier)

  6. Add the following additional dependencies to your project

    dependencies {
    	implementation 'com.google.guava:guava:27.1-android'
    }
  7. Use the following code snippet to add AkamaiPlayerCollector to your project.

    The following code snippet illustrates the usage of the AkamaiPlayer collector. Open demo application's MainActivity.java to see a running example.

    String configId = "<configuration id from Datazoom>";
    String configUrl = "<url given by Datazoom>";
    AkamaiPlayerCollector akamaiPlayerCollector = AkamaiPlayerCollector.create(videoPlayerView, MainActivity.this);
    akamaiPlayerCollector.setConfig(new DatazoomConfig(configId, configUrl))
        .connect(new DZBeaconConnector.ConnectionListener() {                          
            public void onSuccess(DZEventCollector dzEventCollector) {
    			//Everything is setup, collector initialization complete.
            }                         
            public void onError(Throwable t) {
    			//Error while creating akamai player collector
    			//showAlert("Error", "Error while creating AkamaiPlayerCollector, error:" + t.getMessage());
            }                    
        });

  8. After the player is done playing a content, invoke the collector’s releasePlayer() method to stop data collection for the player. Later if the same or a different play instance is used to play contents again, invoke the collector’s setPlayer() method to start data collection.

    // when content playing is done (completed or aborted)
    akamaiPlayerCollector.releasePlayer();
    ...
    // before requesting content playback again
    akamaiPlayerCollector.setPlayer(videoPlayerView);

    CUSTOM EVENTS & METADATA

    Datazoom allows customers to collect custom events and metadata that don't originate from a video player.

    Custom Metadata

    1. Create a JSONArray with necessary metadata

      JSONArray metadata = new JSONArray( "[{\"customMetadata\": \"MetadataValue\"}]");
    2. Add the metadata to DZEventCollector

       DZEventCollector.setCustomMetadata(metadata);

    Example:

    String configId = "<configuration id from Datazoom>";
    String configUrl = "<url given by Datazoom>";
    
    //Setup CustomMetadata here
    
     try {
            DZEventCollector.setCustomMetadata(new JSONArray("[{\"customPlayerName\": \"Akamai Player\"},{\"customDomain\": \"devplatform.io\"}]  "));
        } catch (JSONException e) {
            e.printStackTrace();
        }
    
    AkamaiPlayerCollector.create(videoPlayerView, MainActivity.this)
        .setConfig(new DatazoomConfig(configId, configUrl))
        .connect(new DZBeaconConnector.ConnectionListener() {                          
            public void onSuccess(DZEventCollector dzEventCollector) {
    		
            }                         
            public void onError(Throwable t) {
    		
            }                    
        });

    Custom Events

    1. Create an Event object

      Event event = new Event("Custom_Event_Name", new JSONArray());


      The first constructor parameter is the event name, and the second is a list of custom metadata to be included in the event.

    2. Add the event to DZEventCollector

      dzEventCollector.addCustomEvent(event);

    Example:

    @Override
    public void onSuccess(DZEventCollector dzEventCollector) {
        Event event = new Event("SDKLoaded", new JSONArray());
        dzEventCollector.addCustomEvent(event);
        btnPush.setOnClickListener(v - > {
            try {
                Event event1 = new Event("buttonClick", new JSONArray("[{\"customakamaiPlay\": \"true\"}, {\"customakamaiPause\": \"true\"}]  "));
                dzEventCollector.addCustomEvent(event1);
            } catch (JSONException e) {
                e.printStackTrace();
            }
        });
    }

Google IMA Ad Integration

  1. Add the following dependencies in your project's build.gradle file's dependencies block.

    dependencies {
    	implementation 'com.datazoom.android:plugin-google-ima:4.39.0'
    	api 'com.google.ads.interactivemedia.v3:interactivemedia:3.10.7'
    }
    
  2. Setup Google IMA Ad listener.
    After the collector initialization call this method.

          
          private void setupAdListeners(final DZEventCollector dzEventCollector) {
                if (adsManager != null) {
                   adsManager.addAdEventListener((AdEvent.AdEventListener)
                   dzEventCollector.adListener());
                }
            }
    
    


    Sample code :- https://gitlab.com/datazoom/mobile-android-group/mobile-android-akamai-demo/-/tree/Plugin-Google-IMA

Customers Using Freewheel Ads

  1. Add the freewheel manager libraries from Akamai Premier releases to your project.

  2. Setup the Freewheel Manager listener.

    After the collector initialization call this method

        @Override
          public void onSuccess(DZEventCollector dzEventCollector) {  
                    
            if (freewheelManager != null) {
                freewheelManager.addEventsListener((IAdsComponentListener) dzEventCollector);
                }       
          }