> For the complete documentation index, see [llms.txt](https://aatkit.gitbook.io/ios-integration/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://aatkit.gitbook.io/ios-integration/advanced/advanced-delegates/impression-delegate-ilrd.md).

# Impression Delegate (ILRD)

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

### Impression Delegate

[`AATImpressionDelegate`](https://docs.gravite.net/aatkit/ios/docs/documentation/aatkit/aatimpressiondelegate) enables publishers to listen to impression events for all ad formats. Impression listener provides - amongst others - impression-level revenue data (ILRD) as an instance of[`AATImpression`](https://docs.gravite.net/aatkit/ios/docs/documentation/aatkit/aatimpression) object, in case the mediation type is supported (see details below).

### Listen to Placement Impressions

To set the impression delegate for a specific placement, use the following code:

{% tabs %}
{% tab title="Swift" %}

```swift
placement.impressionDelegate = self
```

{% endtab %}

{% tab title="Objective-C" %}

```objectivec
self.placement.impressionDelegate = self;
```

{% endtab %}
{% endtabs %}

{% hint style="info" %}
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. See the accuracy matrix below to learn how exact price information should be for given network and mediation type.
{% endhint %}

### Google Impression-Level Revenue

AATKit uses impression-level revenue data provided by Google to report impressions. To ensure this functionality works correctly for Google ads, please enable the impression-level ad revenue feature in your account's UI:

* [Google AdMob](https://support.google.com/admob/answer/11322405)
* [Google AdManager](https://support.google.com/admanager/answer/13404416?hl=en\&sjid=18368642623406695169-EU)

### Ad Network

Use the `func getAdNetworkName() -> String` method to get the string representation of the [AATAdNetwork](https://docs.gravite.net/aatkit/ios/docs/documentation/aatkit/aatadnetwork) enum.

### **Price Information**

Use the `getPriceInfo` method to get the [object representing detailed impression price information](https://docs.gravite.net/aatkit/ios/docs/documentation/aatkit/aatpriceinfo) (if available), like price, currency and precision type

{% hint style="info" %}
The price value passed in the impression object is the CPM price.
{% endhint %}

## Accuracy matrix <a href="#accuracy-matrix" id="accuracy-matrix"></a>

The accuracy of price information and used currency varies between ad networks and mediation types. Please see the following table for more information.

| AdNetwork                     | Mediation type | Accuracy                                | Currency             |
| ----------------------------- | -------------- | --------------------------------------- | -------------------- |
| AmazonHB                      | Any            | Exact                                   | USD                  |
| AppNexus                      | Any            | Exact                                   | USD                  |
| GraviteRTB                    | Any            | Exact                                   | USD                  |
| Google: AdMob, AdManager(DFP) | Any            | Depends on ad response from the network | USD                  |
| All other networks            | Waterfall      | no price information                    | no price information |
|                               | MAYO           | Floor price                             | EUR                  |

### Complete Code Example

{% hint style="info" %}
The below example can be applied to all types of placements.
{% endhint %}

{% tabs %}
{% tab title="Swift" %}

```swift

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.priceInfo)")
        print("Ad Network Name: \(impression.getAdNetworkName())")
    }
}
```

{% endtab %}

{% tab title="Objective-C" %}

```objectivec

@interface ViewController () <AATImpressionDelegate>
- (void)viewDidAppear:(BOOL)animated {
    [super viewDidAppear:animated];
    [AATSDK controllerViewDidAppearWithController:self];
    
    // Setting the impression delegate for the infeed-banner placement
    self.inFeedBannerPlacement.impressionDelegate = self;
    AATBannerRequest *request = [[AATBannerRequest alloc] initWithDelegate:self];
    [self.bannerInContentFeedPlacement requestAdWithRequest:request
                                                     completion:^(AATBannerPlacementWrapperView * _Nullable bannerView, AATBannerRequestError * _Nullable error) {
        // Display bannerView if not nil and error is nil
    }];
}

...

- (void)didCountImpressionWithPlacement:(id <AATPlacement> _Nullable)placement :(AATImpression * _Nonnull)impression
    NSLog(@"Banner Size: %@", impression.bannerSize);
    NSLog(@"Network Key: %@", impression.networkKey);
    NSLog(@"Ad Network: %ld", (long)impression.adNetwork);
    NSLog(@"Direct Deal: %@", impression.isDirectDeal ? @"YES" : @"NO");
    NSLog(@"CPM Price: %f", impression.price);
    NSLog(@"Mediation: %@", [impression getMediationTypeName]);
    NSLog(@"Ad Network Name: %@", [impression getAdNetworkName]);
    NSLog(@"Precision: %f", impression.precision);
}
@end
```

{% endtab %}
{% endtabs %}
