---
title: Impression Level Data
---

CAS.AI SDK enables you to access detailed information for each impression through the impressions callback APIs. The information includes, for example, which demand source served the ad, the expected or exact revenue associated with it. In addition, it contains granular details to allow you to analyze and, ultimately, optimize user acquisition strategies. 

## AdContentInfo
The `AdContentInfo` data structure, which contains information about the loaded/displayed ad. 

Additionally to `impressionDelegate`, each ad format has a `contentInfo` property that returns `AdContentInfo`, but the info may be `nil` before the ad is loaded.

<CodeGroup synchronize="true">
```swift
let info: CASContentInfo? = eachAd.contentInfo
```

```objc
CASContentInfo *info = eachAd.contentInfo;
```
</CodeGroup>

<Property name="format" type="AdFormat">
  The format of the ad that is shown.
</Property>

---

<Property name="sourceName" type="String">
  The display name of the mediated network that purchased the impression.
</Property>

---

<Property name="sourceId" type="AdSource">
  The ID of the mediated network that purchased the impression.
</Property>

---

<Property name="sourceUnitId" type="String">
  The Ad Unit ID from the mediated network that purchased the impression.
</Property>

---

<Property name="creativeId" type="String?" optional>
  The Creative ID associated with the ad, if available.
  You can use this ID to report creative issues to the Ad review team. 
</Property>

---

<Property name="revenue" type="Double">
  The revenue generated from the impression, in USD. 
  The revenue value may be either estimated or exact, depending on the precision specified by `revenuePrecision`. 
</Property>

---

<Property name="revenuePrecision" type="AdRevenuePrecision">
  The precision type of the revenue field.
</Property>

---

<Property name="revenueTotal" type="Double">
  The accumulated value of user ad revenue in USD from all ad format impressions. 
</Property>

---

<Property name="impressionDepth" type="Int">
  The total number of impressions across all ad formats for the current user, across all sessions. 
</Property>

### User ad summary 
CAS count the number of ad impressions and the total revenue of all formats at the time of a new impression. 
<CodeGroup synchronize="true">
```swift
let totalImpressions: Int = impression.impressionDepth
let totalRevenue: Double = impression.revenueTotal
```

```objc
NSInteger totalImpressions = impression.impressionDepth;
double totalRevenue = impression.revenueTotal;
```
</CodeGroup>

<Info>
Progress is saved between sessions until the user clears your app's data.
</Info>

### OnAdImpressionListener
A delegate for receive ad impression info from each ad format.

<CodeGroup synchronize="true">
```swift
import CleverAdsSolutions

extension MyViewController: CASImpressionDelegate {
    func adDidRecordImpression(info: CASContentInfo) {
        // Called when an ad impression occurs. 
    }
}
```

```objc
#import <CleverAdsSolutions/CleverAdsSolutions.h>

@interface MyViewController: UIViewController <CASImpressionDelegate>
@end

@implementation MyViewController

- (void)adDidRecordImpression:(CASContentInfo *)info {
    // Called when an ad impression occurs.
}

@end
```
</CodeGroup>

Each ad format have a `weak var impressionDelegate` property to receive `AdContentInfo` with impression details.  

<CodeGroup synchronize="true">
```swift
let impressionDelegate: CASImpressionDelegate = self

let appOpenAd: CASAppOpen
appOpenAd.impressionDelegate = impressionDelegate

let interstitialAd: CASInterstitial
interstitialAd.impressionDelegate = impressionDelegate

let rewardedAd: CASRewarded
rewardedAd.impressionDelegate = impressionDelegate

let nativeAd: NativeAdContent
nativeAd.impressionDelegate = impressionDelegate
```

```objc
id<CASImpressionDelegate> impressionDelegate = self;

CASAppOpen *appOpenAd;
appOpenAd.impressionDelegate = impressionDelegate;

CASInterstitial *interstitialAd;
interstitialAd.impressionDelegate = impressionDelegate;

CASRewarded *rewardedAd;
rewardedAd.impressionDelegate = impressionDelegate;

CASNativeAdContent *nativeAd;
nativeAd.impressionDelegate = impressionDelegate;
```
</CodeGroup>

## Automatic collect ad revenue
The CAS SDK have features to automatically collect ad revenue to Google Analytics and Tenjin Analytics. Contact your account manager for details of enabling automatic events.
### Google Analytics
If you haven't already, make sure to complete the following tasks:
1. Set up your project and app as described in [Get Started with Analytics](https://firebase.google.com/docs/analytics/get-started).
2. Make sure that you've linked your Firebase project to a Google Analytics account.
3. Ensure that you've included in your app the CAS SDK 3.5.0+.

To measure ad revenue, CAS SDK log [`ad_impression` events](https://firebase.google.com/docs/reference/android/com/google/firebase/analytics/FirebaseAnalytics.Event#public-static-final-string-ad_impression) whenever your user sees an advertisement in your app. These events contain details such as the ad platform, source, currency, and value. Optionally, the alternative event name can be `CAS_Impression`.  

### Tenjin
To measure ad revenue with Tenjin Analytics integrate the [Tenjin SDK](https://docs.tenjin.com/docs/ios-sdk#sdk-integration) or just include Tenjin SDK by CAS Cocoapods:
```ruby
pod 'CleverAdsSolutions-SDK/Tenjin', '{{ versions.ios }}'
```

CAS SDK automatically initializes the Tenjin SDK and sends ILRD if this option is enabled for your application.

## Custom collect ad revenue
The following code shows an implementation example for log `ad_impression` event to Google Analytics.

<CodeGroup synchronize="true">
```swift
extension MyViewController: CASImpressionDelegate {
    func adDidRecordImpression(info: AdContentInfo) {
        Analytics.logEvent(
           AnalyticsEventAdImpression,
           parameters: [
               AnalyticsParameterAdPlatform: "CAS",
               AnalyticsParameterAdSource: info.sourceName,
               AnalyticsParameterAdUnitName: info.sourceUnitID,
               AnalyticsParameterAdFormat: info.format.description,
               AnalyticsParameterValue: info.revenue,
               // All CAS revenue is sent in USD
               AnalyticsParameterCurrency: "USD",
           ])
   }
}
```

```objc
#import <FirebaseAnalytics/FirebaseAnalytics.h>

@interface MyViewController: UIViewController <CASImpressionDelegate>
@end

@implementation MyViewController

- (void)adDidRecordImpression:(CASContentInfo *)info {
    [FIRAnalytics logEventWithName:kFIREventAdImpression
                        parameters:@{
        kFIRParameterAdPlatform: @"CAS",
        kFIRParameterAdSource: info.sourceName ?: @"",
        kFIRParameterAdUnitName: info.sourceUnitID ?: @"",
        kFIRParameterAdFormat: info.format.description ?: @"",
        kFIRParameterValue: @(info.revenue),
        // All CAS revenue is sent in USD
        kFIRParameterCurrency: @"USD"
    }];
}

@end
```
</CodeGroup>