Statistics Listener
Listen to placements' statistics events
Statistics Listener
StatisticsListener enables publishers to listen to all the placement-related statistics events. This might be useful e.g. to establish user-related analytics.
Set Statistics Listener for Placement
Use the following code to set the statistics listener for a specific placement:
placement.setStatisticsListener(this);
placement.statisticsListener = this
Complete Code Example
The below example can be applied to all types of placements.
private void requestAd() {
// Setting the impression delegate for the infeed-banner placement
inFeedBannerPlacement.setStatisticsListener(this);
BannerRequest request = new BannerRequest(this);
inFeedBannerPlacement.requestAd(request, (layout, error) -> {
// Display the banner or handle the error
});
}
// StatisticsListener implementation:
@Override
public void countedAdSpace(@NonNull Placement placement) {
// An ad space counted
}
@Override
public void countedMediationCycle(@NonNull Placement placement) {
// An mediation cycle counted
}
@Override
public void countedRequest(@NonNull Placement placement, @NonNull AdNetwork network) {
// An request counted
}
@Override
public void countedResponse(@NonNull Placement placement, @NonNull AdNetwork network) {
// An response counted
}
@Override
public void countedImpression(@NonNull Placement placement, @NonNull AdNetwork network) {
// An impression counted
}
@Override
public void countedVimpression(@NonNull Placement placement, @NonNull AdNetwork network) {
// An viewable impression counted
}
@Override
public void countedDirectDealImpression(@NonNull Placement placement, @NonNull AdNetwork network) {
// An direct deal impression counted
}
@Override
public void countedClick(@NonNull Placement placement, @NonNull AdNetwork network) {
// An click counted
}
private fun requestAd() {
// Setting the impression delegate for the infeed-banner placement
inFeedBannerPlacement.statisticsListener = this
val request = BannerRequest(this)
inFeedBannerPlacement.requestAd(request,
object : BannerRequestCompletionListener {
override fun onRequestCompleted(layout: BannerPlacementLayout?, error: BannerRequestError?) {
// Display the banner or handle the error
}
})
}
// StatisticsListener implementation:
override fun countedAdSpace(placement: Placement) {
// An ad space counted
}
override fun countedMediationCycle(placement: Placement) {
// An mediation cycle counted
}
override fun countedRequest(placement: Placement, network: AdNetwork) {
// An request counted
}
override fun countedResponse(placement: Placement, network: AdNetwork) {
// An response counted
}
override fun countedImpression(placement: Placement, network: AdNetwork) {
// An impression counted
}
override fun countedVimpression(placement: Placement, network: AdNetwork) {
// An viewable impression counted
}
override fun countedDirectDealImpression(placement: Placement, network: AdNetwork) {
// An direct deal impression counted
}
override fun countedClick(placement: Placement, network: AdNetwork) {
// An click counted
}
Last updated