Statistics Delegate
Listen to placements' statistics events
Statistics Delegate
AATStatisticsDelegate enables publishers to listen to all the placement-related statistics events. This might be useful e.g. to establish user-related analytics.
Set Statistics Delegate for Placement
Use the following code to set the statistics delegate for a specific placement:
placement.statisticsDelegate = self
Complete Code Example
class ViewController: UIViewController {
// Create the placement
lazy var placement = AATSDK.createStickyBannerPlacement(name: "<PLACEMENT_NAME>", size: .banner320x50)
override func viewDidAppear(_ animated: Bool) {
super.viewDidAppear(animated)
// [IMPORTANT] Notify AATKit about the currently active view controller
AATSDK.controllerViewDidAppear(controller: self)
// Set placement delegate to listen to the callbacks
placement.delegate = self
// Set placement statistics delegate to listen to the statistics callbacks
placement.statisticsDelegate = self
// Get the banner view
if let bannerAdView = placement.getPlacementView() {
view.addSubview(bannerAdView)
// Change the bannerAdView frame to your desired location on the screen
}
// reload the banner placement each 30 seconds.
placement.startAutoReload()
}
override func viewWillDisappear(_ animated: Bool) {
super.viewWillDisappear(animated)
// [IMPORTANT] Remove the currently active view controller
AATSDK.controllerViewWillDisappear()
// [IMPORTANT] Stop placement autoreload
placement?.stopAutoReload()
}
}
// MARK: - AATStickyBannerPlacementDelegate
extension ViewController: AATStickyBannerPlacementDelegate {
func aatHaveAd(placement: AATPlacement) {
// The placement has a new banner ad
}
func aatNoAd(placement: AATPlacement) {
// No ad available
}
func aatAdCurrentlyDisplayed(placement: AATPlacement) {
// Ad has been displayed on the screen
}
func aatResumeAfterAd(placement: AATPlacement) {
// Back to the app after clicking on the ad
}
}
// MARK: - AATStatisticsDelegate
extension ViewController: AATStatisticsDelegate {
func AATKitCountedAdSpace(placement: AATPlacement?) {
// An ad space counted
}
func AATKitCountedRequest(placement: AATPlacement?, for network: AATAdNetwork) {
// A request counted
}
func AATKitCountedResponse(placement: AATPlacement?, for network: AATAdNetwork) {
// A response counted
}
func AATKitCountedImpression(placement: AATPlacement?, for network: AATAdNetwork) {
// An impression counted
}
func AATKitCountedVImpression(placement: AATPlacement?, for network: AATAdNetwork) {
// A viewable impression counted
}
func AATKitCountedClick(placement: AATPlacement?, for network: AATAdNetwork) {
// A click counted
}
func AATKitCountedDirectDealImpression(placement: AATPlacement?, for network: AATAdNetwork) {
// A direct deal impression counted
}
func AATKitCountedMediationCycle(placement: AATPlacement?) {
// A mediation cycle counted
}
}
Last updated