Tracking ad activity

Warning.

This is an archived version of the documentation. Actual documentation for all platforms can be found here.

The library lets you track events in the lifecycle of an ad (for example, unsuccessful queries and clicks) using a set of optional methods for the following protocols:

Banner ads

When working with this type of ad, use the following methods:

extension YourClass: YMAAdViewDelegate {
    func adViewDidLoad(_ adView: YMAAdView) { }
    func adViewDidFailLoading(_ adView: YMAAdView, error: Error) { }
    func adViewWillLeaveApplication(_ adView: YMAAdView) { }
    func adView(_ adView: YMAAdView, willPresentScreen viewController: UIViewController?) { }
    func adView(_ adView: YMAAdView, didDismissScreen viewController: UIViewController?) { }
}
Interstitial ads

When working with this type of ad, use the following methods:

extension YourClass: YMAInterstitialAdDelegate {
    func interstitialAdDidLoad(_ interstitialAd: YMAInterstitialAd) { }
    func interstitialAdDidFail(toLoad interstitialAd: YMAInterstitialAd, error: Error) { }
    func interstitialAdWillLeaveApplication(_ interstitialAd: YMAInterstitialAd) { }
    func interstitialAdWillAppear(_ interstitialAd: YMAInterstitialAd) { }
    func interstitialAdDidAppear(_ interstitialAd: YMAInterstitialAd) { }
    func interstitialAdWillDisappear(_ interstitialAd: YMAInterstitialAd) { }
    func interstitialAdDidDisappear(_ interstitialAd: YMAInterstitialAd) { }
    func interstitialAd(_ interstitialAd: YMAInterstitialAd, willPresentScreen webBrowser: UIViewController?) { }
}
Native ads

When working with this type of ad, use the following methods:

extension YourClass: YMANativeAdDelegate {
    func nativeAdWillLeaveApplication(_ ad: YMANativeAd) { }
    func nativeAd(_ ad: YMANativeAd, willPresentScreen viewController: UIViewController?) { }
    func nativeAd(_ ad: YMANativeAd, didDismissScreen viewController: UIViewController?) { }
}