> 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).

# 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 %}


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://ios-docs.adster.tech/multiple-ads/carousel-banner-ad.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
