Resources API

ironSource App Analytics provides analysis of the in-app economy – the resources actual usage by the – spent & received resources, of all kinds. Identify where the places the users spent the most or received the most. What action the users perform in order to spend or receive the resources (E.g. Watch an ad, pay to get hints or progress after failing a level and others). 

Analyzing the resources usage within the application rely on two phases:

  • Settings API (Pre-init)
  • Users’ activity API (Post-init)

Settings API (Pre-init)

Use this API, prior to SDK initialization, to update the resources settings available in your application.

Only settings declared prior to initialization are available for resource updates

// The resources settings API
+(void)setAppResourcesWithResourceType:(ISAnalyticsResourceType) resourceType withValues:(NSArray <NSString *>*) values
// The resources settings API
static func setAppResources(resourceType : ISAnalyticsResourceType, values : [String])

Parameters

  • ISAnalyticsResourceType resourceType – An enumeration of the required resource list to update:
    • CURRENCIES – All the Resources available in your application (Such as coins, diamonds, gems etc)
    • PLACEMENTS – All the places the user can gain or consume resources in your application (Such as coins, diamonds, gems etc)
    • USERACTIONS – The action the user did that affected their resources (Such as watching an ad, failing a level, replacing with other resources etc.)
  • NSArray <NSString *>* values – An array of the available resources (string values)

Note: All parameters are mandatory 

Example of resources settings API

// Example of resources settings prior to SDK initialization
// Add all application resources and currencies
NSArray * appCurrencies = [NSArray arrayWithObjects:@"Coins", @"Gems" nil];
[IronSourceAnalytics setAppResourcesWithResourceType:ISAnalyticsResourceTypeCURRENCIES withValues:appCurrencies];
// Add all places where users can spend or gain app resources
NSArray * resourcesUpdatesPlacements = [NSArray arrayWithObjects:@"store", @"level_2_end", @"level_4_end", @"new_year_promo", @"first_rv_ad", nil];
[IronSourceAnalytics setAppResourcesWithResourceType:ISAnalyticsResourceTypePLACEMENTS withValues:resourcesUpdatesPlacements];
// Add all activities where it is possible to spend or gain app resources
NSArray * userActions = [NSArray arrayWithObjects:@"purchased_in_shop", @"level_completed", @"watched_ad", nil];
[IronSourceAnalytics setAppResourcesWithResourceType:ISAnalyticsResourceTypeUSERACTIONS withValues:userActions];
// Example of resources settings prior to SDK initialization
// Add all application resources and currencies
let appCurrencies : [String] = ["Coins", "Gems"]
IronSourceAnalytics.setAppResourcesWith(ISAnalyticsResourceType.CURRENCIES, withValues: iapOfferingLocations)
// Add all places where users can spend or gain app resources
let resourcesUpdatesPlacements : [String] = ["store", "level_2_end", "level_4_end", "new_year_promo", "first_rv_ad"]
IronSourceAnalytics.setAppResourcesWith(ISAnalyticsResourceType.PLACEMENTS, withValues: resourcesPlacements)
// Add all activities where it is possible to spend or gain app resources
let userActions : [String] = ["purchased_in_shop", "level_completed", "watched_ad"]
IronSourceAnalytics.setAppResourcesWith(ISAnalyticsResourceType.USERACTIONS, withValues: userActions)

Resources usage API (Post-init)

Use this API, following the SDK initialization, to update the users’ usage of the resources (Using the resources, placements & actions that were set in the pre-init)

// The resources settings API
+(void)updateUserResourcesWithResourceAction:(ISAnalyticsResourceUpdate *_Nonnull) appResource;
// The resources settings API
static func updateUserResources(appResource: ISAnalyticsResourceUpdate)

Parameters

  • ISAnalyticsResourceUpdate appResourceThe object that represents the resource update event

ISAnalyticsInAppPurchase Object

This object and it’s properties define all the required information regarding a resource update event

Constructor:

  • initWithCurrency:(NSString *) currency – The currency the user updated (Consumed or gained). Must be one of the resource currencies passed as part of the setAppResources SDK API, in CURRENCIES array

Set methods:

  • consumed:(NSInteger) amount – Represents use of the resource to buy something in the amount (consumed/gained is mandatory)
  • gained:(NSInteger) amount – Represents addition of resources to the user in the amount (consumed/gained is mandatory)
  • placement:(NSString *) placement – The location within the application where the user performed the action that caused change in his resources. Must be one of the resource placements passed as part of the setAppResources SDK API, in PLACEMENTS array (mandatory)
  • userAction:(NSString *) userAction – The action done by the user that caused change in his resources. Must be one of the user actions passed as part of the setAppResources SDK API, in USERACTIONS array (mandatory)
  • balance:(NSInteger) amount – The resource that was gained or consumed balance in the game (optional)

Example of resources update API

// Example of resource spent by user:
ISAnalyticsResourceUpdate *coins1 = [[[[[ISAnalyticsResourceUpdate alloc] initWithCurrency:@"coins"]consumed:30]placement:@"store"]userAction:@"purchased_in_shop"]balance:0];
 
[IronSourceAnalytics updateUserResources:coins1];
// Example of resource received by user:
ISAnalyticsResourceUpdate *coins2 = [[[[[ISAnalyticsResourceUpdate alloc] initWithCurrency:@"coins"]gained:99]placement:@"level_2_end"]userAction:@"level_completed"]balance:99];
 
[IronSourceAnalytics updateUserResources:coins2];
// Example of resource spent by user:
var coins1 = ISAnalyticsResourceUpdate(currency: "coins").consumed(30).placement("store").userAction("purchased_in_shop").balance(0)
 
IronSourceAnalytics.updateUserResources(coins1)
// Example of resource received by user:
var coins2 = ISAnalyticsResourceUpdate(currency: "coins").gained(99).placement("level_2_end").userAction("level_completed").balance(99)
        
IronSourceAnalytics.updateUserResources(coins2)