> For the complete documentation index, see [llms.txt](https://ios-docs.adster.tech/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://ios-docs.adster.tech/multiple-ads/carousel-banner-ad.md). Agents can also search and read this documentation through its [MCP server](https://ios-docs.adster.tech/~gitbook/mcp).

# Carousel Banner Ad

To receive multiple Banner Ads, you need to conform to the `MediationAdDelegate` protocol. This protocol will notify you when the ad is successfully loaded or failed to load.

**Implementation:**

```swift
extension BannerAdManager: MediationAdDelegate {
    func onCarouselBannerAdLoaded(carouselBannerAd: AdsFramework.MediationCarouselBannerAd) {
        guard !carouselBannerAd.ads.isEmpty else {
            print("Carousel Banner Ad request failed with reason no banner ads")
            return
        }

        addCarouselBannerToView(carouselBannerAd.ads)
    }
    
    func onAdFailedToLoad(error: AdsFramework.AdError) {
        print("Banner Ad request failed with reason \(error.description)")
    }
    
    func onAdRevenuePaid(revenue: Double, adUnitId: String, network: String, currency: String, precisionType: AdsFramework.PrecisionType) {
        print("Revenue: \(revenue) \(currency), adUnitId: \(adUnitId), network: \(network), precision: \(precisionType)")
        
    }
}
```

**Example carousel rendering:**

```swift
private func addCarouselBannerToView(_ bannerAds: [AdsFramework.MediationBannerAd]) {
    carouselStackView.arrangedSubviews.forEach { view in
        carouselStackView.removeArrangedSubview(view)
        view.removeFromSuperview()
    }

    for bannerAd in bannerAds {
        guard let bannerView = bannerAd.view else {
            continue
        }

        bannerAd.eventDelegate = self

        let slideView = UIView()
        slideView.translatesAutoresizingMaskIntoConstraints = false

        bannerView.translatesAutoresizingMaskIntoConstraints = false
        slideView.addSubview(bannerView)

        NSLayoutConstraint.activate([
            bannerView.centerXAnchor.constraint(equalTo: slideView.centerXAnchor),
            bannerView.centerYAnchor.constraint(equalTo: slideView.centerYAnchor),

            slideView.widthAnchor.constraint(equalTo: carouselScrollView.frameLayoutGuide.widthAnchor),
            slideView.heightAnchor.constraint(equalTo: carouselScrollView.frameLayoutGuide.heightAnchor)
        ])

        carouselStackView.addArrangedSubview(slideView)
    }

    pageControl.numberOfPages = bannerAds.count
    pageControl.currentPage = 0
}
```

**Tracking Events:**

To track click and impression events for Banner Ads, conform to `MediationBannerAdEventDelegate`:

```swift
extension BannerAdManager: MediationBannerAdEventDelegate {
    func recordBannerClick() {
        print("Banner clicked")
    }
    
    func recordBannerImpression() {
        print("Banner impression recorded")
    }
}
```

{% hint style="info" %}
Carousel Banner Ads return multiple banner ads in `carouselBannerAd.ads`. \
Each item is a `MediationBannerAd`, so add every banner ad's `view` to your carousel UI and assign `eventDelegate` for click and impression tracking.
{% endhint %}
