|
| 1 | +# Track Unity ad revenue with Adjust SDK |
| 2 | + |
| 3 | +[Adjust iOS SDK README][ios-readme] |
| 4 | + |
| 5 | +Minimum SDK version required for this feature: |
| 6 | + |
| 7 | +- **Adjust SDK v4.29.7** |
| 8 | + |
| 9 | +If you want to track your ad revenue with the Unity SDK, you can use our SDK-to-SDK integration to pass this information to the Adjust backend. To do this, you will need to construct an Adjust ad revenue object containing the information you wish to record, then pass the object to the `trackAdRevenue` method. |
| 10 | + |
| 11 | +> Note: If you have any questions about ad revenue tracking with Unity, please contact your dedicated account manager or send an email to [support@adjust.com](mailto:support@adjust.com). |
| 12 | +
|
| 13 | +For more information, see the Unity Mediation [API documentation](https://docs.unity.com/mediation/APIReferenceIOS.html) and [impression event documentation](https://docs.unity.com/mediation/SDKIntegrationIOSImpressionEvents.html). |
| 14 | + |
| 15 | +### Example |
| 16 | + |
| 17 | +```objc |
| 18 | +@interface ViewController() |
| 19 | + |
| 20 | +@property(nonatomic, strong) UMSImpressionListenerWithBlocks * listener; |
| 21 | + |
| 22 | +@end |
| 23 | + |
| 24 | +@implementation ViewController |
| 25 | + |
| 26 | +- (void) viewDidLoad { |
| 27 | + [super viewDidLoad]; |
| 28 | + |
| 29 | + self.listener = [[UMSImpressionListenerWithBlocks alloc] init]; |
| 30 | + self.listener.onImpressionBlock = ^ (NSString *adUnitId, UMSImpressionData *impressionData) { |
| 31 | + if (impressionData) { |
| 32 | + NSLog(@ "impressionData: %@", [impressionData getJsonRepresentation]); |
| 33 | + // send impression data to Adjust |
| 34 | + ADJAdRevenue *adjustAdRevenue = [[ADJAdRevenue alloc] initWithSource:ADJAdRevenueSourceUnity]; |
| 35 | + adjustAdRevenue.setRevenue([impressionData.revenue doubleValue], impressionData.currency); |
| 36 | + // optional fields |
| 37 | + adjustAdRevenue.setAdRevenueNetwork(impressionData.adSourceName); |
| 38 | + adjustAdRevenue.setAdRevenueUnit(impressionData.adUnitId); |
| 39 | + adjustAdRevenue.setAdRevenuePlacement(impressionData.adSourceInstance); |
| 40 | + // track Adjust ad revenue |
| 41 | + Adjust.trackAdRevenue(adjustAdRevenue); |
| 42 | + } else { |
| 43 | + NSLog(@ "Data does not exist due to not enabling User-Level Reporting"); |
| 44 | + } |
| 45 | + }; |
| 46 | + [UMSImpressionEventPublisher subscribe: self.listener]; |
| 47 | +} |
| 48 | + |
| 49 | +@end |
| 50 | +``` |
| 51 | +
|
| 52 | +[ios-readme]: ../../../README.md |
0 commit comments