Resource Event - GameAnalytics/GA-SDK-JAVASCRIPT GitHub Wiki

Resource events are used to register the flow of your in-game economy (virtual currencies) - the sink (subtract) and the source (add) for each virtual currency.

:information_source:
Before calling the resource event it is needed to specify what discrete values can be used for currencies and item types in the Configuration phase.

source (add) Gem currency from an in-app purchase.

<!-- Tradional way -->
gameanalytics.GameAnalytics.addResourceEvent(gameanalytics.EGAResourceFlowType.Source, "Gems", 400, "IAP", "Coins400");
<!-- Command queue -->
GameAnalytics("addResourceEvent", "Source", "Gems", 400, "IAP", "Coins400");

sink (subtract) Gem currency to buy an item.

<!-- Tradional way -->
gameanalytics.GameAnalytics.addResourceEvent(gameanalytics.EGAResourceFlowType.Sink, "Gems", 400, "IAP", "Coins400");
<!-- Command queue -->
GameAnalytics("addResourceEvent", "Sink", "Gems", 400, "IAP", "Coins400");

sink (subtract) Gem currency to source (buy) some amount of another virtual currency (BeamBooster).

<!-- Tradional way -->
gameanalytics.GameAnalytics.addResourceEvent(ga.EGAResourceFlowType.Sink, "Gems", 100, "Boosters", "BeamBooster5Pack");

gameanalytics.GameAnalytics.addResourceEvent(ga.EGAResourceFlowType.Source, "BeamBooster", 5, "Gems", "BeamBooster5Pack");

<!-- Command queue -->
GameAnalytics("addResourceEvent", "Sink", "Gems", 100, "Boosters", "BeamBooster5Pack");

GameAnalytics("addResourceEvent", "Source", "BeamBooster", 5, "Gems", "BeamBooster5Pack");

sink (subtract) 3 BeamBooster currency that were used during a level.

<!-- Tradional way -->
gameanalytics.GameAnalytics.addResourceEvent(ga.EGAResourceFlowType.Sink, "BeamBooster", 3, "Gameplay", "BeamBooster5Pack");
<!-- Command queue -->
GameAnalytics("addResourceEvent", "Sink", "BeamBooster", 3, "Gameplay", "BeamBooster5Pack");

 

Field Type Description Example
flowType enum A defined enum for sourcing and sinking resources. gameanalytics.EGAResourceFlowType.Sink
currency string The resource type/currency to track. Has to be one of the configured available resource currencies.This string can only contain [A-Za-z] characters. Gems, BeamBoosters, Coins
amount float Amount sourced or sinked. 0 or negative numbers are not allowed. 100.0
itemType string For sink events it can describe an item category you are buying (Weapons) or a place (Gameplay) the currency was consumed. For source events it can describe how the currency was gained. For example "IAP" (for in-app purchase) or from using another currency (Gems). Has to be one of the configured available itemTypes. Weapons, IAP, Gameplay, Boosters
itemId string For sink events it can describe the specific item (SwordOfFire) gained. If consumed during Gameplay you can simply use "Consumed". For source events it describes how the player got the added currency. This could be buying a pack (BoosterPack5) or earned through Gameplay when completing a level (LevelEnd). BoosterPack5, SwordOfFire, LevelEnd, Coins400

 

:warning:
Be carefull to not call the resource event too often ! In a game where the user collect coins fairly fast you should not call a Source event on each pickup. Instead you should count the coins and send a single Source event when the user either complete or fail the level.

 

:information_source:
For more information on the resource event go here.

 

NEXT  →