trackViewability()
From Engineering Client Portal
Viewability support requires additional parameters to be provided from player applications to the SDK. In order to provide those parameters and to start the viewability measurement trackViewability
method is added to the public SDK API.
Syntax
void trackViewability(JSONObject);
Calling trackViewability for a player view
String targetViewTag = targetView.getTag().toString();
String activityObj = MainActivity.this;
JSONArray friendlyTags = new JSONArray();
friendlyTags.put("friendlyViewTag1");
friendlyTags.put("friendlyViewTag2");
JSONObject json = new JSONObject();
json.put("viewContainer", activityObj);
json.put("viewTag", targetViewTag);
json.put("friendlyObstructions", friendlyTags);
sdkInstance.trackViewability(json);
Setting tag for a player view in layout xml
<SurfaceView
android:id="@+id/playerView"
android:tag="playerViewTag"
android:layout_width="match_parent"
android:layout_height="match_parent"
/>
Setting tag for a player view in Activity/Fragment
mPlayerView = (SurfaceView) findViewById(R.id.playerView);
mPlayerView.setTag("playerViewTag");
Input Parameters
Parameter | Description | ||||||
---|---|---|---|---|---|---|---|
data | JSONObject object with the following objects and keys:
|
Output Parameters
Output Parameters (Return value) | Description |
---|---|
Void |
Notes
If incorrect view tag is provided, SDK will not be able to measure viewability metrics. Viewability engine tries to find a view for the provided tag during 15 seconds and if it is not found it goes to inactive state. In order to restart the viewability engine it is required to call trackViewability with a proper tag again.