- Login to Datazoom here: https://app.datazoom.io
- Add a Collector as indicated here: How to add a Collector
- Copy the
config key
that was created at the end of the process
Click the icon indicated below to copy the Configuration Key
You will see this message:
4. Replace the <configuration id from Datazoom>
with the Key you copied above.
5. Replace the <url given by Datazoom>
with <https://platform.datazoom.io/beacon/v1/>
Adding dependencies to your project
Add following maven repository URL in your project's build.gradle file
maven { // 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' } }
Add the following dependency for Datazoom Exo Player SDK in your project's build.gradle file's dependencies block
dependencies { implementation 'com.datazoom.android:exo-collector:4.1.0' }
Add the following compile options if you don't have it already.
compileOptions { sourceCompatibility JavaVersion.VERSION_1_8 targetCompatibility JavaVersion.VERSION_1_8 }
Add the following additional dependencies to your project.
dependencies { // ExoPlayer Core library implementation 'com.google.android.exoplayer:exoplayer:2.9.2' // Google Ad Service implementation 'com.google.android.gms:play-services-ads:17.2.0' }
Use the following code snippet to add ExoPlayerCollector to your project.
The following code snippet illustrates the usage of ExoPlayer collector. Open demo application's MainActivity.java to see a running example.String configId = <configuration id from Datazoom>; String configUrl = <url given by Datazoom>; ExoPlayerCollector.create(player, MainActivity.this) .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 exo player collector //showAlert("Error", "Error while creating ExoPlayerCollector, error:" + t.getMessage()); } });
Custom Events & Metadata
Datazoom allows customers to collect custom events and metadata that don't originate from a video player.
Custom Metadata
a. Create a JSONArray with necessary metadata.
JSONArray metadata = new JSONArray( "[{\"customMetadata\": \"MetadataValue\"}]");
b. Add the metadata to DZEventCollector.dzEventCollector.setDatazoomMetadata(metadata);
Example:
@Override public void onSuccess(DZEventCollector dzEventCollector) { try { dzEventCollector.setDatazoomMetadata(new JSONArray("[{\"customPlayerName\": \"Exo Player\"}," + "{\"customDomain\": " + "\"platform.io\"}]")); } catch (JSONException e) { e.printStackTrace(); } }
Custom Events
a. 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.
b. 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("btnPush", new JSONArray("[{\"customPlay\": \"true\"}] ")); dzEventCollector.addCustomEvent(event1); } catch (JSONException e) { e.printStackTrace(); } }); }
Comments
0 comments
Article is closed for comments.