Impression Delegate (ILRD)

Listen to placements' impressions events (Impression-Level Revenue Data)

Impression Delegate

AATImpressionDelegate enables publishers to listen to impression events for all ad formats. Impression delegate provides - amongst others - impression-level revenue data (ILRD) as an instance of AATImpression object, in case the mediation type is supported (see details below).

Pass Impression Delegate to Placement

Use the following code to set the impression delegate for a specific placement:

placement.impressionDelegate = self

If the ad network provides impression-level revenue data, AATKit will use this information during the AATImpression instantiation and pass it to AATImpressionDelegate via the didCountImpression(placement:_:) callback. Otherwise, AATKit will detect and collect the impression-level information internally and provide it to the impression delegate via the same didCountImpression(placement:_:) callback.

Ad Network

Use the func getAdNetworkName() -> String method to get the string representation of the AATAdNetwork enum.

Mediation Type

Use the func getMediationTypeName() -> String method to get the string representation of the AATMediationType enum. It will return one of the following string values:

  • WATERFALL

  • AUCTION

  • MAYO

Price Currency

The impression price currency depends on the mediation type:

Mediation TypeCurrency

AUCTION

USD

MAYO

EUR

WATERFALL

Price not available

Precision

The precision type of an impression. It can be one case of AATImpressionPricePrecisionType.

Complete Code Example

The below example can be applied to all types of placements.


class ViewController: UIViewController {
    override func viewDidAppear(_ animated: Bool) {
	super.viewDidAppear(animated)
        AATSDK.controllerViewDidAppear(controller: self)
        
        // Setting the impression delegate for the infeed-banner placement
        inFeedBannerPlacement?.impressionDelegate = self
        let request = AATBannerRequest(delegate: self)
        inFeedBannerPlacement?.requestAd(request: request, completion: {[weak self] bannerView, error in
            // Display banner view if not nil and the error is nil
        })
    }
}

extension ViewController: AATImpressionDelegate {
    func didCountImpression(placement: AATPlacement?, _ impression: AATImpression) {
        print("placement: \(placement) - impression: \(impression)")
        print("Banner Size: \(impression.bannerSize)")
        print("Network Key: \(impression.networkKey)")
        print("Ad Network: \(impression.adNetwork)")
        print("Direct Deal: \(impression.isDirectDeal)")
        print("CPM Price: \(impression.price)")
        print("Mediation: \(impression.getMediationTypeName())")
        print("Ad Network Name: \(impression.getAdNetworkName())")
        print("Precision: \(impression.precision)")
    }
}

Last updated